[Devel] [PATCH VZ9 2/2] fs/fuse kio: abort all kRPCs on fuse connection abort

Liu Kui kui.liu at virtuozzo.com
Mon Dec 9 11:46:55 MSK 2024


All kRPCs must be aborted first to remove all potential lingering
references to pages belong to fuse read requests that will be
completed during fuse connection abort.

Related to #VSTOR-95997

Signed-off-by: Liu Kui <kui.liu at virtuozzo.com>
---
 fs/fuse/dev.c                      | 5 +++--
 fs/fuse/kio/pcs/pcs_fuse_kdirect.c | 9 +++++++--
 fs/fuse/kio/pcs/pcs_krpc.c         | 8 ++++++++
 fs/fuse/kio/pcs/pcs_krpc.h         | 1 +
 4 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index f5594e49bc2f..3193590eb642 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -2615,8 +2615,6 @@ void fuse_abort_conn(struct fuse_conn *fc)
 						      &to_end);
 			spin_unlock(&fpq->lock);
 		}
-		if (fc->kio.op)
-			fc->kio.op->conn_abort(fc);
 
 		spin_lock(&fc->bg_lock);
 		fc->blocked = 0;
@@ -2633,6 +2631,9 @@ void fuse_abort_conn(struct fuse_conn *fc)
 			wake_up_all(&fc->qhash[cpu].waitq);
 		spin_unlock(&fc->lock);
 
+		if (fc->kio.op)
+			fc->kio.op->conn_abort(fc);
+
 		end_requests(&to_end);
 	} else {
 		spin_unlock(&fc->lock);
diff --git a/fs/fuse/kio/pcs/pcs_fuse_kdirect.c b/fs/fuse/kio/pcs/pcs_fuse_kdirect.c
index 5b141fe5bbd4..7e5d3d4fb403 100644
--- a/fs/fuse/kio/pcs/pcs_fuse_kdirect.c
+++ b/fs/fuse/kio/pcs/pcs_fuse_kdirect.c
@@ -313,11 +313,16 @@ static void kpcs_conn_fini(struct fuse_mount *fm)
 
 static void kpcs_conn_abort(struct fuse_conn *fc)
 {
-	/* XXX: Implement abort pending kio */
+	struct pcs_fuse_cluster *pfc = (struct pcs_fuse_cluster *) fc->kio.ctx;
+
+	/* we need to abort krpcs */
+	if (!pfc)
+		return;
+
+	pcs_krpcset_abort(&pfc->cc.krpcs);
 }
 
 static int kpcs_probe(struct fuse_conn *fc, char *name)
-
 {
 	return 1;
 }
diff --git a/fs/fuse/kio/pcs/pcs_krpc.c b/fs/fuse/kio/pcs/pcs_krpc.c
index ab2534f7a952..45ec3cb3207c 100644
--- a/fs/fuse/kio/pcs/pcs_krpc.c
+++ b/fs/fuse/kio/pcs/pcs_krpc.c
@@ -957,6 +957,14 @@ void pcs_krpcset_init(struct pcs_krpc_set *krpcs)
 	spin_lock_init(&krpcs->lock);
 }
 
+void pcs_krpcset_abort(struct pcs_krpc_set *krpcs)
+{
+	struct pcs_krpc *krpc;
+
+	list_for_each_entry(krpc, &krpcs->list, link)
+		pcs_krpc_abort(krpc);
+}
+
 void pcs_krpcset_fini(struct pcs_krpc_set *krpcs)
 {
 	spin_lock(&krpcs->lock);
diff --git a/fs/fuse/kio/pcs/pcs_krpc.h b/fs/fuse/kio/pcs/pcs_krpc.h
index 556021b1d1f5..85ddbe1b713c 100644
--- a/fs/fuse/kio/pcs/pcs_krpc.h
+++ b/fs/fuse/kio/pcs/pcs_krpc.h
@@ -138,6 +138,7 @@ void pcs_krpc_fini(void);
 
 void pcs_krpcset_init(struct pcs_krpc_set *krpcs);
 void pcs_krpcset_fini(struct pcs_krpc_set *krpcs);
+void pcs_krpcset_abort(struct pcs_krpc_set *krpcs);
 
 struct pcs_krpc *pcs_krpc_lookup(struct pcs_krpc_set *krpcs, PCS_NODE_ID_T *id);
 int pcs_krpc_create(struct pcs_krpc_set *krpcs, PCS_NODE_ID_T *id,
-- 
2.39.5 (Apple Git-154)



More information about the Devel mailing list