Whamcloud - gitweb
LU-6038 osd-zfs: sa_spill_alloc()/sa_spill_free() compat 97/13097/6
authorBrian Behlendorf <behlendorf1@llnl.gov>
Wed, 17 Dec 2014 00:14:17 +0000 (16:14 -0800)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 3 Mar 2015 16:46:33 +0000 (16:46 +0000)
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 <behlendorf1@llnl.gov>
Change-Id: Id1d19d7b4c440808b8b3fd042f687b10c1b869f2
Reviewed-on: http://review.whamcloud.com/13097
Reviewed-by: Alex Zhuravlev <alexey.zhuravlev@intel.com>
Reviewed-by: Nathaniel Clark <nathaniel.l.clark@intel.com>
Reviewed-by: Isaac Huang <he.huang@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
config/lustre-build-zfs.m4
lustre/osd-zfs/osd_internal.h
lustre/osd-zfs/osd_xattr.c

index b6d56dd..455977d 100644 (file)
@@ -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 <sys/kmem.h>
+                       #include <sys/sa.h>
+               ],[
+                       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])
index 988ccb5..6124fa8 100644 (file)
@@ -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 */
index 1697728..4a32f1a 100644 (file)
@@ -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);
 }