int libcfs_kkuc_msg_put(struct file *fp, void *payload);
int libcfs_kkuc_group_put(int group, void *payload);
int libcfs_kkuc_group_add(struct file *fp, int uid, unsigned int group,
- void *data);
-int libcfs_kkuc_group_rem(int uid, int group, void **pdata);
+ void *data, size_t data_len);
+int libcfs_kkuc_group_rem(int uid, int group);
int libcfs_kkuc_group_foreach(int group, libcfs_kkuc_cb_t cb_func,
void *cb_arg);
static int lmv_hsm_ct_unregister(struct lmv_obd *lmv, unsigned int cmd, int len,
struct lustre_kernelcomm *lk, void *uarg)
{
- struct kkuc_ct_data *kcd = NULL;
int rc = 0;
__u32 i;
* Unreached coordinators will get EPIPE on next requests
* and will unregister automatically.
*/
- rc = libcfs_kkuc_group_rem(lk->lk_uid, lk->lk_group, (void **)&kcd);
- if (kcd)
- kfree(kcd);
+ rc = libcfs_kkuc_group_rem(lk->lk_uid, lk->lk_group);
return rc;
}
__u32 i, j;
int err, rc = 0;
bool any_set = false;
- struct kkuc_ct_data *kcd;
+ struct kkuc_ct_data kcd = { 0 };
/* All or nothing: try to register to all MDS.
* In case of failure, unregister from previous MDS,
if (!filp)
return -EBADF;
- kcd = kzalloc(sizeof(*kcd), GFP_NOFS);
- if (!kcd) {
- fput(filp);
- return -ENOMEM;
- }
- kcd->kcd_magic = KKUC_CT_DATA_MAGIC;
- kcd->kcd_uuid = lmv->cluuid;
- kcd->kcd_archive = lk->lk_data;
+ kcd.kcd_magic = KKUC_CT_DATA_MAGIC;
+ kcd.kcd_uuid = lmv->cluuid;
+ kcd.kcd_archive = lk->lk_data;
- rc = libcfs_kkuc_group_add(filp, lk->lk_uid, lk->lk_group, kcd);
+ rc = libcfs_kkuc_group_add(filp, lk->lk_uid, lk->lk_group,
+ &kcd, sizeof(kcd));
if (rc) {
if (filp)
fput(filp);
- kfree(kcd);
}
return rc;
case OBD_CLEANUP_EXPORTS:
/* Failsafe, ok if racy */
if (obd->obd_type->typ_refcnt <= 1)
- libcfs_kkuc_group_rem(0, KUC_GRP_HSM, NULL);
+ libcfs_kkuc_group_rem(0, KUC_GRP_HSM);
obd_cleanup_client_import(obd);
ptlrpc_lprocfs_unregister_obd(obd);
struct list_head kr_chain;
int kr_uid;
struct file *kr_fp;
- void *kr_data;
+ char kr_data[0];
};
static struct list_head kkuc_groups[KUC_GRP_MAX+1] = {};
* @param data user data
*/
int libcfs_kkuc_group_add(struct file *filp, int uid, unsigned int group,
- void *data)
+ void *data, size_t data_len)
{
struct kkuc_reg *reg;
return -EBADF;
/* freed in group_rem */
- reg = kmalloc(sizeof(*reg), 0);
+ reg = kmalloc(sizeof(*reg) + data_len, 0);
if (reg == NULL)
return -ENOMEM;
reg->kr_fp = filp;
reg->kr_uid = uid;
- reg->kr_data = data;
+ memcpy(reg->kr_data, data, data_len);
down_write(&kg_sem);
if (kkuc_groups[group].next == NULL)
}
EXPORT_SYMBOL(libcfs_kkuc_group_add);
-int libcfs_kkuc_group_rem(int uid, int group, void **pdata)
+int libcfs_kkuc_group_rem(int uid, int group)
{
struct kkuc_reg *reg, *next;
reg->kr_uid, reg->kr_fp, group);
if (reg->kr_fp != NULL)
fput(reg->kr_fp);
- if (pdata)
- *pdata = reg->kr_data;
kfree(reg);
}
}