[Devel] [PATCH RHEL7 COMMIT] fuse kio: Add pcs_cleanup_wq

Konstantin Khorenko khorenko at virtuozzo.com
Tue Oct 16 18:04:34 MSK 2018


The commit is pushed to "branch-rh7-3.10.0-862.14.4.vz7.72.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-862.14.4.vz7.72.9
------>
commit 30690e3586409a33d2d265200e7d256be4e41c7d
Author: Kirill Tkhai <ktkhai at virtuozzo.com>
Date:   Tue Oct 16 18:04:30 2018 +0300

    fuse kio: Add pcs_cleanup_wq
    
    This is a work, which makes possible pining pcs_rps to pcs_sockio
    in next patches, and pcs_rpc_destroy() will be called from its context.
    We can't do that from pcs_wq instead, since the function flushes
    delayed works, which are queued on this workqueue. So we introduce
    the new one.
    
    Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
    Reviewed-by: Pavel Butsykin <pbutsykin at virtuozzo.com>
    
    =====================
    Patchset description:
    
    Order pcs_rpc and pcs_sockio destruction and close leaked socket
    
    https://pmc.acronis.com/browse/VSTOR-15305
    
    Ploop can asynchronously unmap regions by sending IOCB_CMD_UNMAP_ITER, but this
    command isn't quite correctly interpreted in Fuse. Moreover, in Fast-path mode,
    fallocate(FALLOC_FL_PUNCH_HOLE|FALLOC_FL_ZERO_RANGE) falls to fuse user daemon
    and it can lead to data corruption.
    
    Let's fix it.
    
    Kirill Tkhai (9):
          fuse kio: Use __maybe_unused
          fuse kio: Use sio eof instead of parent to determ abort
          fuse kio: Reorder callback assignment
          fuse kio: Add pcs_cleanup_wq
          fuse kio: Destroy rpc in work func
          fuse kio: Introduce pcs_sk_kick_queue()
          fuse kio: Dereference sk_user_data under rcu
          fuse kio: Fix rpc socket leak on rpc_abort()
          fuse kio: Hold pcs_rpc counter till sio may be freed
---
 fs/fuse/kio/pcs/pcs_cluster.h      |  2 ++
 fs/fuse/kio/pcs/pcs_fuse_kdirect.c | 10 +++++++++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/fs/fuse/kio/pcs/pcs_cluster.h b/fs/fuse/kio/pcs/pcs_cluster.h
index f4ec5ecf9571..9c537cb43b30 100644
--- a/fs/fuse/kio/pcs/pcs_cluster.h
+++ b/fs/fuse/kio/pcs/pcs_cluster.h
@@ -41,6 +41,8 @@ struct pcs_fuse_work {
 	void *ctx2;
 };
 
+extern struct workqueue_struct *pcs_cleanup_wq;
+
 int pcs_cluster_init(struct pcs_fuse_cluster *c, struct workqueue_struct *,
 		     struct fuse_conn *fc, PCS_CLUSTER_ID_T *cl_id,
 		     PCS_NODE_ID_T *id);
diff --git a/fs/fuse/kio/pcs/pcs_fuse_kdirect.c b/fs/fuse/kio/pcs/pcs_fuse_kdirect.c
index a9b0b729dafe..b286a956a751 100644
--- a/fs/fuse/kio/pcs/pcs_fuse_kdirect.c
+++ b/fs/fuse/kio/pcs/pcs_fuse_kdirect.c
@@ -61,6 +61,7 @@ static int fuse_ktrace_remove(struct fuse_conn *fc);
 static struct kmem_cache *pcs_fuse_req_cachep;
 static struct kmem_cache *pcs_ireq_cachep;
 static struct workqueue_struct *pcs_wq;
+struct workqueue_struct *pcs_cleanup_wq;
 static struct fuse_kio_ops kio_pcs_ops;
 static struct dentry *fuse_trace_root;
 
@@ -1494,15 +1495,21 @@ static int __init kpcs_mod_init(void)
 	if (!pcs_wq)
 		goto free_map_cache;
 
-	if (fuse_register_kio(&kio_pcs_ops))
+	pcs_cleanup_wq = alloc_workqueue("pcs_cleanup_wq", WQ_MEM_RECLAIM, 0);
+	if (!pcs_cleanup_wq)
 		goto free_wq;
 
+	if (fuse_register_kio(&kio_pcs_ops))
+		goto free_cleanup_wq;
+
 	fuse_trace_root = debugfs_create_dir("fuse", NULL);
 
 	printk("%s fuse_c:%p ireq_c:%p pcs_wq:%p\n", __FUNCTION__,
 	       pcs_fuse_req_cachep, pcs_ireq_cachep, pcs_wq);
 
 	return 0;
+free_cleanup_wq:
+	destroy_workqueue(pcs_cleanup_wq);
 free_wq:
 	destroy_workqueue(pcs_wq);
 free_map_cache:
@@ -1520,6 +1527,7 @@ static void __exit kpcs_mod_exit(void)
 		debugfs_remove(fuse_trace_root);
 
 	fuse_unregister_kio(&kio_pcs_ops);
+	destroy_workqueue(pcs_cleanup_wq);
 	destroy_workqueue(pcs_wq);
 	kmem_cache_destroy(pcs_map_cachep);
 	kmem_cache_destroy(pcs_ireq_cachep);



More information about the Devel mailing list