From bf7431d6e14c8a0a530cf7ed538d579cc2057e78 Mon Sep 17 00:00:00 2001 From: Andreas Dilger Date: Thu, 3 Sep 2020 16:37:47 -0600 Subject: [PATCH] LU-12542 osd: consolidate RCU handling 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 Change-Id: I0fa68f11b5008ede5a498d38b69ccaeecf3ebbe5 Reviewed-on: https://review.whamcloud.com/40204 Tested-by: jenkins Reviewed-by: Ben Evans Tested-by: Maloo Reviewed-by: James Simmons Reviewed-by: Neil Brown Reviewed-by: Oleg Drokin --- lustre/include/lu_object.h | 1 + lustre/obdclass/lu_object.c | 11 +++++++++++ lustre/osd-ldiskfs/osd_handler.c | 7 ++----- lustre/osd-zfs/osd_object.c | 7 ++----- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/lustre/include/lu_object.h b/lustre/include/lu_object.h index e86f8b9..2dc95af 100644 --- a/lustre/include/lu_object.h +++ b/lustre/include/lu_object.h @@ -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); diff --git a/lustre/obdclass/lu_object.c b/lustre/obdclass/lu_object.c index e174dfa9..8847a4e 100644 --- a/lustre/obdclass/lu_object.c +++ b/lustre/obdclass/lu_object.c @@ -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. */ diff --git a/lustre/osd-ldiskfs/osd_handler.c b/lustre/osd-ldiskfs/osd_handler.c index 57ef148..c8cec71 100644 --- a/lustre/osd-ldiskfs/osd_handler.c +++ b/lustre/osd-ldiskfs/osd_handler.c @@ -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); } /* diff --git a/lustre/osd-zfs/osd_object.c b/lustre/osd-zfs/osd_object.c index 7f38fa4..e34ba94 100644 --- a/lustre/osd-zfs/osd_object.c +++ b/lustre/osd-zfs/osd_object.c @@ -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 -- 1.8.3.1