From 46938c53461d136b71a32c4951b1776e2d226648 Mon Sep 17 00:00:00 2001 From: Shaun Tancheff Date: Mon, 22 May 2023 07:36:21 -0500 Subject: [PATCH] LU-16053 build: Update zfs configure checks From Brian Behlendorf : update dmu_*_by_dnode checks Provided as a feature since ZFS 0.7.0, convert to a fatal configure error when unavailable. update zap_*_by_dnode checks Provided as a feature since ZFS 0.7.0, convert to a fatal configure error when unavailable. update multihost protection check Provided as a feature since ZFS 0.7.0, convert to a fatal configure error when unavailable. Drop the compatibility code required to support OpenZFS releases older than 0.7.0. update userobj accounting check Provided as a feature since ZFS 0.7.0, convert to a fatal configure error when unavailable. update dmu_prefetch() check Provided since at least ZFS 0.7.0, convert to a fatal configure error when unavailable. update dmu_object_alloc_dnsize() check Provided since at least ZFS 0.7.0, convert to a fatal configure error when unavailable. update spa_maxblocksize() check Provided since at least ZFS 0.7.0, convert to a fatal configure error when unavailable. update dsl_pool_config_enter/exit check Convert to a fatal configure error, these functions have been provided since at least ZFS 0.7.x. replace sa_spill_block() check The sa_spill_block() function was removed after the ZFS 0.6.x release. Replace the check with one for use zio_buf_alloc/free which have been available since 0.7.x. The dsl_sync_task_do_nowait() function has not been provided by since the 0.6.x releases. Furthermore, the results of this check are unused by Lustre so let's just remove it. Test-Parameters: trivial Signed-off-by: Brian Behlendorf Signed-off-by: Shaun Tancheff Change-Id: I3c1597e56100961178f9001e918ffb9aa3558706 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/48089 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Arshad Hussain Reviewed-by: James Simmons Reviewed-by: Oleg Drokin --- config/lustre-build-zfs.m4 | 84 ++++++++++++++----------- lustre/osd-zfs/osd_handler.c | 15 ++--- lustre/osd-zfs/osd_internal.h | 114 +--------------------------------- lustre/osd-zfs/osd_object.c | 12 ++-- lustre/osd-zfs/osd_oi.c | 4 +- lustre/osd-zfs/osd_quota.c | 14 ++--- lustre/osd-zfs/osd_scrub.c | 2 +- lustre/osd-zfs/osd_xattr.c | 4 +- lustre/utils/libmount_utils_zfs.c | 125 -------------------------------------- 9 files changed, 71 insertions(+), 303 deletions(-) diff --git a/config/lustre-build-zfs.m4 b/config/lustre-build-zfs.m4 index cd95e75..ac5acce 100644 --- a/config/lustre-build-zfs.m4 +++ b/config/lustre-build-zfs.m4 @@ -454,40 +454,35 @@ your distribution. ],[ AC_DEFINE(HAVE_DSL_POOL_CONFIG, 1, [Have dsl_pool_config_enter/exit in ZFS]) - ]) - LB_CHECK_COMPILE([if zfs defines dsl_sync_task_do_nowait], - dsl_sync_task_do_nowait, [ - #include - ],[ - dsl_sync_task_do_nowait(NULL, NULL, NULL, NULL, NULL, 0, NULL); ],[ - AC_DEFINE(HAVE_DSL_SYNC_TASK_DO_NOWAIT, 1, - [Have dsl_sync_task_do_nowait in ZFS]) + AC_MSG_ERROR([dsl_pool_config_enter/exit do not exist]) ]) - LB_CHECK_COMPILE([if zfs defines sa_spill_alloc], - sa_spill_alloc, [ - #include - #include + LB_CHECK_COMPILE([if zfs defines zio_buf_alloc/free], + zio_buf_alloc, [ + #include ],[ - void *ptr; + void *ptr = zio_buf_alloc(1024); - ptr = sa_spill_alloc(KM_SLEEP); - sa_spill_free(ptr); + (void)ptr; + ],[ + AC_DEFINE(HAVE_ZIO_BUF_ALLOC, 1, + [Have zio_buf_alloc/free in ZFS]) ],[ - AC_DEFINE(HAVE_SA_SPILL_ALLOC, 1, - [Have sa_spill_alloc in ZFS]) + AC_MSG_ERROR([zio_buf_alloc/free do not exist]) ]) LB_CHECK_COMPILE([if zfs defines spa_maxblocksize], spa_maxblocksize, [ #include ],[ spa_t *spa = NULL; - int size; + int size = spa_maxblocksize(spa); - size = spa_maxblocksize(spa); + (void)size; ],[ AC_DEFINE(HAVE_SPA_MAXBLOCKSIZE, 1, [Have spa_maxblocksize in ZFS]) + ],[ + AC_MSG_ERROR([spa_maxblocksize does not exist]) ]) dnl # @@ -518,6 +513,8 @@ your distribution. ],[ AC_DEFINE(HAVE_DMU_OBJECT_ALLOC_DNSIZE, 1, [Have dmu_object_alloc_dnsize in ZFS]) + ],[ + AC_MSG_ERROR([dmu_object_alloc_dnsize does not exist]) ]) dnl # @@ -541,6 +538,8 @@ your distribution. ],[ AC_DEFINE(HAVE_DMU_PREFETCH_6ARG, 1, [Have 6 argument dmu_pretch in ZFS]) + ],[ + AC_MSG_ERROR([6 argument dmu_pretch does not exist]) ]) dnl # dnl # ZFS 0.7.0 feature: SPA_FEATURE_USEROBJ_ACCOUNTING @@ -553,28 +552,25 @@ your distribution. ],[ AC_DEFINE(HAVE_DMU_USEROBJ_ACCOUNTING, 1, [Have native dnode accounting in ZFS]) + ],[ + AC_MSG_ERROR([native dnode accounting does not exist]) ]) dnl # dnl # ZFS 0.7.0 feature: MULTIHOST dnl # - restore_CFLAGS=$CFLAGS - CFLAGS="$CFLAGS $ZFS_LIBZFS_INCLUDE -Werror" - AC_MSG_CHECKING([[if ZFS has multihost protection]]) - AC_COMPILE_IFELSE([ - AC_LANG_PROGRAM( - [[ - #define _LARGEFILE64_SOURCE 1 - #include - #include - ]], [[ - spa_multihost(NULL); - ]]) - ],[ - AC_DEFINE(HAVE_ZFS_MULTIHOST, 1, - [Have multihost protection in ZFS]) - spa_multihost_fn="yes"],[spa_multihost_fn="no"]), - AC_MSG_RESULT([$spa_multihost_fn]) - CFLAGS=$restore_CFLAGS + LB_CHECK_COMPILE([if ZFS has multihost protection], + spa_multihost, [ + #include + ],[ + zpool_prop_t prop = ZPOOL_PROP_MULTIHOST; + + (void)prop; + ],[ + AC_DEFINE(HAVE_ZFS_MULTIHOST, 1, + [Have multihost protection in ZFS]) + ],[ + AC_MSG_ERROR([multihost protection does not exist]) + ]) dnl # dnl # ZFS 0.7.x adds new method zap_lookup_by_dnode dnl # @@ -588,6 +584,8 @@ your distribution. ],[ AC_DEFINE(HAVE_ZAP_LOOKUP_BY_DNODE, 1, [Have zap_lookup_by_dnode() in ZFS]) + ],[ + AC_MSG_ERROR([zap_lookup_by_dnode does not exist]) ]) dnl # dnl # ZFS 0.7.x adds new method zap_add_by_dnode @@ -602,6 +600,8 @@ your distribution. ],[ AC_DEFINE(HAVE_ZAP_ADD_BY_DNODE, 1, [Have zap_add_by_dnode() in ZFS]) + ],[ + AC_MSG_ERROR([zap_add_by_dnode does not exist]) ]) dnl # dnl # ZFS 0.7.x adds new method zap_remove_by_dnode @@ -616,6 +616,8 @@ your distribution. ],[ AC_DEFINE(HAVE_ZAP_REMOVE_ADD_BY_DNODE, 1, [Have zap_remove_by_dnode() in ZFS]) + ],[ + AC_MSG_ERROR([zap_remove_by_dnode does not exist]) ]) dnl # dnl # ZFS 0.7.x adds new method dmu_tx_hold_zap_by_dnode @@ -630,6 +632,8 @@ your distribution. ],[ AC_DEFINE(HAVE_DMU_TX_HOLD_ZAP_BY_DNODE, 1, [Have dmu_tx_hold_zap_by_dnode() in ZFS]) + ],[ + AC_MSG_ERROR([dmu_tx_hold_zap_by_dnode does not exist]) ]) dnl # dnl # ZFS 0.7.x adds new method dmu_tx_hold_write_by_dnode @@ -644,6 +648,8 @@ your distribution. ],[ AC_DEFINE(HAVE_DMU_TX_HOLD_WRITE_BY_DNODE, 1, [Have dmu_tx_hold_write_by_dnode() in ZFS]) + ],[ + AC_MSG_ERROR([dmu_tx_hold_write_by_dnode does not exist]) ]) dnl # dnl # ZFS 0.7.x adds new method dmu_write_by_dnode @@ -658,6 +664,8 @@ your distribution. ],[ AC_DEFINE(HAVE_DMU_WRITE_BY_DNODE, 1, [Have dmu_write_by_dnode() in ZFS]) + ],[ + AC_MSG_ERROR([dmu_write_by_dnode does not exist]) ]) dnl # dnl # ZFS 0.7.x adds new method dmu_read_by_dnode @@ -672,6 +680,8 @@ your distribution. ],[ AC_DEFINE(HAVE_DMU_READ_BY_DNODE, 1, [Have dmu_read_by_dnode() in ZFS]) + ],[ + AC_MSG_ERROR([dmu_read_by_dnode does not exist]) ]) dnl # dnl # ZFS 0.7.2 adds new method dmu_tx_mark_netfree diff --git a/lustre/osd-zfs/osd_handler.c b/lustre/osd-zfs/osd_handler.c index fb148f1..c29bae6 100644 --- a/lustre/osd-zfs/osd_handler.c +++ b/lustre/osd-zfs/osd_handler.c @@ -576,7 +576,7 @@ static int osd_blk_insert_cost(struct osd_device *osd) /* max_blockshift is the log2 of the number of blocks needed to reach * the maximum filesize (that's to say 2^64) */ - bshift = osd_spa_maxblockshift(dmu_objset_spa(osd->od_os)); + bshift = fls64(spa_maxblocksize(dmu_objset_spa(osd->od_os)) - 1); max_blockshift = DN_MAX_OFFSET_SHIFT - bshift; /* nr_blkptrshift is the log2 of the number of block pointers that can @@ -833,7 +833,7 @@ static void osd_recordsize_changed_cb(void *arg, uint64_t newval) { struct osd_device *osd = arg; - LASSERT(newval <= osd_spa_maxblocksize(dmu_objset_spa(osd->od_os))); + LASSERT(newval <= spa_maxblocksize(dmu_objset_spa(osd->od_os))); LASSERT(newval >= SPA_MINBLOCKSIZE); LASSERT(ISP2(newval)); @@ -847,14 +847,13 @@ static void osd_readonly_changed_cb(void *arg, uint64_t newval) osd->od_prop_rdonly = !!newval; } -#ifdef HAVE_DMU_OBJECT_ALLOC_DNSIZE static void osd_dnodesize_changed_cb(void *arg, uint64_t newval) { struct osd_device *osd = arg; osd->od_dnsize = newval; } -#endif + /* * This function unregisters all registered callbacks. It's harmless to * unregister callbacks that were never registered so it is used to safely @@ -870,10 +869,8 @@ static void osd_objset_unregister_callbacks(struct osd_device *o) osd_recordsize_changed_cb, o); (void) dsl_prop_unregister(ds, zfs_prop_to_name(ZFS_PROP_READONLY), osd_readonly_changed_cb, o); -#ifdef HAVE_DMU_OBJECT_ALLOC_DNSIZE (void) dsl_prop_unregister(ds, zfs_prop_to_name(ZFS_PROP_DNODESIZE), osd_dnodesize_changed_cb, o); -#endif if (o->arc_prune_cb != NULL) { arc_remove_prune_callback(o->arc_prune_cb); @@ -910,12 +907,10 @@ static int osd_objset_register_callbacks(struct osd_device *o) if (rc) GOTO(err, rc); -#ifdef HAVE_DMU_OBJECT_ALLOC_DNSIZE rc = -dsl_prop_register(ds, zfs_prop_to_name(ZFS_PROP_DNODESIZE), osd_dnodesize_changed_cb, o); if (rc) GOTO(err, rc); -#endif o->arc_prune_cb = arc_add_prune_callback(arc_prune_func, o); err: @@ -1146,7 +1141,7 @@ static int osd_mount(const struct lu_env *env, RETURN(rc); o->od_xattr_in_sa = B_TRUE; - o->od_max_blksz = osd_spa_maxblocksize(o->od_os->os_spa); + o->od_max_blksz = spa_maxblocksize(o->od_os->os_spa); o->od_readcache_max_filesize = OSD_MAX_CACHE_SIZE; rc = __osd_obj2dnode(o->od_os, o->od_rootid, &rootdn); @@ -1230,12 +1225,10 @@ static int osd_mount(const struct lu_env *env, GOTO(err, rc); } -#ifdef HAVE_DMU_USEROBJ_ACCOUNTING if (!osd_dmu_userobj_accounting_available(o)) CWARN("%s: dnode accounting not enabled: " "enable feature@userobj_accounting in pool\n", o->od_mntdev); -#endif /* parse mount option "noacl", and enable ACL by default */ if (opts == NULL || strstr(opts, "noacl") == NULL) diff --git a/lustre/osd-zfs/osd_internal.h b/lustre/osd-zfs/osd_internal.h index 23a63e4..c820726 100644 --- a/lustre/osd-zfs/osd_internal.h +++ b/lustre/osd-zfs/osd_internal.h @@ -781,15 +781,7 @@ int __osd_sa_xattr_update(const struct lu_env *env, struct osd_object *obj, sizeof(__u64) /* VBR VERSION */ + \ sizeof(struct lustre_mdt_attrs) /* LMA */) -#ifdef HAVE_DMU_OBJECT_ALLOC_DNSIZE int osd_find_dnsize(struct osd_device *osd, int ea_in_bonus); -#else -static inline int -osd_find_dnsize(struct osd_device *osd, int ea_in_bonus) -{ - return DN_MAX_BONUSLEN; -} -#endif static inline int osd_object_is_zap(dnode_t *dn) { @@ -847,43 +839,6 @@ 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, void *name) -{ -} - -static inline void dsl_pool_config_exit(dsl_pool_t *dp, void *name) -{ -} -#endif - -#ifdef HAVE_SPA_MAXBLOCKSIZE -#define osd_spa_maxblocksize(spa) spa_maxblocksize(spa) -#define osd_spa_maxblockshift(spa) fls64(spa_maxblocksize(spa) - 1) -#else -#define osd_spa_maxblocksize(spa) SPA_MAXBLOCKSIZE -#define osd_spa_maxblockshift(spa) SPA_MAXBLOCKSHIFT -#define SPA_OLD_MAXBLOCKSIZE SPA_MAXBLOCKSIZE -#endif - -#ifdef HAVE_SA_SPILL_ALLOC -static inline void * -osd_zio_buf_alloc(size_t size) -{ - return sa_spill_alloc(KM_SLEEP); -} - -static inline void -osd_zio_buf_free(void *buf, size_t size) -{ - sa_spill_free(buf); -} -#else -#define osd_zio_buf_alloc(size) zio_buf_alloc(size) -#define osd_zio_buf_free(buf, size) zio_buf_free(buf, size) -#endif - -#ifdef HAVE_DMU_OBJECT_ALLOC_DNSIZE static inline uint64_t osd_dmu_object_alloc(objset_t *os, dmu_object_type_t objtype, int blocksize, int dnodesize, dmu_tx_t *tx) @@ -931,39 +886,6 @@ osd_obj_bonuslen(struct osd_object *obj) return bonuslen; } -#else -static inline uint64_t -osd_dmu_object_alloc(objset_t *os, dmu_object_type_t objtype, int blocksize, - int dnodesize, dmu_tx_t *tx) -{ - return dmu_object_alloc(os, objtype, blocksize, DMU_OT_SA, - DN_MAX_BONUSLEN, tx); -} - -static inline uint64_t -osd_zap_create_flags(objset_t *os, int normflags, zap_flags_t flags, - dmu_object_type_t ot, int leaf_blockshift, - int indirect_blockshift, int dnodesize, dmu_tx_t *tx) -{ - return zap_create_flags(os, normflags, flags, ot, leaf_blockshift, - indirect_blockshift, DMU_OT_SA, - DN_MAX_BONUSLEN, tx); -} - -static inline int -osd_obj_bonuslen(struct osd_object *obj) -{ - return DN_MAX_BONUSLEN; -} -#endif /* HAVE_DMU_OBJECT_ALLOC_DNSIZE */ - -#ifdef HAVE_DMU_PREFETCH_6ARG -#define osd_dmu_prefetch(os, obj, lvl, off, len, pri) \ - dmu_prefetch((os), (obj), (lvl), (off), (len), (pri)) -#else -#define osd_dmu_prefetch(os, obj, lvl, off, len, pri) \ - dmu_prefetch((os), (obj), (lvl), (off)) -#endif static inline int osd_sa_handle_get(struct osd_object *obj) { @@ -1011,25 +933,10 @@ static inline uint64_t osd_db_dirty_txg(dmu_buf_impl_t *db) return txg; } -#ifdef HAVE_DMU_USEROBJ_ACCOUNTING - -#define OSD_DMU_USEROBJ_PREFIX DMU_OBJACCT_PREFIX -#define OSD_DMU_USEROBJ_PREFIX_LEN DMU_OBJACCT_PREFIX_LEN - static inline bool osd_dmu_userobj_accounting_available(struct osd_device *osd) { return dmu_objset_userobjspace_present(osd->od_os); } -#else - -#define OSD_DMU_USEROBJ_PREFIX "obj-" -#define OSD_DMU_USEROBJ_PREFIX_LEN 4 - -static inline bool osd_dmu_userobj_accounting_available(struct osd_device *osd) -{ - return false; -} -#endif /* #ifdef HAVE_DMU_USEROBJ_ACCOUNTING */ static inline int osd_zap_add(struct osd_device *osd, uint64_t zap, dnode_t *dn, const char *key, @@ -1038,10 +945,9 @@ static inline int osd_zap_add(struct osd_device *osd, uint64_t zap, { LASSERT(zap != 0); -#ifdef HAVE_ZAP_ADD_BY_DNODE if (dn) return -zap_add_by_dnode(dn, key, int_size, int_num, val, tx); -#endif + return -zap_add(osd->od_os, zap, key, int_size, int_num, val, tx); } @@ -1051,10 +957,9 @@ static inline int osd_zap_remove(struct osd_device *osd, uint64_t zap, { LASSERT(zap != 0); -#ifdef HAVE_ZAP_ADD_BY_DNODE if (dn) return -zap_remove_by_dnode(dn, key, tx); -#endif + return -zap_remove(osd->od_os, zap, key, tx); } @@ -1065,34 +970,29 @@ static inline int osd_zap_lookup(struct osd_device *osd, uint64_t zap, { LASSERT(zap != 0); -#ifdef HAVE_ZAP_ADD_BY_DNODE if (dn) return -zap_lookup_by_dnode(dn, key, int_size, int_num, v); -#endif + return -zap_lookup(osd->od_os, zap, key, int_size, int_num, v); } static inline void osd_tx_hold_zap(dmu_tx_t *tx, uint64_t zap, dnode_t *dn, int add, const char *name) { -#ifdef HAVE_DMU_TX_HOLD_ZAP_BY_DNODE if (dn) { dmu_tx_hold_zap_by_dnode(tx, dn, add, name); return; } -#endif dmu_tx_hold_zap(tx, zap, add, name); } static inline void osd_tx_hold_write(dmu_tx_t *tx, uint64_t oid, dnode_t *dn, uint64_t off, int len) { -#ifdef HAVE_DMU_TX_HOLD_ZAP_BY_DNODE if (dn) { dmu_tx_hold_write_by_dnode(tx, dn, off, len); return; } -#endif dmu_tx_hold_write(tx, oid, off, len); } @@ -1101,11 +1001,7 @@ static inline void osd_dmu_write(struct osd_device *osd, dnode_t *dn, const char *buf, dmu_tx_t *tx) { LASSERT(dn); -#ifdef HAVE_DMU_WRITE_BY_DNODE dmu_write_by_dnode(dn, offset, size, buf, tx); -#else - dmu_write(osd->od_os, dn->dn_object, offset, size, buf, tx); -#endif } static inline int osd_dmu_read(struct osd_device *osd, dnode_t *dn, @@ -1113,11 +1009,7 @@ static inline int osd_dmu_read(struct osd_device *osd, dnode_t *dn, char *buf, int flags) { LASSERT(dn); -#ifdef HAVE_DMU_READ_BY_DNODE return -dmu_read_by_dnode(dn, offset, size, buf, flags); -#else - return -dmu_read(osd->od_os, dn->dn_object, offset, size, buf, flags); -#endif } #ifdef HAVE_DMU_OBJSET_OWN_6ARG diff --git a/lustre/osd-zfs/osd_object.c b/lustre/osd-zfs/osd_object.c index 75aa683..f0bd9e8 100644 --- a/lustre/osd-zfs/osd_object.c +++ b/lustre/osd-zfs/osd_object.c @@ -1046,7 +1046,7 @@ static int osd_attr_get(const struct lu_env *env, struct dt_object *dt, } /* Block size may be not set; suggest maximal I/O transfers. */ if (blksize == 0) - blksize = osd_spa_maxblocksize( + blksize = spa_maxblocksize( dmu_objset_spa(osd_obj2dev(obj)->od_os)); attr->la_blksize = blksize; @@ -1125,7 +1125,7 @@ static int osd_add_projid(const struct lu_env *env, struct osd_object *obj, if (rc) GOTO(out, rc); - dxattr = osd_zio_buf_alloc(sa_size); + dxattr = zio_buf_alloc(sa_size); if (dxattr == NULL) GOTO(out, rc = -ENOMEM); @@ -1141,7 +1141,7 @@ static int osd_add_projid(const struct lu_env *env, struct osd_object *obj, rc = -sa_replace_all_by_template(obj->oo_sa_hdl, bulk, cnt, oh->ot_tx); out: if (dxattr) - osd_zio_buf_free(dxattr, sa_size); + zio_buf_free(dxattr, sa_size); return rc; } #endif @@ -1659,7 +1659,7 @@ int __osd_attr_init(const struct lu_env *env, struct osd_device *osd, rc = -nvlist_size(xattr, &sa_size, NV_ENCODE_XDR); LASSERT(rc == 0); - dxattr = osd_zio_buf_alloc(sa_size); + dxattr = zio_buf_alloc(sa_size); LASSERT(dxattr); rc = -nvlist_pack(xattr, &dxattr, &sa_size, @@ -1672,7 +1672,7 @@ int __osd_attr_init(const struct lu_env *env, struct osd_device *osd, rc = -sa_replace_all_by_template(sa_hdl, bulk, cnt, tx); if (dxattr) - osd_zio_buf_free(dxattr, sa_size); + zio_buf_free(dxattr, sa_size); return rc; } @@ -1720,7 +1720,6 @@ int osd_find_new_dnode(const struct lu_env *env, dmu_tx_t *tx, return rc; } -#ifdef HAVE_DMU_OBJECT_ALLOC_DNSIZE int osd_find_dnsize(struct osd_device *osd, int ea_in_bonus) { int dnsize; @@ -1749,7 +1748,6 @@ int osd_find_dnsize(struct osd_device *osd, int ea_in_bonus) } return dnsize; } -#endif /* * The transaction passed to this routine must have diff --git a/lustre/osd-zfs/osd_oi.c b/lustre/osd-zfs/osd_oi.c index 25054a5..24f8b64 100644 --- a/lustre/osd-zfs/osd_oi.c +++ b/lustre/osd-zfs/osd_oi.c @@ -700,8 +700,8 @@ int osd_fid_lookup(const struct lu_env *env, struct osd_device *dev, } if (rc == 0) - osd_dmu_prefetch(dev->od_os, *oid, 0, 0, 0, - ZIO_PRIORITY_ASYNC_READ); + dmu_prefetch(dev->od_os, *oid, 0, 0, 0, + ZIO_PRIORITY_ASYNC_READ); RETURN(rc); } diff --git a/lustre/osd-zfs/osd_quota.c b/lustre/osd-zfs/osd_quota.c index 708a4b6..c2047c5 100644 --- a/lustre/osd-zfs/osd_quota.c +++ b/lustre/osd-zfs/osd_quota.c @@ -122,7 +122,7 @@ static int osd_acct_index_lookup(const struct lu_env *env, rec->ispace = osd_objset_user_iused(osd, rec->bspace); rc = 1; } else { - snprintf(buf, buflen, OSD_DMU_USEROBJ_PREFIX "%llx", + snprintf(buf, buflen, DMU_OBJACCT_PREFIX "%llx", *((__u64 *)dtkey)); rc = osd_zap_lookup(osd, dn->dn_object, dn, buf, sizeof(uint64_t), 1, &rec->ispace); @@ -220,8 +220,8 @@ static int osd_zap_locate(struct osd_it_quota *it, zap_attribute_t *za) if (rc) break; - if (strncmp(za->za_name, OSD_DMU_USEROBJ_PREFIX, - OSD_DMU_USEROBJ_PREFIX_LEN)) + if (strncmp(za->za_name, DMU_OBJACCT_PREFIX, + DMU_OBJACCT_PREFIX_LEN)) break; zap_cursor_advance(it->oiq_zc); @@ -374,10 +374,10 @@ static int osd_it_acct_rec(const struct lu_env *env, RETURN(rc); /* inode accounting is maintained by DMU since 0.7.0 */ - strncpy(info->oti_buf, OSD_DMU_USEROBJ_PREFIX, - OSD_DMU_USEROBJ_PREFIX_LEN); - strlcpy(info->oti_buf + OSD_DMU_USEROBJ_PREFIX_LEN, za->za_name, - sizeof(info->oti_buf) - OSD_DMU_USEROBJ_PREFIX_LEN); + strncpy(info->oti_buf, DMU_OBJACCT_PREFIX, + DMU_OBJACCT_PREFIX_LEN); + strlcpy(info->oti_buf + DMU_OBJACCT_PREFIX_LEN, za->za_name, + sizeof(info->oti_buf) - DMU_OBJACCT_PREFIX_LEN); rc = osd_zap_lookup(osd, it->oiq_obj->oo_dn->dn_object, it->oiq_obj->oo_dn, info->oti_buf, sizeof(uint64_t), 1, &rec->ispace); diff --git a/lustre/osd-zfs/osd_scrub.c b/lustre/osd-zfs/osd_scrub.c index fbec6d3..943eba7 100644 --- a/lustre/osd-zfs/osd_scrub.c +++ b/lustre/osd-zfs/osd_scrub.c @@ -1570,7 +1570,7 @@ static void osd_otable_it_preload(const struct lu_env *env, if (rc) break; - osd_dmu_prefetch(dev->od_os, it->ooi_prefetched_dnode, + dmu_prefetch(dev->od_os, it->ooi_prefetched_dnode, 0, 0, 0, ZIO_PRIORITY_ASYNC_READ); it->ooi_prefetched++; } diff --git a/lustre/osd-zfs/osd_xattr.c b/lustre/osd-zfs/osd_xattr.c index f37f7a9..8de3022 100644 --- a/lustre/osd-zfs/osd_xattr.c +++ b/lustre/osd-zfs/osd_xattr.c @@ -76,7 +76,7 @@ int __osd_xattr_load(struct osd_device *osd, sa_handle_t *hdl, nvlist_t **sa) goto out_sa; } - buf = osd_zio_buf_alloc(size); + buf = zio_buf_alloc(size); if (buf == NULL) { rc = -ENOMEM; goto out_sa; @@ -84,7 +84,7 @@ int __osd_xattr_load(struct osd_device *osd, sa_handle_t *hdl, nvlist_t **sa) rc = -sa_lookup(hdl, SA_ZPL_DXATTR(osd), buf, size); if (rc == 0) rc = -nvlist_unpack(buf, size, sa, KM_SLEEP); - osd_zio_buf_free(buf, size); + zio_buf_free(buf, size); out_sa: return rc; diff --git a/lustre/utils/libmount_utils_zfs.c b/lustre/utils/libmount_utils_zfs.c index 71966fc..2fdc0b6 100644 --- a/lustre/utils/libmount_utils_zfs.c +++ b/lustre/utils/libmount_utils_zfs.c @@ -26,11 +26,6 @@ /* * Author: Brian Behlendorf */ -#ifndef HAVE_ZFS_MULTIHOST -#include -#define list_move_tail(a, b) spl_list_move_tail(a, b) -#include -#endif #include "mount_utils.h" #include #include @@ -229,114 +224,6 @@ static int zfs_erase_allprops(zfs_handle_t *zhp) free(strs); return rc; } -/* - * ZFS on linux 0.7.0-rc5 commit 379ca9cf2beba802f096273e89e30914a2d6bafc - * Multi-modifier protection (MMP) - * - * Introduced spa_get_hostid() along with a few constants like - * ZPOOL_CONFIG_MMP_HOSTID that can be checked to imply availablity of - * spa_get_hostid. Supply a fallback when spa_get_hostid is not - * available. - * - * This can be removed when zfs 0.6.x support is dropped. - */ -#if !defined(ZPOOL_CONFIG_MMP_HOSTID) && !defined(HAVE_ZFS_MULTIHOST) -unsigned long _hostid_from_proc(void) -{ - FILE *f; - unsigned long hostid; - int rc; - - f = fopen("/proc/sys/kernel/spl/hostid", "r"); - if (f == NULL) - goto out; - - rc = fscanf(f, "%lx", &hostid); - fclose(f); - if (rc == 1) - return hostid; -out: - return 0; -} - -unsigned long _hostid_from_module_param(void) -{ - FILE *f; - unsigned long hostid; - int rc; - - f = fopen("/sys/module/spl/parameters/spl_hostid", "r"); - if (f == NULL) - goto out; - - rc = fscanf(f, "%li", &hostid); - fclose(f); - if (rc == 1) - return hostid; -out: - return 0; -} - -unsigned long _from_module_param_indirect(void) -{ - FILE *f; - unsigned long hostid = 0; - uint32_t hwid; - int rc; - char *spl_hostid_path = NULL; - - /* read the module parameter for HW_HOSTID_PATH */ - f = fopen("/sys/module/spl/parameters/spl_hostid_path", "r"); - if (f == NULL) { - fatal(); - fprintf(stderr, "Failed to open spl_hostid_path param: %s\n", - strerror(errno)); - goto out; - } - - rc = fscanf(f, "%ms%*[\n]", &spl_hostid_path); - fclose(f); - if (rc == 0 || !spl_hostid_path) - goto out; - - /* read the hostid from the file */ - f = fopen(spl_hostid_path, "r"); - if (f == NULL) { - fatal(); - fprintf(stderr, "Failed to open %s param: %s\n", - spl_hostid_path, strerror(errno)); - goto out; - } - - /* hostid is the first 4 bytes in native endian order */ - rc = fread(&hwid, sizeof(uint32_t), 1, f); - fclose(f); - if (rc == 1) - hostid = (unsigned long)hwid; - -out: - if (spl_hostid_path) - free(spl_hostid_path); - - return hostid; -} - -unsigned long spa_get_hostid(void) -{ - unsigned long hostid; - - hostid = _hostid_from_proc(); - if (hostid) - return hostid; - - /* if /proc isn't available, try /sys */ - hostid = _hostid_from_module_param(); - if (hostid) - return hostid; - - return _from_module_param_indirect(); -} -#endif /* * Map '= ...' pairs in the passed string to dataset properties @@ -391,11 +278,7 @@ static int zfs_check_hostid(struct mkfs_opts *mop) if (strstr(mop->mo_ldd.ldd_params, PARAM_FAILNODE) == NULL) return 0; -#ifdef HAVE_ZFS_MULTIHOST hostid = get_system_hostid(); -#else - hostid = spa_get_hostid(); -#endif if (hostid == 0) { if (mop->mo_flags & MO_NOHOSTID_CHECK) { fprintf(stderr, "WARNING: spl_hostid not set. ZFS has " @@ -587,7 +470,6 @@ int zfs_read_ldd(char *ds, struct lustre_disk_data *ldd) ldd->ldd_mount_type = LDD_MT_ZFS; ret = 0; -#ifdef HAVE_ZFS_MULTIHOST if (strstr(ldd->ldd_params, PARAM_FAILNODE) != NULL) { zpool_handle_t *pool = zfs_get_pool_handle(zhp); uint64_t mh = zpool_get_prop_int(pool, ZPOOL_PROP_MULTIHOST, @@ -597,7 +479,6 @@ int zfs_read_ldd(char *ds, struct lustre_disk_data *ldd) "but zpool does not have multihost enabled\n", progname, ds); } -#endif out_close: zfs_close(zhp); @@ -832,18 +713,12 @@ int zfs_make_lustre(struct mkfs_opts *mop) * 0.7.0 - multihost=on * 0.7.0 - feature@userobj_accounting=enabled */ -#if defined(HAVE_ZFS_MULTIHOST) || defined(HAVE_DMU_USEROBJ_ACCOUNTING) php = zpool_open(g_zfs, pool); if (php) { -#ifdef HAVE_ZFS_MULTIHOST zpool_set_prop(php, "multihost", "on"); -#endif -#ifdef HAVE_DMU_USEROBJ_ACCOUNTING zpool_set_prop(php, "feature@userobj_accounting", "enabled"); -#endif zpool_close(php); } -#endif /* * Create the ZFS filesystem with any required mkfs options: -- 1.8.3.1