From: Bobi Jam Date: Fri, 8 Sep 2017 13:56:03 +0000 (+0800) Subject: LU-9735 compat: heed the fs_struct::seq X-Git-Tag: 2.10.58~43 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=refs%2Fchanges%2F07%2F28907%2F7;p=fs%2Flustre-release.git LU-9735 compat: heed the fs_struct::seq 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 Change-Id: I35384b8f5c468a8c142a59032f3148b698a0c79e Reviewed-on: https://review.whamcloud.com/28907 Reviewed-by: Jinshan Xiong Reviewed-by: Fan Yong Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Oleg Drokin --- diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4 index c2f5038..b8f4e45 100644 --- a/lustre/autoconf/lustre-core.m4 +++ b/lustre/autoconf/lustre-core.m4 @@ -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 +],[ + ((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 diff --git a/lustre/include/lustre_compat.h b/lustre/include/lustre_compat.h index 6a5b6cc..2e41ef4 100644 --- a/lustre/include/lustre_compat.h +++ b/lustre/include/lustre_compat.h @@ -53,22 +53,31 @@ # 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); } /*