From: Michal Marek <mmarek@suse.cz>
Subject: [PATCH] oracleasm: quick fix to build with 3.0

Signed-off-by: Michal Marek <mmarek@suse.cz>
---
 configure.in    |   14 +++++++-------
 kernel/driver.c |   43 +++++++++++++------------------------------
 2 files changed, 20 insertions(+), 37 deletions(-)

--- oracleasm-2.0.5.orig/configure.in
+++ oracleasm-2.0.5/configure.in
@@ -66,7 +66,7 @@ AC_ARG_WITH(kernel, [  --with-kernel=dir
   fi
 ])
 
-if test ! -f "${kerneldir}/include/linux/autoconf.h"; then
+if test ! -f "${kerneldir}/include/linux/version.h"; then
   AC_MSG_RESULT([not found])
   KERNELDIR=
 else
@@ -104,7 +104,7 @@ KERNELSRC="$kernelsourcedir"
 KERNELBUILD="$kerneldir"
 KERNELINC="$KERNELSRC/include"
 
-if test ! -f "$KERNELBUILD/include/linux/autoconf.h"; then
+if test ! -f "$KERNELBUILD/include/linux/version.h"; then
   AC_MSG_WARN(No configured kernel include tree found)
 fi
 
@@ -121,7 +121,7 @@ elif test "x$KERNELSRC" != "x"; then
   CPPFLAGS="-I$KERNELINC $CPPFLAGS"
 
   AC_EGREP_CPP(kernel_is_SuSE,
-[#include <linux/autoconf.h>
+[#include <generated/autoconf.h>
 #ifdef CONFIG_SUSE_KERNEL
   kernel_is_SuSE
 #endif
@@ -155,15 +155,15 @@ kversion="$kbuildversion"
 
 BUILD_DRIVER=
 case "$kversion" in
-  2.6.*)
-    BUILD_DRIVER=yes
+  [01].* | 2.[0-5].* )
+    AC_MSG_RESULT([This module only supports kernel version 2.6.x, disabling driver build])
     ;;
   none)
     AC_MSG_RESULT([Could not determine kernel version, disabling driver build])
     ;;
   *)
-    AC_MSG_RESULT([This module only supports kernel version 2.6.x, disabling driver build])
-  ;;
+    BUILD_DRIVER=yes
+    ;;
 esac
 AC_SUBST(BUILD_DRIVER)
 
--- oracleasm-2.0.5.orig/kernel/driver.c
+++ oracleasm-2.0.5/kernel/driver.c
@@ -64,7 +64,6 @@
 #include <linux/slab.h>
 #include <linux/blkdev.h>
 #include <linux/mount.h>
-#include <linux/smp_lock.h>
 #include <linux/parser.h>
 #include <linux/backing-dev.h>
 #include <linux/compat.h>
@@ -347,8 +346,7 @@ static void asmdisk_evict_inode(struct i
 		mlog(ML_DISK,
 		     "Releasing disk 0x%p (bdev 0x%p, dev %X)\n",
 		     d, d->d_bdev, d->d_bdev->bd_dev);
-		bd_release(d->d_bdev);
-		kapi_asm_blkdev_put(d->d_bdev, FMODE_WRITE | FMODE_READ);
+		kapi_asm_blkdev_put(d->d_bdev, FMODE_WRITE | FMODE_READ | FMODE_EXCL);
 		d->d_bdev = NULL;
 	}
 
@@ -373,19 +371,19 @@ static int asmdisk_get_sb(struct file_sy
 			     &asmdisk_sops, 0x61736D64, mnt);
 }
 #else
