Whamcloud - gitweb
LU-9735 compat: heed the fs_struct::seq 07/28907/7
authorBobi Jam <bobijam.xu@intel.com>
Fri, 8 Sep 2017 13:56:03 +0000 (21:56 +0800)
committerOleg Drokin <oleg.drokin@intel.com>
Wed, 31 Jan 2018 05:51:45 +0000 (05:51 +0000)
2.6.37 kernel uses a seqlock in the fs_struct to enable us to take
an atomic copy of the complete cwd and root paths.

Signed-off-by: Bobi Jam <bobijam.xu@intel.com>
Change-Id: I35384b8f5c468a8c142a59032f3148b698a0c79e
Reviewed-on: https://review.whamcloud.com/28907
Reviewed-by: Jinshan Xiong <jinshan.xiong@intel.com>
Reviewed-by: Fan Yong <fan.yong@intel.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/autoconf/lustre-core.m4
lustre/include/lustre_compat.h

index c2f5038..b8f4e45 100644 (file)
@@ -595,6 +595,22 @@ kernel_locked, [
 ]) # LC_KERNEL_LOCKED
 
 #
+# LC_FS_STRUCT_SEQCOUNT
+#
+# 2.6.37 uses seqlock in fs_struct
+#
+AC_DEFUN([LC_FS_STRUCT_SEQCOUNT], [
+LB_CHECK_COMPILE([if fs_struct use seqcount],
+fs_struct_seqcount, [
+       #include <linux/fs_struct.h>
+],[
+       ((struct fs_struct *)0)->seq = (struct seqcount){ 0 };
+],[
+       AC_DEFINE(HAVE_FS_STRUCT_SEQCOUNT, 1, [fs_struct use seqcount])
+])
+]) # LC_FS_STRUCT_SEQCOUNT
+
+#
 # LC_D_COMPARE_7ARGS
 #
 # 2.6.38 dentry_operations.d_compare() taken 7 arguments.
@@ -2729,6 +2745,7 @@ AC_DEFUN([LC_PROG_LINUX], [
 
        # 2.6.37
        LC_KERNEL_LOCKED
+       LC_FS_STRUCT_SEQCOUNT
 
        # 2.6.38
        LC_BLKDEV_GET_BY_DEV
index 6a5b6cc..2e41ef4 100644 (file)
 # define UNLOCK_FS_STRUCT(fs)  spin_unlock(&(fs)->lock)
 #endif
 
+#ifdef HAVE_FS_STRUCT_SEQCOUNT
+# define WRITE_FS_SEQ_BEGIN(fs)        write_seqcount_begin(&(fs)->seq)
+# define WRITE_FS_SEQ_END(fs)  write_seqcount_end(&(fs)->seq)
+#else
+# define WRITE_FS_SEQ_BEGIN(fs)
+# define WRITE_FS_SEQ_END(fs)
+#endif
 static inline void ll_set_fs_pwd(struct fs_struct *fs, struct vfsmount *mnt,
                                  struct dentry *dentry)
 {
-        struct path path;
-        struct path old_pwd;
-
-        path.mnt = mnt;
-        path.dentry = dentry;
-        LOCK_FS_STRUCT(fs);
-        old_pwd = fs->pwd;
-        path_get(&path);
-        fs->pwd = path;
-        UNLOCK_FS_STRUCT(fs);
-
-        if (old_pwd.dentry)
-                path_put(&old_pwd);
+       struct path path;
+       struct path old_pwd;
+
+       path.mnt = mnt;
+       path.dentry = dentry;
+       path_get(&path);
+       LOCK_FS_STRUCT(fs);
+       WRITE_FS_SEQ_BEGIN(fs);
+       old_pwd = fs->pwd;
+       fs->pwd = path;
+       WRITE_FS_SEQ_END(fs);
+       UNLOCK_FS_STRUCT(fs);
+
+       if (old_pwd.dentry)
+               path_put(&old_pwd);
 }
 
 /*