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>
]) # 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.
# 2.6.37
LC_KERNEL_LOCKED
+ LC_FS_STRUCT_SEQCOUNT
# 2.6.38
LC_BLKDEV_GET_BY_DEV
# 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);
}
/*