Whamcloud - gitweb
LU-12542 handle: discard OBD_FREE_RCU 97/35797/9
authorNeilBrown <neilb@suse.com>
Tue, 1 Oct 2019 00:58:55 +0000 (20:58 -0400)
committerOleg Drokin <green@whamcloud.com>
Fri, 20 Dec 2019 03:26:23 +0000 (03:26 +0000)
OBD_FREE_RCU and the hop_free call-back together form an overly
complex mechanism equivalent to kfree_rcu() or call_rcu(...).
Discard them and use the simpler approach.

This removes the only use for the field h_size, so discard
that too.

Change-Id: I3b4135565dab6a9aa5034f42ae3f9b66851cae31
Signed-off-by: NeilBrown <neilb@suse.com>
Reviewed-on: https://review.whamcloud.com/35797
Reviewed-by: Neil Brown <neilb@suse.de>
Reviewed-by: Mike Pershin <mpershin@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Shaun Tancheff <stancheff@cray.com>
Reviewed-by: Petros Koutoupis <pkoutoupis@cray.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
lustre/include/lustre_handles.h
lustre/include/obd_support.h
lustre/ldlm/ldlm_lock.c
lustre/mdt/mdt_open.c
lustre/obdclass/genops.c
lustre/obdclass/lustre_handles.c

index c7f316d..511a2f6 100644 (file)
@@ -48,7 +48,6 @@
 #include <libcfs/libcfs.h>
 
 struct portals_handle_ops {
-       void (*hop_free)(void *object, int size);
        /* hop_type is used for some debugging messages */
        char *hop_type;
 };
@@ -73,7 +72,6 @@ struct portals_handle {
        /* newly added fields to handle the RCU issue. -jxiong */
        struct rcu_head                 h_rcu;
        spinlock_t                      h_lock;
-       unsigned int                    h_size:31;
        unsigned int                    h_in:1;
 };
 
@@ -84,7 +82,6 @@ void class_handle_hash(struct portals_handle *,
                       const struct portals_handle_ops *ops);
 void class_handle_unhash(struct portals_handle *);
 void *class_handle2object(u64 cookie, const struct portals_handle_ops *ops);
-void class_handle_free_cb(struct rcu_head *rcu);
 int class_handle_init(void);
 void class_handle_cleanup(void);
 
index cc154f7..b81d22a 100644 (file)
@@ -767,8 +767,7 @@ static inline void obd_memory_sub(long size)
         LASSERT(ptr);                                                   \
         obd_memory_sub(size);                                           \
         CDEBUG(D_MALLOC, name " '" #ptr "': %d at %p.\n",               \
-               (int)(size), ptr);                                       \
-        POISON(ptr, 0x5a, size)
+              (int)(size), ptr);
 
 #else /* !OBD_DEBUG_MEMUSAGE */
 
