#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;
};
/* 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;
};
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);
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 */
#define OBD_FREE(ptr, size) \
do { \
OBD_FREE_PRE(ptr, size, "kfreed"); \
+ POISON(ptr, 0x5a, size); \
kfree(ptr); \
POISON_PTR(ptr); \
} while (0)
do { \
if (is_vmalloc_addr(ptr)) { \
OBD_FREE_PRE(ptr, size, "vfreed"); \
+ POISON(ptr, 0x5a, size); \
vfree(ptr); \
POISON_PTR(ptr); \
} else { \
} \
} 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. */
#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)
}
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.
*
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;
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",
};
#include <lustre_nodemap.h>
static const struct portals_handle_ops mfd_open_handle_ops = {
- .hop_free = NULL,
.hop_type = "mdt",
};
{
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,
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",
};
}
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;