Enable pcs_krpc in kio module: - add module parameter 'pcs_krpc_support' to indicate whether pcs_krpc is supported. - export APIs to userspace as sub-commands of the FUSE_IOC_KIO_CALL ioctl command on the /dev/fuse device.
https://pmc.acronis.work/browse/VSTOR-82613 Signed-off-by: Liu Kui <kui....@virtuozzo.com> --- fs/fuse/dev.c | 19 ++++-- fs/fuse/fuse_i.h | 2 +- fs/fuse/kio/pcs/pcs_cluster_core.c | 4 ++ fs/fuse/kio/pcs/pcs_fuse_kdirect.c | 94 +++++++++++++++++++++++++++++- fs/fuse/kio/pcs/pcs_ioctl.h | 29 +++++++++ 5 files changed, 140 insertions(+), 8 deletions(-) diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index e4a153bcc82e..01df9d4e4e70 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -2658,11 +2658,20 @@ static long fuse_dev_ioctl(struct file *file, unsigned int cmd, if (copy_from_user(&req, (void __user *)arg, sizeof(req))) return -EFAULT; - op = fuse_kio_get(NULL, req.name); - if (op == NULL) - return -EINVAL; - res = op->ioctl(NULL, NULL, req.cmd, req.data, req.len); - fuse_kio_put(op); + + fud = fuse_get_dev(file); + if (fud) { + op = fud->fc->kio.op; + if (op == NULL) + return -EINVAL; + res = op->dev_ioctl(fud->fc, req.cmd, req.data, req.len); + } else { + op = fuse_kio_get(NULL, req.name); + if (op == NULL) + return -EINVAL; + res = op->ioctl(NULL, NULL, req.cmd, req.data, req.len); + fuse_kio_put(op); + } break; } default: diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h index 0c1bd5209dbc..090871a1e356 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h @@ -649,7 +649,7 @@ struct fuse_kio_ops { void (*inode_release)(struct fuse_inode *fi); void (*kill_requests)(struct fuse_conn *fc, struct inode *inode); int (*ioctl)(struct file *file, struct inode *inode, unsigned int cmd, unsigned long arg, int len); - + int (*dev_ioctl)(struct fuse_conn *fc, unsigned int cmd, unsigned long arg, int len); }; int fuse_register_kio(struct fuse_kio_ops *ops); void fuse_unregister_kio(struct fuse_kio_ops *ops); diff --git a/fs/fuse/kio/pcs/pcs_cluster_core.c b/fs/fuse/kio/pcs/pcs_cluster_core.c index 8c34c60eb79a..6df2ccee9a1f 100644 --- a/fs/fuse/kio/pcs/pcs_cluster_core.c +++ b/fs/fuse/kio/pcs/pcs_cluster_core.c @@ -162,6 +162,8 @@ int pcs_cc_init(struct pcs_cluster_core *cc, struct workqueue_struct *wq, cc->nilbuffer_kv.iov_len = sizeof(cc->nilbuffer); pcs_csset_init(&cc->css); + pcs_mrset_init(&cc->mrs); + pcs_krpcset_init(&cc->krpcs); err = pcs_mapset_init(cc); if (err) @@ -210,6 +212,8 @@ int pcs_cc_init(struct pcs_cluster_core *cc, struct workqueue_struct *wq, void pcs_cc_fini(struct pcs_cluster_core *cc) { + pcs_krpcset_fini(&cc->krpcs); + pcs_mrset_fini(&cc->mrs); pcs_csset_fini(&cc->css); pcs_mapset_fini(&cc->maps); pcs_rpc_engine_fini(&cc->eng); diff --git a/fs/fuse/kio/pcs/pcs_fuse_kdirect.c b/fs/fuse/kio/pcs/pcs_fuse_kdirect.c index d326cab39625..a0452bad1fd1 100644 --- a/fs/fuse/kio/pcs/pcs_fuse_kdirect.c +++ b/fs/fuse/kio/pcs/pcs_fuse_kdirect.c @@ -37,6 +37,8 @@ #include "fuse_ktrace.h" #include "fuse_prometheus.h" #include "pcs_net_addr.h" +#include "pcs_mr.h" +#include "pcs_krpc.h" unsigned int pcs_loglevel = LOG_TRACE; module_param(pcs_loglevel, uint, 0644); @@ -79,6 +81,10 @@ unsigned int cpu_worker_flags = 1; module_param(cpu_worker_flags, uint, 0444); MODULE_PARM_DESC(cpu_worker_flags, "Set cpu worker flags"); +bool pcs_krpc_support = true; +module_param(pcs_krpc_support, bool, 0444); +MODULE_PARM_DESC(pcs_krpc_support, "krpc support"); + #define sel_wq_flags(f) ((((f) & 1) ? WQ_CPU_INTENSIVE : 0) | (((f) & 2) ? WQ_UNBOUND : 0)) void (*fuse_printk_plugin)(unsigned long, const char *, ...); @@ -1876,6 +1882,84 @@ static int kpcs_ioctl(struct file *file, struct inode *inode, unsigned int cmd, return res; } +static int kpcs_dev_ioctl(struct fuse_conn *fc, unsigned int cmd, unsigned long arg, int len) +{ + struct pcs_fuse_cluster *pfc = fc->kio.ctx; + struct pcs_cluster_core *cc = &pfc->cc; + int res; + + switch (cmd) { + case PCS_IOC_KRPC_CREATE: + { + struct pcs_ioc_krpc_create req; + + if (copy_from_user(&req, (void __user *)arg, sizeof(req))) + return -EFAULT; + + if (pcs_krpc_lookup(&cc->krpcs, &req.id)) + return -EEXIST; + + res = pcs_krpc_create(&cc->krpcs, &req.id, &req.addr, req.cs_flags); + break; + } + case PCS_IOC_KRPC_UPDATE_ADDR: + { + struct pcs_ioc_krpc_create req; + + if (copy_from_user(&req, (void __user *)arg, sizeof(req))) + return -EFAULT; + + res = pcs_krpc_update_addr(&cc->krpcs, &req.id, &req.addr, req.cs_flags); + break; + } + + case PCS_IOC_KRPC_CONNECT: + { + struct pcs_ioc_krpc_connect req; + + if (copy_from_user(&req, (void __user *)arg, sizeof(req))) + return -EFAULT; + + res = pcs_krpc_connect(&cc->krpcs, &req.id); + break; + } + case PCS_IOC_KRPC_DESTROY: + { + struct pcs_ioc_krpc_destroy req; + + if (copy_from_user(&req, (void __user *)arg, sizeof(req))) + return -EFAULT; + + res = pcs_krpc_destroy(&cc->krpcs, &req.id); + break; + } + case PCS_IOC_REG_MR: + { + struct pcs_ioc_reg_mr req; + + if (copy_from_user(&req, (void __user *)arg, sizeof(req))) + return -EFAULT; + + res = pcs_reg_mr(&cc->mrs, req.start, req.len); + break; + } + case PCS_IOC_DEREG_MR: + { + struct pcs_ioc_dereg_mr req; + + if (copy_from_user(&req, (void __user *)arg, sizeof(req))) + return -EFAULT; + + res = pcs_dereg_mr(&cc->mrs, req.id); + break; + } + default: + res = -ENOIOCTLCMD; + break; + } + return res; +} + static struct fuse_kio_ops kio_pcs_ops = { .name = "pcs", .owner = THIS_MODULE, @@ -1892,9 +1976,9 @@ static struct fuse_kio_ops kio_pcs_ops = { .inode_release = kpcs_inode_release, .kill_requests = kpcs_kill_requests, .ioctl = kpcs_ioctl, + .dev_ioctl = kpcs_dev_ioctl, }; - static int __init kpcs_mod_init(void) { int err = -ENOMEM; @@ -1936,10 +2020,13 @@ static int __init kpcs_mod_init(void) if (pcs_csa_init()) goto free_cleanup_wq; + if (pcs_krpc_init()) + goto free_csa; + fast_path_version = PCS_FAST_PATH_VERSION.full; if (fuse_register_kio(&kio_pcs_ops)) - goto free_csa; + goto free_krpc; /* Clone relay_file_operations to set ownership */ ktrace_file_operations = relay_file_operations; @@ -1957,6 +2044,8 @@ static int __init kpcs_mod_init(void) pcs_fuse_req_cachep, pcs_ireq_cachep, pcs_wq); return 0; +free_krpc: + pcs_krpc_fini(); free_csa: pcs_csa_fini(); free_cleanup_wq: @@ -1989,6 +2078,7 @@ static void __exit kpcs_mod_exit(void) kmem_cache_destroy(pcs_ireq_cachep); kmem_cache_destroy(pcs_fuse_req_cachep); pcs_csa_fini(); + pcs_krpc_fini(); } module_init(kpcs_mod_init); diff --git a/fs/fuse/kio/pcs/pcs_ioctl.h b/fs/fuse/kio/pcs/pcs_ioctl.h index 8e55be02c654..a0795d33b4f6 100644 --- a/fs/fuse/kio/pcs/pcs_ioctl.h +++ b/fs/fuse/kio/pcs/pcs_ioctl.h @@ -123,4 +123,33 @@ struct pcs_csa_setmap #define PCS_CSA_IOC_SETMAP _IOR('V',38, struct pcs_csa_setmap) #define PCS_KIO_CALL_REG _IOR('V',39, struct fuse_pcs_ioc_register) +struct pcs_ioc_reg_mr { + u64 start; + u64 len; +}; +#define PCS_IOC_REG_MR _IOR('V', 40, struct pcs_ioc_reg_mr) + +struct pcs_ioc_dereg_mr { + u32 id; +}; +#define PCS_IOC_DEREG_MR _IOR('V', 41, struct pcs_ioc_dereg_mr) + +struct pcs_ioc_krpc_create { + PCS_NODE_ID_T id; + PCS_NET_ADDR_T addr; + int cs_flags; +}; +#define PCS_IOC_KRPC_CREATE _IOR('V', 42, struct pcs_ioc_krpc_create) +#define PCS_IOC_KRPC_UPDATE_ADDR _IOR('V', 43, struct pcs_ioc_krpc_create) + +struct pcs_ioc_krpc_connect { + PCS_NODE_ID_T id; +}; +#define PCS_IOC_KRPC_CONNECT _IOR('V', 44, struct pcs_ioc_krpc_connect) + +struct pcs_ioc_krpc_destroy { + PCS_NODE_ID_T id; +}; +#define PCS_IOC_KRPC_DESTROY _IOR('V', 45, struct pcs_ioc_krpc_destroy) + #endif /* _PCS_IOCTL_H_ */ -- 2.39.3 (Apple Git-146) _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel