Whamcloud - gitweb
LU-1337 llite: 3.3 changes super_operations/inode_operations
authorLiu Xuezhao <xuezhao.liu@emc.com>
Wed, 31 Oct 2012 07:43:54 +0000 (15:43 +0800)
committerOleg Drokin <green@whamcloud.com>
Wed, 5 Dec 2012 13:56:24 +0000 (08:56 -0500)
1. Kernel 3.3 switchs super_operations to use dentry as parameter
   (kernel commit 34c80b1d93e6e20ca9dea0baf583a5b5510d92d4).
   Add LC_SUPEROPS_USE_DENTRY/HAVE_SUPEROPS_USE_DENTRY to check it.
2. Kernel 3.3 switchs inode_operations to use umode_t as parameter
   (kernel commit 1a67aafb5f72a436ca044293309fa7e6351d6a35).
   Add LC_INODEOPS_USE_UMODE_T/HAVE_INODEOPS_USE_UMODE_T to check it.

Signed-off-by: Liu Xuezhao <xuezhao.liu@emc.com>
Change-Id: I7564506cf4365c8da113a81058f68b9ef8b092a4
Reviewed-on: http://review.whamcloud.com/3581
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Yang Sheng <yang.sheng@intel.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
lustre/autoconf/lustre-core.m4
lustre/include/linux/lustre_compat25.h
lustre/llite/llite_internal.h
lustre/llite/llite_lib.c
lustre/llite/namei.c

index c284b8c..0cbd114 100644 (file)
@@ -1955,6 +1955,61 @@ LB_LINUX_TRY_COMPILE([
 ])
 
 #
+# 3.3 switchs super_operations to use dentry as parameter (but not vfsmount)
+# see kernel commit 34c80b1d93e6e20ca9dea0baf583a5b5510d92d4
+#
+AC_DEFUN([LC_SUPEROPS_USE_DENTRY],
+[AC_MSG_CHECKING([if super_operations use dentry as parameter])
+tmp_flags="$EXTRA_KCFLAGS"
+EXTRA_KCFLAGS="-Werror"
+LB_LINUX_TRY_COMPILE([
+       #include <linux/fs.h>
+       int show_options(struct seq_file *seq, struct dentry *root){
+               return 0;
+       }
+],[
+       struct super_operations ops;
+       ops.show_options = show_options;
+],[
+       AC_DEFINE(HAVE_SUPEROPS_USE_DENTRY, 1,
+                 [super_operations use dentry as parameter])
+       AC_MSG_RESULT([yes])
+],[
+       AC_MSG_RESULT([no])
+])
+EXTRA_KCFLAGS="$tmp_flags"
+])
+
+#
+# 3.3 switchs inode_operations to use umode_t as parameter (but not int)
+# see kernel commit 1a67aafb5f72a436ca044293309fa7e6351d6a35
+#
+AC_DEFUN([LC_INODEOPS_USE_UMODE_T],
+[AC_MSG_CHECKING([if inode_operations use umode_t as parameter])
+tmp_flags="$EXTRA_KCFLAGS"
+EXTRA_KCFLAGS="-Werror"
+LB_LINUX_TRY_COMPILE([
+       #include <linux/fs.h>
+       #include <linux/types.h>
+       int my_mknod(struct inode *dir, struct dentry *dchild,
+                    umode_t mode, dev_t dev)
+       {
+               return 0;
+       }
+],[
+       struct inode_operations ops;
+       ops.mknod = my_mknod;
+],[
+       AC_DEFINE(HAVE_INODEOPS_USE_UMODE_T, 1,
+                 [inode_operations use umode_t as parameter])
+       AC_MSG_RESULT([yes])
+],[
+       AC_MSG_RESULT([no])
+])
+EXTRA_KCFLAGS="$tmp_flags"
+])
+
+#
 # LC_PROG_LINUX
 #
 # Lustre linux kernel checks
@@ -2111,6 +2166,8 @@ AC_DEFUN([LC_PROG_LINUX],
         # 3.3
         LC_HAVE_MIGRATE_HEADER
         LC_MIGRATEPAGE_4ARGS
+        LC_SUPEROPS_USE_DENTRY
+        LC_INODEOPS_USE_UMODE_T
 
          #
          if test x$enable_server = xyes ; then
index 8b2273d..df109a8 100644 (file)
@@ -722,4 +722,10 @@ static inline void set_nlink(struct inode *inode, unsigned int nlink)
 }
 #endif
 