-static struct super_block *asmdisk_get_sb(struct file_system_type *fs_type,
+static struct dentry *asmdisk_get_sb(struct file_system_type *fs_type,
 					  int flags,
 					  const char *dev_name,
 					  void *data)
 {
-	return get_sb_pseudo(fs_type, "asmdisk:",
-			     &asmdisk_sops, 0x61736D64);
+	return mount_pseudo(fs_type, "asmdisk:",
+			     &asmdisk_sops, NULL, 0x61736D64);
 }
 #endif
 
 static struct file_system_type asmdisk_type = {
 	.name		= "asmdisk",
-	.get_sb		= asmdisk_get_sb,
+	.mount		= asmdisk_get_sb,
 	.kill_sb	= kill_anon_super,
 };
 
@@ -751,22 +749,18 @@ static int asm_open_disk(struct file *fi
 
 	mlog_entry("(0x%p, 0x%p)\n", file, bdev);
 
-	ret = kapi_asm_blkdev_get(bdev, FMODE_WRITE | FMODE_READ);
+	ret = kapi_asm_blkdev_get(bdev, FMODE_WRITE | FMODE_READ | FMODE_EXCL, bdev);
 	if (ret)
 		goto out;
 
-	ret = bd_claim(bdev, inode->i_sb);
-	if (ret)
-		goto out_get;
-
 	ret = set_blocksize(bdev, bdev_physical_block_size(bdev));
 	if (ret)
-		goto out_claim;
+		goto out_get;
 
 	ret = -ENOMEM;
 	h = kmalloc(sizeof(struct asm_disk_head), GFP_KERNEL);
 	if (!h)
-		goto out_claim;
+		goto out_get;
 
 	mlog(ML_DISK, "Looking up disk for bdev %p (dev %X)\n", bdev,
 	     bdev->bd_dev);
@@ -807,8 +801,7 @@ static int asm_open_disk(struct file *fi
 		mlog(ML_DISK,
 		     "Open of disk 0x%p (bdev 0x%p, dev %X)\n",
 		     d, d->d_bdev, d->d_bdev->bd_dev);
-		bd_release(bdev);
-		kapi_asm_blkdev_put(bdev, FMODE_WRITE | FMODE_READ);
+		kapi_asm_blkdev_put(bdev, FMODE_WRITE | FMODE_READ | FMODE_EXCL);
 	}
 
 	h->h_disk = d;
@@ -828,11 +821,8 @@ static int asm_open_disk(struct file *fi
 out_head:
 	kfree(h);
 
-out_claim:
-	bd_release(bdev);
-
 out_get:
-	kapi_asm_blkdev_put(bdev, FMODE_WRITE | FMODE_READ);
+	kapi_asm_blkdev_put(bdev, FMODE_WRITE | FMODE_READ | FMODE_EXCL);
 
 out:
 	mlog_exit(ret);
@@ -917,7 +907,6 @@ static int asm_close_disk(struct file *f
 			if (!atomic_read(&d->d_ios))
 				break;
 
-			blk_run_address_space(bdev->bd_inode->i_mapping);
 			/*
 			 * Timeout of one second.  This is slightly
 			 * subtle.  In this wait, and *only* this wait,
@@ -1530,8 +1519,6 @@ static int asm_maybe_wait_io(struct file
 					      asmdisk_test, &args);
 			if (disk_inode) {
 				d = ASMDISK_I(disk_inode);
-				if (d->d_bdev)
-					blk_run_address_space(d->d_bdev->bd_inode->i_mapping);
 				iput(&d->vfs_inode);
 			}
 
@@ -1682,8 +1669,6 @@ static int asm_wait_completion(struct fi
 				      asmdisk_test, &args);
 		if (disk_inode) {
 			d = ASMDISK_I(disk_inode);
-			if (d->d_bdev)
-				blk_run_address_space(d->d_bdev->bd_inode->i_mapping);
 			iput(&d->vfs_inode);
 		}
 
@@ -2186,8 +2171,6 @@ static int asmfs_file_release(struct ino
 				      asmdisk_test, &args);
 		if (disk_inode) {
 			d = ASMDISK_I(disk_inode);
-			if (d->d_bdev)
-				blk_run_address_space(d->d_bdev->bd_inode->i_mapping);
 			iput(&d->vfs_inode);
 		}
 
@@ -2899,18 +2882,18 @@ static int asmfs_get_sb(struct file_syst
 	return get_sb_nodev(fs_type, flags, data, asmfs_fill_super, mnt);
 }
 #else
-static struct super_block *asmfs_get_sb(struct file_system_type *fs_type,
+static struct dentry *asmfs_get_sb(struct file_system_type *fs_type,
 					int flags, const char *dev_name,
 					void *data)
 {
-	return get_sb_nodev(fs_type, flags, data, asmfs_fill_super);
+	return mount_nodev(fs_type, flags, data, asmfs_fill_super);
 }
 #endif  /* GET_SB_HAS_VFSMOUNT */
 
 static struct file_system_type asmfs_fs_type = {
 	.owner		= THIS_MODULE,
 	.name		= "oracleasmfs",
-	.get_sb		= asmfs_get_sb,
+	.mount		= asmfs_get_sb,
 	.kill_sb	= kill_litter_super,
 };
 
