From: Brian Behlendorf Date: Wed, 17 Dec 2014 00:14:17 +0000 (-0800) Subject: LU-6038 osd-zfs: sa_spill_alloc()/sa_spill_free() compat X-Git-Tag: 2.7.51~79 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=c994fc0df788928c18485be34b28f40c34538ee8 LU-6038 osd-zfs: sa_spill_alloc()/sa_spill_free() compat The sa_spill_alloc()/sa_spill_free() interfaces have been retired. Callers may either use the more memory efficient zio_buf_alloc()/ zio_buf_free() which are now exported, or they may use their own allocator. For the purposes of this patch an osd_zio_buf_alloc()/ osd_zio_buf_free() wrapper function was introduced which layers on whichever interface is provided. Signed-off-by: Brian Behlendorf Change-Id: Id1d19d7b4c440808b8b3fd042f687b10c1b869f2 Reviewed-on: http://review.whamcloud.com/13097 Reviewed-by: Alex Zhuravlev Reviewed-by: Nathaniel Clark Reviewed-by: Isaac Huang Reviewed-by: Andreas Dilger Tested-by: Jenkins Tested-by: Maloo --- diff --git a/config/lustre-build-zfs.m4 b/config/lustre-build-zfs.m4 index b6d56dd..455977d 100644 --- a/config/lustre-build-zfs.m4 +++ b/config/lustre-build-zfs.m4 @@ -401,6 +401,19 @@ your distribution. AC_DEFINE(HAVE_DSL_SYNC_TASK_DO_NOWAIT, 1, [Have dsl_sync_task_do_nowait in ZFS]) ]) + LB_CHECK_COMPILE([if zfs defines sa_spill_alloc], + sa_spill_alloc, [ + #include + #include + ],[ + void *ptr; + + ptr = sa_spill_alloc(KM_SLEEP); + sa_spill_free(ptr); + ],[ + AC_DEFINE(HAVE_SA_SPILL_ALLOC, 1, + [Have sa_spill_alloc in ZFS]) + ]) ]) AM_CONDITIONAL(ZFS_ENABLED, [test "x$enable_zfs" = xyes]) diff --git a/lustre/osd-zfs/osd_internal.h b/lustre/osd-zfs/osd_internal.h index 988ccb5..6124fa8 100644 --- a/lustre/osd-zfs/osd_internal.h +++ b/lustre/osd-zfs/osd_internal.h @@ -555,4 +555,21 @@ static inline void dsl_pool_config_exit(dsl_pool_t *dp, char *name) #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 + #endif /* _OSD_INTERNAL_H */ diff --git a/lustre/osd-zfs/osd_xattr.c b/lustre/osd-zfs/osd_xattr.c index 1697728..4a32f1a 100644 --- a/lustre/osd-zfs/osd_xattr.c +++ b/lustre/osd-zfs/osd_xattr.c @@ -89,7 +89,7 @@ int __osd_xattr_load(struct osd_device *osd, uint64_t dnode, nvlist_t **sa) goto out_sa; } - buf = sa_spill_alloc(KM_SLEEP); + buf = osd_zio_buf_alloc(size); if (buf == NULL) { rc = -ENOMEM; goto out_sa; @@ -97,7 +97,7 @@ int __osd_xattr_load(struct osd_device *osd, uint64_t dnode, nvlist_t **sa) rc = -sa_lookup(sa_hdl, SA_ZPL_DXATTR(osd), buf, size); if (rc == 0) rc = -nvlist_unpack(buf, size, sa, KM_SLEEP); - sa_spill_free(buf); + osd_zio_buf_free(buf, size); out_sa: sa_handle_destroy(sa_hdl); @@ -375,7 +375,7 @@ __osd_sa_xattr_update(const struct lu_env *env, struct osd_object *obj, if (rc) return rc; - dxattr = sa_spill_alloc(KM_SLEEP); + dxattr = osd_zio_buf_alloc(sa_size); if (dxattr == NULL) RETURN(-ENOMEM); @@ -386,7 +386,7 @@ __osd_sa_xattr_update(const struct lu_env *env, struct osd_object *obj, rc = osd_object_sa_update(obj, SA_ZPL_DXATTR(osd), dxattr, sa_size, oh); out_free: - sa_spill_free(dxattr); + osd_zio_buf_free(dxattr, sa_size); RETURN(rc); }