@@ -866,6 +865,7 @@ do {                                                                              \
 #define OBD_FREE(ptr, size)                                                  \
 do {                                                                         \
        OBD_FREE_PRE(ptr, size, "kfreed");                                    \
+       POISON(ptr, 0x5a, size);                                              \
        kfree(ptr);                                                           \
        POISON_PTR(ptr);                                                      \
 } while (0)
@@ -874,6 +874,7 @@ do {                                                                              \
 do {                                                                         \
        if (is_vmalloc_addr(ptr)) {                                           \
                OBD_FREE_PRE(ptr, size, "vfreed");                            \
+               POISON(ptr, 0x5a, size);                                      \
                vfree(ptr);                                                   \
                POISON_PTR(ptr);                                              \
        } else {                                                              \
@@ -881,17 +882,6 @@ do {                                                                             \
        }                                                                     \
 } while (0)
 
-#define OBD_FREE_RCU(ptr, size, handle)                                              \
-do {                                                                         \
-       struct portals_handle *__h = (handle);                                \
-                                                                             \
-       LASSERT(handle != NULL);                                              \
-       __h->h_cookie = (unsigned long)(ptr);                                 \
-       __h->h_size = (size);                                                 \
-       call_rcu(&__h->h_rcu, class_handle_free_cb);                          \
-       POISON_PTR(ptr);                                                      \
-} while(0)
-
 /* we memset() the slab object to 0 when allocation succeeds, so DO NOT
  * HAVE A CTOR THAT DOES ANYTHING.  its work will be cleared here.  we'd
  * love to assert on that, but slab.c keeps kmem_cache_s all to itself. */
@@ -922,6 +912,7 @@ do {                                                                              \
 #define OBD_SLAB_FREE(ptr, slab, size)                                        \
 do {                                                                          \
         OBD_FREE_PRE(ptr, size, "slab-freed");                                \
+       POISON(ptr, 0x5a, size);                                              \
        kmem_cache_free(slab, ptr);                                        \
         POISON_PTR(ptr);                                                      \
 } while(0)
index b8e3989..2de1815 100644 (file)
@@ -190,6 +190,15 @@ struct ldlm_lock *ldlm_lock_get(struct ldlm_lock *lock)
 }
 EXPORT_SYMBOL(ldlm_lock_get);
 
+static void lock_handle_free(struct rcu_head *rcu)
+{
+       struct ldlm_lock *lock = container_of(rcu, struct ldlm_lock,
+                                             l_handle.h_rcu);
+
+       OBD_FREE_PRE(lock, sizeof(*lock), "slab-freed");
+       kmem_cache_free(ldlm_lock_slab, lock);
+}
+
 /**
  * Release lock reference.
  *
@@ -234,7 +243,7 @@ void ldlm_lock_put(struct ldlm_lock *lock)
                ldlm_resource_putref(res);
                lock->l_resource = NULL;
                 lu_ref_fini(&lock->l_reference);
-               OBD_FREE_RCU(lock, sizeof(*lock), &lock->l_handle);
+               call_rcu(&lock->l_handle.h_rcu, lock_handle_free);
         }
 
         EXIT;
@@ -438,14 +447,7 @@ void ldlm_lock_destroy_nolock(struct ldlm_lock *lock)
         EXIT;
 }
 
-static void lock_handle_free(void *lock, int size)
-{
-       LASSERT(size == sizeof(struct ldlm_lock));
-       OBD_SLAB_FREE(lock, ldlm_lock_slab, size);
-}
-
 static struct portals_handle_ops lock_handle_ops = {
-       .hop_free   = lock_handle_free,
        .hop_type       = "ldlm",
 };
 
index c13fe07..c364925 100644 (file)
@@ -45,7 +45,6 @@
 #include <lustre_nodemap.h>
 
 static const struct portals_handle_ops mfd_open_handle_ops = {
-       .hop_free   = NULL,
        .hop_type       = "mdt",
 };
 
@@ -104,7 +103,8 @@ void mdt_mfd_free(struct mdt_file_data *mfd)
 {
        LASSERT(refcount_read(&mfd->mfd_open_handle.h_ref) == 1);
        LASSERT(list_empty(&mfd->mfd_list));
-       OBD_FREE_RCU(mfd, sizeof *mfd, &mfd->mfd_open_handle);
+       OBD_FREE_PRE(mfd, sizeof(*mfd), "rcu");
+       kfree_rcu(mfd, mfd_open_handle.h_rcu);
 }
 
 static int mdt_create_data(struct mdt_thread_info *info,
index 1a635f3..0d670da 100644 (file)
@@ -966,12 +966,12 @@ static void class_export_destroy(struct obd_export *exp)
        if (exp != obd->obd_self_export)
                class_decref(obd, "export", exp);
 
-        OBD_FREE_RCU(exp, sizeof(*exp), &exp->exp_handle);
+       OBD_FREE_PRE(exp, sizeof(*exp), "rcu");
+       kfree_rcu(exp, exp_handle.h_rcu);
         EXIT;
 }
 
 static struct portals_handle_ops export_handle_ops = {
-       .hop_free   = NULL,
        .hop_type       = "export",
 };
 
index 75987f1..40d6918 100644 (file)
@@ -173,21 +173,6 @@ void *class_handle2object(u64 cookie, const struct portals_handle_ops *ops)
 }
 EXPORT_SYMBOL(class_handle2object);
 
-void class_handle_free_cb(struct rcu_head *rcu)
-{
-       struct portals_handle *h;
-       void *ptr;
-
-       h = container_of(rcu, struct portals_handle, h_rcu);
-       ptr = (void *)(unsigned long)h->h_cookie;
-
-       if (h->h_ops->hop_free != NULL)
-               h->h_ops->hop_free(ptr, h->h_size);
-       else
-               OBD_FREE(ptr, h->h_size);
-}
-EXPORT_SYMBOL(class_handle_free_cb);
-
 int class_handle_init(void)
 {
        struct handle_bucket *bucket;