[Devel] [PATCH 13/15] fs/fuse kio: convert rpc state id to string

Pavel Butsykin pbutsykin at virtuozzo.com
Fri May 17 16:20:46 MSK 2019


This is preparation patch that will be needed to display the rpc state
as string.

Signed-off-by: Pavel Butsykin <pbutsykin at virtuozzo.com>
---
 fs/fuse/kio/pcs/pcs_rpc.c | 23 +++++++++++++++++++++++
 fs/fuse/kio/pcs/pcs_rpc.h |  2 ++
 2 files changed, 25 insertions(+)

diff --git a/fs/fuse/kio/pcs/pcs_rpc.c b/fs/fuse/kio/pcs/pcs_rpc.c
index a34b204476bd..66d090988552 100644
--- a/fs/fuse/kio/pcs/pcs_rpc.c
+++ b/fs/fuse/kio/pcs/pcs_rpc.c
@@ -1434,3 +1434,26 @@ void rpc_connect_done(struct pcs_rpc *ep, struct socket *sock)
 	mutex_unlock(&ep->mutex);
 
 }
+
+static const char *s_rpc_state_names[] = {
+	[PCS_RPC_UNCONN]	= "UNCONN",	/* Not connected */
+	[PCS_RPC_CONNECT]	= "CONNECT",	/* Connect in progress */
+	[PCS_RPC_AUTH]		= "AUTH",	/* Connected. Auth request sent. */
+	[PCS_RPC_AUTHWAIT]	= "AUTHWAIT",	/* Accepted. Waiting for auth request from peer. */
+	[PCS_RPC_APPWAIT] 	= "APPWAIT",	/* Auth complete, client is notified */
+	[PCS_RPC_WORK]		= "WORK",	/* Established */
+	[PCS_RPC_HOLDDOWN] 	= "HOLDDOWN",	/* Not connected. Connect must not be reinitiated. */
+	[PCS_RPC_ABORT]		= "ABORT",	/* Aborted. Not reconnected automatically. */
+	[PCS_RPC_DESTROY]	= "DESTROY"	/* Destruction in progress */
+};
+
+const char *pcs_rpc_state_name(unsigned state)
+{
+	const char *name;
+	if (state >=  ARRAY_SIZE(s_rpc_state_names))
+		return "Invalid";
+	name = s_rpc_state_names[state];
+	if (!name)
+		return "Invalid";
+	return name;
+}
diff --git a/fs/fuse/kio/pcs/pcs_rpc.h b/fs/fuse/kio/pcs/pcs_rpc.h
index 8d3c571fd1e2..119de48d4376 100644
--- a/fs/fuse/kio/pcs/pcs_rpc.h
+++ b/fs/fuse/kio/pcs/pcs_rpc.h
@@ -292,4 +292,6 @@ static inline struct pcs_rpc *pcs_rpc_from_work(struct work_struct *wr)
 	return container_of(wr, struct pcs_rpc, work);
 }
 
+const char* pcs_rpc_state_name(unsigned state);
+
 #endif /* _PCS_RPC_H_ */
-- 
2.15.1



More information about the Devel mailing list