From cc4780ad2c69b0bbc6c49cb473fd9f7945c01e5c Mon Sep 17 00:00:00 2001 From: Chris Horn Date: Tue, 22 May 2018 09:39:14 -0500 Subject: [PATCH] LU-11044 osd-ldiskfs: ext4_dir_operations uses iterate_shared Linux 4.7 commit ae05327a00fd47c34dfe25294b359a3f3fef96e8 replaces ext4_dir_operations iterate with iterate_shared. dir_relaxed_shared() was also added in that commit, so we can use that function to verify that the ext4_dir_operations is using iterate_shared. Cray-bug-id: LUS-6008 Signed-off-by: Chris Horn Change-Id: I67ff714296cab96408cb74fba62855c0e12cdf43 Reviewed-on: https://review.whamcloud.com/32486 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: James Simmons Reviewed-by: Yang Sheng Reviewed-by: Li Dongyang Reviewed-by: Oleg Drokin --- lustre/autoconf/lustre-core.m4 | 24 ++++++++++++++++++++++++ lustre/osd-ldiskfs/osd_handler.c | 8 ++++++++ lustre/osd-ldiskfs/osd_scrub.c | 4 ++++ 3 files changed, 36 insertions(+) diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4 index 399ce0a..2dd5327 100644 --- a/lustre/autoconf/lustre-core.m4 +++ b/lustre/autoconf/lustre-core.m4 @@ -2537,6 +2537,29 @@ generic_write_sync_2args, [ ]) # LC_GENERIC_WRITE_SYNC_2ARGS # +# LC_FOPS_ITERATE_SHARED +# +# 4.7 commit ae05327a00fd47c34dfe25294b359a3f3fef96e8 +# ext4: switch to ->iterate_shared() +# this replaces ext4_dir_operations iterate with iterate_shared. +# dir_relaxed_shared() was also added in this commit, so we can +# use that function to verify that the ext4_dir_operations is using +# iterate_shared. +# +AC_DEFUN([LC_FOPS_ITERATE_SHARED], [ +LB_CHECK_COMPILE([if ext4_dir_operations uses iterate_shared], +iterate_shared, [ + #include +],[ + ((struct file_operations *)0)->iterate_shared(NULL, NULL); + dir_relax_shared(NULL); +],[ + AC_DEFINE(HAVE_ITERATE_SHARED, 1, + ['iterate_shared' is available]) +]) +]) # LC_FOPS_ITERATE_SHARED + +# # LC_HAVE_POSIX_ACL_VALID_USER_NS # # 4.8 posix_acl_valid takes struct user_namespace @@ -3078,6 +3101,7 @@ AC_DEFUN([LC_PROG_LINUX], [ # 4.7 LC_DIRECTIO_2ARGS LC_GENERIC_WRITE_SYNC_2ARGS + LC_FOPS_ITERATE_SHARED # 4.8 LC_HAVE_POSIX_ACL_VALID_USER_NS diff --git a/lustre/osd-ldiskfs/osd_handler.c b/lustre/osd-ldiskfs/osd_handler.c index 8aaf426..f964d92 100644 --- a/lustre/osd-ldiskfs/osd_handler.c +++ b/lustre/osd-ldiskfs/osd_handler.c @@ -994,7 +994,11 @@ again: oclb.oclb_items = 0; #ifdef HAVE_DIR_CONTEXT oclb.ctx.pos = filp->f_pos; +#ifdef HAVE_ITERATE_SHARED + rc = fops->iterate_shared(filp, &oclb.ctx); +#else rc = fops->iterate(filp, &oclb.ctx); +#endif filp->f_pos = oclb.ctx.pos; #else rc = fops->readdir(filp, &oclb, osd_stripe_dir_filldir); @@ -6365,7 +6369,11 @@ static int osd_ldiskfs_it_fill(const struct lu_env *env, #ifdef HAVE_DIR_CONTEXT buf.ctx.pos = filp->f_pos; +#ifdef HAVE_ITERATE_SHARED + rc = inode->i_fop->iterate_shared(filp, &buf.ctx); +#else rc = inode->i_fop->iterate(filp, &buf.ctx); +#endif filp->f_pos = buf.ctx.pos; #else rc = inode->i_fop->readdir(filp, &buf, osd_ldiskfs_filldir); diff --git a/lustre/osd-ldiskfs/osd_scrub.c b/lustre/osd-ldiskfs/osd_scrub.c index 0e83f0c..22a7277 100644 --- a/lustre/osd-ldiskfs/osd_scrub.c +++ b/lustre/osd-ldiskfs/osd_scrub.c @@ -2284,7 +2284,11 @@ osd_ios_general_scan(struct osd_thread_info *info, struct osd_device *dev, buf.oifb_items = 0; #ifdef HAVE_DIR_CONTEXT buf.ctx.pos = filp->f_pos; +#ifdef HAVE_ITERATE_SHARED + rc = fops->iterate_shared(filp, &buf.ctx); +#else rc = fops->iterate(filp, &buf.ctx); +#endif filp->f_pos = buf.ctx.pos; #else rc = fops->readdir(filp, &buf, filldir); -- 1.8.3.1