} \
} while (0)
+#define OBD_FREE_RCU(ptr, size, list) \
+do { \
+ if (likely(ptr)) { \
+ OBD_FREE_PRE(ptr, size, "kfreed_rcu"); \
+ kfree_rcu(ptr, list); \
+ POISON_PTR(ptr); \
+ } \
+} while (0)
+
#define OBD_FREE_LARGE(ptr, size) \
do { \
if (is_vmalloc_addr(ptr)) { \
LASSERT(pool->pool_proc_entry == NULL);
lu_tgt_pool_free(&(pool->pool_rr.lqr_pool));
lu_tgt_pool_free(&(pool->pool_obds));
- kfree_rcu(pool, pool_rcu);
+ OBD_FREE_RCU(pool, sizeof(*pool), pool_rcu);
EXIT;
}
if (strlen(poolname) > LOV_MAXPOOLNAME)
RETURN(-ENAMETOOLONG);
- /* OBD_ALLOC_* doesn't work with direct kfree_rcu use */
- new_pool = kmalloc(sizeof(*new_pool), __GFP_ZERO);
+ OBD_ALLOC_PTR(new_pool);
if (new_pool == NULL)
RETURN(-ENOMEM);
LASSERT(list_empty(&pool->pool_list));
LASSERT(pool->pool_proc_entry == NULL);
lu_tgt_pool_free(&(pool->pool_obds));
- kfree_rcu(pool, pool_rcu);
+ OBD_FREE_RCU(pool, sizeof(*pool), pool_rcu);
EXIT;
}
if (strlen(poolname) > LOV_MAXPOOLNAME)
RETURN(-ENAMETOOLONG);
- /* OBD_ALLOC doesn't work with direct use of kfree_rcu */
- new_pool = kmalloc(sizeof(*new_pool), GFP_KERNEL);
+ OBD_ALLOC_PTR(new_pool);
if (new_pool == NULL)
RETURN(-ENOMEM);
{
LASSERT(refcount_read(&mfd->mfd_open_handle.h_ref) == 1);
LASSERT(list_empty(&mfd->mfd_list));
- OBD_FREE_PRE(mfd, sizeof(*mfd), "kfree_rcu");
- kfree_rcu(mfd, mfd_open_handle.h_rcu);
+ OBD_FREE_RCU(mfd, sizeof(*mfd), mfd_open_handle.h_rcu);
}
static int mdt_create_data(struct mdt_thread_info *info,
dt_object_fini(&obj->mgo_obj);
lu_object_header_fini(h);
- OBD_FREE_PRE(obj, sizeof(*obj), "kfreed");
- kfree_rcu(obj, mgo_header.loh_rcu);
+ OBD_FREE_RCU(obj, sizeof(*obj), mgo_header.loh_rcu);
}
static int mgs_object_print(const struct lu_env *env, void *cookie,
if (exp != obd->obd_self_export)
class_decref(obd, "export", exp);
- OBD_FREE_PRE(exp, sizeof(*exp), "kfree_rcu");
- kfree_rcu(exp, exp_handle.h_rcu);
+ OBD_FREE_RCU(exp, sizeof(*exp), exp_handle.h_rcu);
EXIT;
}
int ret;
int len = strlen(jobid);
- sj = kmalloc(sizeof(*sj) + len + 1, GFP_KERNEL);
+ OBD_ALLOC(sj, sizeof(*sj) + len + 1);
if (!sj)
return -ENOMEM;
rcu_read_lock();
if (IS_ERR(origsj)) {
put_pid(sj->sj_session);
- kfree(sj);
+ OBD_FREE(sj, sizeof(*sj) + strlen(sj->sj_jobid) + 1);
rcu_read_unlock();
return PTR_ERR(origsj);
}
jobid_params);
if (ret) {
put_pid(sj->sj_session);
- kfree(sj);
+ OBD_FREE(sj, sizeof(*sj) + strlen(sj->sj_jobid) + 1);
rcu_read_unlock();
return ret;
}
put_pid(origsj->sj_session);
rcu_read_unlock();
- kfree_rcu(origsj, sj_rcu);
+ OBD_FREE_RCU(origsj, sizeof(*sj) + strlen(origsj->sj_jobid) + 1, sj_rcu);
jobid_prune_expedite();
return 0;
struct session_jobid *sj = vsj;
put_pid(sj->sj_session);
- kfree(sj);
+ OBD_FREE(sj, sizeof(*sj) + strlen(sj->sj_jobid) + 1);;
}
static void jobid_prune(struct work_struct *work);
&sj->sj_linkage,
jobid_params) == 0) {
put_pid(sj->sj_session);
- kfree_rcu(sj, sj_rcu);
+ OBD_FREE_RCU(sj, sizeof(*sj) + strlen(sj->sj_jobid) + 1,
+ sj_rcu);
}
}
rhashtable_walk_stop(&iter);
dt_object_fini(&obj->ls_obj);
lu_object_header_fini(h);
- OBD_FREE_PRE(obj, sizeof(*obj), "kfreed");
- kfree_rcu(obj, ls_header.loh_rcu);
+ OBD_FREE_RCU(obj, sizeof(*obj), ls_header.loh_rcu);
}
static const struct lu_object_operations ls_lu_obj_ops = {
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);
+ OBD_FREE_RCU(h, sizeof(*h), loh_rcu);
}
EXPORT_SYMBOL(lu_object_header_free);
lu_env_rhash_params);
if (lei && rhashtable_remove_fast(&lu_env_rhash, &lei->lei_linkage,
lu_env_rhash_params) == 0) {
- OBD_FREE_PRE(lei, sizeof(*lei), "kfreed");
- kfree_rcu(lei, lei_rcu_head);
+ OBD_FREE_RCU(lei, sizeof(*lei), lei_rcu_head);
}
}
EXPORT_SYMBOL(lu_env_remove);
static int lmd_parse_string(char **handle, char *ptr)
{
+ int len;
+
if (!handle || !ptr)
return -EINVAL;
OBD_FREE(*handle, strlen(*handle) + 1);
*handle = NULL;
- *handle = kstrdup(ptr, GFP_NOFS);
+ len = strlen(ptr);
+ OBD_ALLOC(*handle, len + 1);
if (!*handle)
return -ENOMEM;
-
- OBD_ALLOC_POST(*handle, strlen(ptr) + 1, "kmalloced");
+ memcpy(*handle, ptr, len + 1);
return 0;
}