[Oracleasm-commits] jlbec commits r347 - in trunk: . kapi-compat kapi-compat/include kernel

svn-commits@oss.oracle.com svn-commits at oss.oracle.com
Fri Jun 30 17:02:24 CDT 2006


Author: jlbec
Date: 2006-06-30 17:02:22 -0500 (Fri, 30 Jun 2006)
New Revision: 347

Added:
   trunk/kapi-compat/
   trunk/kapi-compat/include/
   trunk/kapi-compat/include/i_mutex.h
   trunk/kfeature.m4
Modified:
   trunk/Config.make.in
   trunk/aclocal.m4
   trunk/configure.in
   trunk/kernel/Makefile
   trunk/kernel/oracleasm.c
   trunk/kernel/transaction_file.c
Log:

oracleasm: Add compatability checks so that recent kernels can be used.



Modified: trunk/Config.make.in
===================================================================
--- trunk/Config.make.in	2006-06-30 21:55:28 UTC (rev 346)
+++ trunk/Config.make.in	2006-06-30 22:02:22 UTC (rev 347)
@@ -21,6 +21,7 @@
 datadir = @datadir@
 sysconfdir = @sysconfdir@
 mandir = @mandir@
+datarootdir = @datarootdir@
 
 top_builddir = .
 
@@ -50,4 +51,10 @@
 KERNELVER = @KERNELVER@
 BUILD_DRIVER = @BUILD_DRIVER@
 
+else
+
+BACKING_DEV_CAPABILITIES = @BACKING_DEV_CAPABILITIES@
+GET_SB_HAS_VFSMOUNT = @GET_SB_HAS_VFSMOUNT@
+EXTRA_CFLAGS += @KAPI_COMPAT_CFLAGS@
+
 endif

Modified: trunk/aclocal.m4
===================================================================
--- trunk/aclocal.m4	2006-06-30 21:55:28 UTC (rev 346)
+++ trunk/aclocal.m4	2006-06-30 22:02:22 UTC (rev 347)
@@ -1 +1,2 @@
+m4_include([kfeature.m4])
 m4_include([mbvendor.m4])

Modified: trunk/configure.in
===================================================================
--- trunk/configure.in	2006-06-30 21:55:28 UTC (rev 346)
+++ trunk/configure.in	2006-06-30 22:02:22 UTC (rev 347)
@@ -161,8 +161,36 @@
 KERNELVER=$kversion
 AC_SUBST(KERNELVER)
 
+KAPI_COMPAT_CFLAGS=
+BACKING_DEV_CAPABILITIES=
+GET_SB_HAS_VFSMOUNT=
+if test x"$BUILD_DRIVER" = "xyes"; then
+  KERNELINC="${KERNELDIR}/include"  # Needed by kfeature.m4
+  KAPI_COMPAT_HEADERS=
 
+  OCFS2_CHECK_KERNEL([capabilities mask in backing_dev_info], backing-dev.h,
+    BACKING_DEV_CAPABILITIES=yes, , [\<BDI_CAP_NO_WRITEBACK\>])
 
