Whamcloud - gitweb
LU-12542 osd: consolidate RCU handling 04/40204/2
authorAndreas Dilger <adilger@whamcloud.com>
Thu, 3 Sep 2020 22:37:47 +0000 (16:37 -0600)
committerOleg Drokin <green@whamcloud.com>
Mon, 19 Oct 2020 03:13:58 +0000 (03:13 +0000)
Consolidate lu_object_header_fini() and kfree_rcu() into a
single lu_object_header_free() function so that callers
which do not need a container for lu_object_header can
avoid duplicating common RCU and OBD_FREE handling code.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Change-Id: I0fa68f11b5008ede5a498d38b69ccaeecf3ebbe5
Reviewed-on: https://review.whamcloud.com/40204
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: Ben Evans <beevans@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Neil Brown <neilb@suse.de>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/include/lu_object.h
lustre/obdclass/lu_object.c
lustre/osd-ldiskfs/osd_handler.c
lustre/osd-zfs/osd_object.c

index e86f8b9..2dc95af 100644 (file)
@@ -669,6 +669,7 @@ int  lu_device_init       (struct lu_device *d, struct lu_device_type *t);
 void lu_device_fini       (struct lu_device *d);
 int  lu_object_header_init(struct lu_object_header *h);
 void lu_object_header_fini(struct lu_object_header *h);
+void lu_object_header_free(struct lu_object_header *h);
 int  lu_object_init       (struct lu_object *o,
                            struct lu_object_header *h, struct lu_device *d);
 void lu_object_fini       (struct lu_object *o);
index e174dfa..8847a4e 100644 (file)
@@ -1389,6 +1389,17 @@ void lu_object_header_fini(struct lu_object_header *h)
 EXPORT_SYMBOL(lu_object_header_fini);
 
 /**
+ * Free lu_object_header with proper RCU handling
+ */
+void lu_object_header_free(struct lu_object_header *h)
+{
+       lu_object_header_fini(h);
+       OBD_FREE_PRE(h, sizeof(*h), "kfreed");
+       kfree_rcu(h, loh_rcu);
+}
+EXPORT_SYMBOL(lu_object_header_free);
+
+/**
  * Given a compound object, find its slice, corresponding to the device type
  * \a dtype.
  */
index 57ef148..c8cec71 100644 (file)
@@ -1583,11 +1583,8 @@ static void osd_object_free(const struct lu_env *env, struct lu_object *l)
                ldiskfs_htree_lock_head_free(obj->oo_hl_head);
        /* obj doesn't contain an lu_object_header, so we don't need call_rcu */
        OBD_FREE_PTR(obj);
-       if (unlikely(h)) {
-               lu_object_header_fini(h);
-               OBD_FREE_PRE(h, sizeof(*h), "kfreed");
-               kfree_rcu(h, loh_rcu);
-       }
+       if (unlikely(h))
+               lu_object_header_free(h);
 }
 
 /*
index 7f38fa4..e34ba94 100644 (file)
@@ -696,11 +696,8 @@ static void osd_object_free(const struct lu_env *env, struct lu_object *l)
        dt_object_fini(&obj->oo_dt);
        /* obj doesn't contain an lu_object_header, so we don't need call_rcu */
        OBD_SLAB_FREE_PTR(obj, osd_object_kmem);
-       if (unlikely(h)) {
-               lu_object_header_fini(h);
-               OBD_FREE_PRE(h, sizeof(*h), "kfreed");
-               kfree_rcu(h, loh_rcu);
-       }
+       if (unlikely(h))
+               lu_object_header_free(h);
 }
 
 static int