[Devel] [PATCH VZ9] fs/fuse kio: fixed a bug in pcs_rpc_cancel_msg()

Liu Kui kui.liu at virtuozzo.com
Thu Nov 21 05:44:31 MSK 2024


Pass the pointer of pcs_rpc instance from caller because msg->rpc
could be NULL when the msg is still in the input_queue.

Signed-off-by: Liu Kui <kui.liu at virtuozzo.com>
---
 fs/fuse/kio/pcs/pcs_krpc.c | 4 ++--
 fs/fuse/kio/pcs/pcs_rpc.c  | 5 +----
 fs/fuse/kio/pcs/pcs_rpc.h  | 2 +-
 3 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/fs/fuse/kio/pcs/pcs_krpc.c b/fs/fuse/kio/pcs/pcs_krpc.c
index 68a30d7c3e2d..9af1c93b20ed 100644
--- a/fs/fuse/kio/pcs/pcs_krpc.c
+++ b/fs/fuse/kio/pcs/pcs_krpc.c
@@ -567,7 +567,7 @@ static int pcs_krpc_abort(struct pcs_krpc *krpc)
 		kreq->flags |= KRPC_REQ_F_ABORTED;
 		msg = &kreq->msg;
 		/* if msg is cancelled, kreq will be removed from the queue */
-		pcs_rpc_cancel_msg(msg);
+		pcs_rpc_cancel_msg(ep, msg);
 	}
 
 	/*
@@ -583,7 +583,7 @@ static int pcs_krpc_abort(struct pcs_krpc *krpc)
 		msg = &kreq->msg;
 
 		/* no longer busy and cancelled */
-		if (!pcs_rpc_cancel_msg(msg))
+		if (!pcs_rpc_cancel_msg(ep, msg))
 			continue;
 
 		/* seems somthing wrong happened to hardware, abort the rpc */
diff --git a/fs/fuse/kio/pcs/pcs_rpc.c b/fs/fuse/kio/pcs/pcs_rpc.c
index 79254431592a..9d782b6bea93 100644
--- a/fs/fuse/kio/pcs/pcs_rpc.c
+++ b/fs/fuse/kio/pcs/pcs_rpc.c
@@ -578,11 +578,8 @@ void pcs_rpc_cancel_request(struct pcs_msg * msg)
 	msg->done(msg);
 }
 
-int pcs_rpc_cancel_msg(struct pcs_msg *msg)
+int pcs_rpc_cancel_msg(struct pcs_rpc *ep, struct pcs_msg *msg)
 {
-	struct pcs_rpc *ep = msg->rpc;
-
-	BUG_ON(!ep);
 	BUG_ON(!mutex_is_locked(&ep->mutex));
 
 	switch (msg->stage) {
diff --git a/fs/fuse/kio/pcs/pcs_rpc.h b/fs/fuse/kio/pcs/pcs_rpc.h
index f13274300f3e..baec7f844e38 100644
--- a/fs/fuse/kio/pcs/pcs_rpc.h
+++ b/fs/fuse/kio/pcs/pcs_rpc.h
@@ -323,6 +323,6 @@ static inline struct pcs_rpc *pcs_rpc_from_work(struct work_struct *wr)
 const char* pcs_rpc_state_name(unsigned state);
 
 void pcs_rpc_report_error(struct pcs_rpc *ep, unsigned int err);
-int pcs_rpc_cancel_msg(struct pcs_msg *msg);
+int pcs_rpc_cancel_msg(struct pcs_rpc *ep, struct pcs_msg *msg);
 
 #endif /* _PCS_RPC_H_ */
-- 
2.39.5 (Apple Git-154)



More information about the Devel mailing list