+  OCFS2_CHECK_KERNEL([vfsmount in ->get_sb() helpers], fs.h,
+    GET_SB_HAS_VFSMOUNT=yes, , [^extern int get_sb_pseudo])
+
+  mutex_compat_header=
+  OCFS2_CHECK_KERNEL([for mutex API], mutex.h, ,
+    mutex_compat_header="i_mutex.h", [mutex_lock])
+  KAPI_COMPAT_HEADERS="$KAPI_COMPAT_HEADERS $mutex_compat_header"
+
+  # using -include has two advantages:
+  #  the source doesn't need to know to include compat headers
+  #  the compat header file names don't go through the search path
+  for h in $KAPI_COMPAT_HEADERS; do
+    KAPI_COMPAT_CFLAGS="$KAPI_COMPAT_CFLAGS -include \$(OUR_TOPDIR)/kapi-compat/include/$h"
+  done
+fi
+AC_SUBST(KAPI_COMPAT_CFLAGS)
+AC_SUBST(BACKING_DEV_CAPABILITIES)
+AC_SUBST(GET_SB_HAS_VFSMOUNT)
+
+
 AC_OUTPUT([Config.make
 include/linux/asm_module_version.h
 vendor/common/oracleasm-support.spec-generic

Added: trunk/kapi-compat/include/i_mutex.h
===================================================================
--- trunk/kapi-compat/include/i_mutex.h	2006-06-30 21:55:28 UTC (rev 346)
+++ trunk/kapi-compat/include/i_mutex.h	2006-06-30 22:02:22 UTC (rev 347)
@@ -0,0 +1,10 @@
+#ifndef KAPI_IMUTEX_H
+#define KAPI_IMUTEX_H
+
+#define mutex_lock down
+#define mutex_unlock up
+#define mutex_trylock(__m) (!down_trylock(__m))
+
+#define i_mutex i_sem
+
+#endif /* KAPI_IMUTEX_H */

Modified: trunk/kernel/Makefile
===================================================================
--- trunk/kernel/Makefile	2006-06-30 21:55:28 UTC (rev 346)
+++ trunk/kernel/Makefile	2006-06-30 22:02:22 UTC (rev 347)
@@ -7,6 +7,7 @@
 # We are included by kbuild
 
 ORACLEASM_SRC_DIR	:= $(M)
+OUR_TOPDIR		:= $(M)/..
 
 include $(ORACLEASM_SRC_DIR)/../Config.make
 endif
@@ -50,6 +51,14 @@
 INCLUDES = -I. -I$(ORACLEASM_SRC_DIR)/../include
 EXTRA_CFLAGS += $(DEFINES) $(INCLUDES)
 
+ifdef BACKING_DEV_CAPABILITIES
+EXTRA_CFLAGS += -DBACKING_DEV_CAPABILITIES
+endif
+
+ifdef GET_SB_HAS_VFSMOUNT
+EXTRA_CFLAGS += -DGET_SB_HAS_VFSMOUNT
+endif
+
 obj-m += oracleasm.o
 #oracleasm-objs := $(OBJECTS)
 

Modified: trunk/kernel/oracleasm.c
===================================================================
--- trunk/kernel/oracleasm.c	2006-06-30 21:55:28 UTC (rev 346)
+++ trunk/kernel/oracleasm.c	2006-06-30 22:02:22 UTC (rev 347)
@@ -269,11 +269,11 @@
 
 static struct backing_dev_info memory_backing_dev_info = {
 	.ra_pages	= 0,	/* No readahead */
-#if 1
+#ifdef BACKING_DEV_CAPABILITIES
+	.capabilities   = BDI_CAP_NO_ACCT_DIRTY | BDI_CAP_NO_WRITEBACK,
+#else
 	.memory_backed	= 1,	/* Does not contribute to dirty memory */
-#else
-	.capabilities   = BDI_CAP_NO_ACCT_DIRTY | BDI_CAP_NO_WRITEBACK,
-#endif
+#endif  /* OLD_BACKING_DEV */
 };
 
 
@@ -352,6 +352,15 @@
 	.clear_inode		= asmdisk_clear_inode,
 };
 
+#ifdef GET_SB_HAS_VFSMOUNT
+static int asmdisk_get_sb(struct file_system_type *fs_type, int flags,
+			  const char *dev_name, void *data,
+			  struct vfsmount *mnt)
+{
+	return get_sb_pseudo(fs_type, "asmdisk:",
+			     &asmdisk_sops, 0x61736D64, mnt);
+}
+#else
 static struct super_block *asmdisk_get_sb(struct file_system_type *fs_type,
 					  int flags,
 					  const char *dev_name,
@@ -360,6 +369,7 @@
 	return get_sb_pseudo(fs_type, "asmdisk:",
 			     &asmdisk_sops, 0x61736D64);
 }
+#endif
 
 static struct file_system_type asmdisk_type = {
 	.name		= "asmdisk",
@@ -2712,18 +2722,35 @@
 }
 
 
+/*
+ * We want all the simple_dir_operations, but we cannot reference them
+ * directly -- they are not EXPORT_SYMBOL()d.  So, we just copy the
+ * exported simple_dir_operations before adding any specific functions
+ * of our own.
+ *
+ * This means that asmfs_dir_operations can't be const.  Oh, well.
+ */
 static void __init init_asmfs_dir_operations(void) {
 	asmfs_dir_operations		= simple_dir_operations;
 	asmfs_dir_operations.fsync	= simple_sync_file;
 };
 
 
+#ifdef GET_SB_HAS_VFSMOUNT
+static int asmfs_get_sb(struct file_system_type *fs_type, int flags,
+			const char *dev_name, void *data,
+			struct vfsmount *mnt)
+{
+	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,
 					int flags, const char *dev_name,
 					void *data)
 {
 	return get_sb_nodev(fs_type, flags, data, asmfs_fill_super);
 }
+#endif  /* GET_SB_HAS_VFSMOUNT */
 
 static struct file_system_type asmfs_fs_type = {
 	.owner		= THIS_MODULE,

Modified: trunk/kernel/transaction_file.c
===================================================================
--- trunk/kernel/transaction_file.c	2006-06-30 21:55:28 UTC (rev 346)
+++ trunk/kernel/transaction_file.c	2006-06-30 22:02:22 UTC (rev 347)
@@ -52,12 +52,12 @@
 	if (!ar)
 		return -ENOMEM;
 	ar->size = 0;
-	down(&file->f_dentry->d_inode->i_sem);
+	mutex_lock(&file->f_dentry->d_inode->i_mutex);
 	if (file->private_data)
 		rv = -EINVAL;
 	else
 		file->private_data = ar;
-	up(&file->f_dentry->d_inode->i_sem);
+	mutex_unlock(&file->f_dentry->d_inode->i_mutex);
 	if (rv) {
 		kfree(ar);
 		return rv;

Added: trunk/kfeature.m4
===================================================================
--- trunk/kfeature.m4	2006-06-30 21:55:28 UTC (rev 346)
+++ trunk/kfeature.m4	2006-06-30 22:02:22 UTC (rev 347)
@@ -0,0 +1,21 @@
+AC_DEFUN([OCFS2_CHECK_KERNEL],
+  [AC_MSG_CHECKING([for $1])
+   kernel_check_regexp="m4_default([$5], [\<$1(])"
+
+   kernel_check_headers=
+   for kfile in $2; do
+     kernel_check_headers="$kernel_check_headers $KERNELINC/linux/$kfile"
+   done
+
+   if grep "$kernel_check_regexp" $kernel_check_headers >/dev/null 2>&1 ; then
+     m4_default([$3], :)
+     AC_MSG_RESULT(yes)
+   else
+     m4_default([$4], :)
+     AC_MSG_RESULT(no)
+   fi
+])# OCFS2_CHECK_KERNEL
+
+AC_DEFUN([OCFS2_KERNEL_COMPAT],
+  [OCFS2_CHECK_KERNEL($1, $2, , 
+     [KAPI_COMPAT_HEADERS="$KAPI_COMPAT_HEADERS $1.h"])])




More information about the Oracleasm-commits mailing list