+#ifdef HAVE_INODEOPS_USE_UMODE_T
+# define ll_umode_t    umode_t
+#else
+# define ll_umode_t    int
+#endif
+
 #endif /* _COMPAT25_H */
index 2623e38..a424766 100644 (file)
@@ -820,10 +820,14 @@ void ll_umount_begin(struct vfsmount *vfsmnt, int flags);
 void ll_umount_begin(struct super_block *sb);
 #endif
 int ll_remount_fs(struct super_block *sb, int *flags, char *data);
+#ifdef HAVE_SUPEROPS_USE_DENTRY
+int ll_show_options(struct seq_file *seq, struct dentry *dentry);
+#else
 int ll_show_options(struct seq_file *seq, struct vfsmount *vfs);
+#endif
 void ll_dirty_page_discard_warn(cfs_page_t *page, int ioret);
 int ll_prep_inode(struct inode **inode, struct ptlrpc_request *req,
-                  struct super_block *);
+                 struct super_block *);
 void lustre_dump_dentry(struct dentry *, int recur);
 void lustre_dump_inode(struct inode *);
 int ll_obd_statfs(struct inode *inode, void *arg);
index 016096f..5813a29 100644 (file)
@@ -2316,12 +2316,21 @@ void ll_finish_md_op_data(struct md_op_data *op_data)
         OBD_FREE_PTR(op_data);
 }
 
+#ifdef HAVE_SUPEROPS_USE_DENTRY
+int ll_show_options(struct seq_file *seq, struct dentry *dentry)
+#else
 int ll_show_options(struct seq_file *seq, struct vfsmount *vfs)
+#endif
 {
         struct ll_sb_info *sbi;
 
-        LASSERT((seq != NULL) && (vfs != NULL));
-        sbi = ll_s2sbi(vfs->mnt_sb);
+#ifdef HAVE_SUPEROPS_USE_DENTRY
+       LASSERT((seq != NULL) && (dentry != NULL));
+       sbi = ll_s2sbi(dentry->d_sb);
+#else
+       LASSERT((seq != NULL) && (vfs != NULL));
+       sbi = ll_s2sbi(vfs->mnt_sb);
+#endif
 
         if (sbi->ll_flags & LL_SBI_NOLCK)
                 seq_puts(seq, ",nolock");
index 32095e0..9fdaf83 100644 (file)
@@ -818,7 +818,7 @@ static int ll_mknod_generic(struct inode *dir, struct qstr *name, int mode,
 }
 
 static int ll_create_nd(struct inode *dir, struct dentry *dentry,
-                        int mode, struct nameidata *nd)
+                       ll_umode_t mode, struct nameidata *nd)
 {
         struct lookup_intent *it = ll_d2d(dentry)->lld_it;
         int rc;
@@ -1133,7 +1133,7 @@ static int ll_rename_generic(struct inode *src, struct dentry *src_dparent,
         RETURN(err);
 }
 
-static int ll_mknod(struct inode *dir, struct dentry *dchild, int mode,
+static int ll_mknod(struct inode *dir, struct dentry *dchild, ll_umode_t mode,
                    dev_t rdev)
 {
        return ll_mknod_generic(dir, &dchild->d_name, mode,
@@ -1144,25 +1144,30 @@ static int ll_unlink(struct inode * dir, struct dentry *dentry)
 {
         return ll_unlink_generic(dir, NULL, dentry, &dentry->d_name);
 }
-static int ll_mkdir(struct inode *dir, struct dentry *dentry, int mode)
+
+static int ll_mkdir(struct inode *dir, struct dentry *dentry, ll_umode_t mode)
 {
         return ll_mkdir_generic(dir, &dentry->d_name, mode, dentry);
 }
+
 static int ll_rmdir(struct inode *dir, struct dentry *dentry)
 {
         return ll_rmdir_generic(dir, NULL, dentry, &dentry->d_name);
 }
+
 static int ll_symlink(struct inode *dir, struct dentry *dentry,
                       const char *oldname)
 {
         return ll_symlink_generic(dir, &dentry->d_name, oldname, dentry);
 }
+
 static int ll_link(struct dentry *old_dentry, struct inode *dir,
                    struct dentry *new_dentry)
 {
         return ll_link_generic(old_dentry->d_inode, dir, &new_dentry->d_name,
                                new_dentry);
 }
+
 static int ll_rename(struct inode *old_dir, struct dentry *old_dentry,
                      struct inode *new_dir, struct dentry *new_dentry)
 {