From: Ned Bass Date: Mon, 4 Nov 2013 23:07:11 +0000 (-0800) Subject: LU-4208 osd-zfs: hold pool config lock to register property X-Git-Tag: 2.5.52~25 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=f8bc2f7fc03d3f86eef434cf644191e689ee57ec LU-4208 osd-zfs: hold pool config lock to register property - Hold the DSL pool configuration lock when calling dsl_prop_register(). Failure to do so will panic the node if assertions are enabled in ZFS. This change requires a build of ZFS on Linux that exports symbols dsl_pool_config_enter and dsl_pool_config_exit, which was done in commit 40a806d [1], and will appear in ZFS release 0.6.3. - Fix up variable declaration alignment in osd_mount(). - Add check for exported symbols in autoconf [1] https://github.com/zfsonlinux/zfs/commit/40a806d Signed-off-by: Ned Bass Signed-off-by: Nathaniel Clark Change-Id: Ib2df05301ca73847d49ca2b183d72b9e2d957c10 Reviewed-on: http://review.whamcloud.com/8172 Tested-by: Jenkins Reviewed-by: Alex Zhuravlev Tested-by: Maloo Reviewed-by: Li Wei Reviewed-by: Oleg Drokin --- diff --git a/config/lustre-build-linux.m4 b/config/lustre-build-linux.m4 index 22833c5..e722001 100644 --- a/config/lustre-build-linux.m4 +++ b/config/lustre-build-linux.m4 @@ -381,7 +381,7 @@ AC_DEFUN([LB_LINUX_COMPILE_IFELSE], [m4_ifvaln([$1], [AC_LANG_CONFTEST([$1])])dnl rm -f build/conftest.o build/conftest.mod.c build/conftest.ko SUBARCH=$(echo $target_cpu | sed -e 's/powerpc64/powerpc/' -e 's/x86_64/x86/' -e 's/i.86/x86/' -e 's/k1om/x86/') -AS_IF([AC_TRY_COMMAND(cp conftest.c build && make -d [$2] ${LD:+"LD=$LD"} CC="$CC" -f $PWD/build/Makefile LUSTRE_LINUX_CONFIG=$LINUX_CONFIG LINUXINCLUDE="$EXTRA_LNET_INCLUDE -I$LINUX/arch/$SUBARCH/include -I$LINUX/arch/$SUBARCH/include/generated -Iinclude -I$LINUX/include -Iinclude2 -I$LINUX/include/uapi -I$LINUX/include/generated -I$LINUX/arch/$SUBARCH/include/uapi -Iarch/$SUBARCH/include/generated/uapi -I$LINUX/include/uapi -Iinclude/generated/uapi -include $CONFIG_INCLUDE" -o tmp_include_depends -o scripts -o include/config/MARKER -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $CROSS_VARS $MODULE_TARGET=$PWD/build) >/dev/null && AC_TRY_COMMAND([$3])], +AS_IF([AC_TRY_COMMAND(cp conftest.c build && make -d [$2] ${LD:+"LD=$LD"} CC="$CC" -f $PWD/build/Makefile LUSTRE_LINUX_CONFIG=$LINUX_CONFIG LINUXINCLUDE="$EXTRA_LNET_INCLUDE -I$LINUX/arch/$SUBARCH/include -I$LINUX/arch/$SUBARCH/include/generated -Iinclude -I$LINUX/include -Iinclude2 -I$LINUX/include/uapi -I$LINUX/include/generated -I$LINUX/arch/$SUBARCH/include/uapi -Iarch/$SUBARCH/include/generated/uapi -I$LINUX/include/uapi -Iinclude/generated/uapi ${SPL_OBJ:+-include $SPL_OBJ/spl_config.h} ${ZFS_OBJ:+-include $ZFS_OBJ/zfs_config.h} ${SPL:+-I$SPL -I$SPL/include } ${ZFS:+-I$ZFS -I$ZFS/include} -include $CONFIG_INCLUDE" -o tmp_include_depends -o scripts -o include/config/MARKER -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $CROSS_VARS $MODULE_TARGET=$PWD/build) >/dev/null && AC_TRY_COMMAND([$3])], [$4], [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])dnl]) diff --git a/config/lustre-build-zfs.m4 b/config/lustre-build-zfs.m4 index f4c46db..df78230 100644 --- a/config/lustre-build-zfs.m4 +++ b/config/lustre-build-zfs.m4 @@ -371,5 +371,20 @@ your distribution. ]) ]) + AS_IF([test x$enable_zfs = xyes], [ + AC_MSG_CHECKING([if zfs defines dsl_pool_config_enter/exit]) + LB_LINUX_TRY_COMPILE([ + #include + ],[ + dsl_pool_config_enter(NULL, FTAG); + ],[ + AC_MSG_RESULT([yes]) + AC_DEFINE(HAVE_DSL_POOL_CONFIG, 1, + [Have dsl_pool_config_enter/exit in ZFS]) + ],[ + AC_MSG_RESULT([no]) + ]) + ]) + AM_CONDITIONAL(ZFS_ENABLED, test x$enable_zfs = xyes) ]) diff --git a/lustre/osd-zfs/osd_handler.c b/lustre/osd-zfs/osd_handler.c index de11dc1..f400f5e 100644 --- a/lustre/osd-zfs/osd_handler.c +++ b/lustre/osd-zfs/osd_handler.c @@ -511,10 +511,11 @@ static void osd_xattr_changed_cb(void *arg, uint64_t newval) static int osd_mount(const struct lu_env *env, struct osd_device *o, struct lustre_cfg *cfg) { - struct dsl_dataset *ds; - char *dev = lustre_cfg_string(cfg, 1); - dmu_buf_t *rootdb; - int rc; + struct dsl_dataset *ds; + char *dev = lustre_cfg_string(cfg, 1); + dmu_buf_t *rootdb; + dsl_pool_t *dp; + int rc; ENTRY; if (o->od_objset.os != NULL) @@ -537,8 +538,12 @@ static int osd_mount(const struct lu_env *env, } ds = dmu_objset_ds(o->od_objset.os); + dp = dmu_objset_pool(o->od_objset.os); LASSERT(ds); + LASSERT(dp); + dsl_pool_config_enter(dp, FTAG); rc = dsl_prop_register(ds, "xattr", osd_xattr_changed_cb, o); + dsl_pool_config_exit(dp, FTAG); if (rc) CERROR("%s: cat not register xattr callback, ignore: %d\n", o->od_svname, rc); diff --git a/lustre/osd-zfs/osd_internal.h b/lustre/osd-zfs/osd_internal.h index 37f351c..d217a56 100644 --- a/lustre/osd-zfs/osd_internal.h +++ b/lustre/osd-zfs/osd_internal.h @@ -506,4 +506,16 @@ static inline uint32_t attrs_zfs2fs(const uint64_t flags) } #endif + +#ifndef HAVE_DSL_POOL_CONFIG +static inline void dsl_pool_config_enter(dsl_pool_t *dp, char *name) +{ +} + +static inline void dsl_pool_config_exit(dsl_pool_t *dp, char *name) +{ +} + +#endif + #endif /* _OSD_INTERNAL_H */