[v2,13/14] fs/fuse kio: convert rpc state id to string

Submitted by Pavel Butsykin on May 24, 2019, 3:55 p.m.

Details

Message ID 20190524155503.7205-14-pbutsykin@virtuozzo.com
State New
Series "Statistics for vstorage kernel fast-path"
Headers show

Commit Message

Pavel Butsykin May 24, 2019, 3:55 p.m.
This is preparation patch that will be needed to display the rpc state
as string.

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

Patch hide | download patch | download mbox

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_ */