[RHEL7,COMMIT] fs/fuse kio: convert rpc state id to string

Submitted by Konstantin Khorenko on May 29, 2019, 2:35 p.m.

Details

Message ID 201905291435.x4TEZiVb010074@finist-ce7.sw.ru
State New
Series "Statistics for vstorage kernel fast-path"
Headers show

Commit Message

Konstantin Khorenko May 29, 2019, 2:35 p.m.
The commit is pushed to "branch-rh7-3.10.0-957.12.2.vz7.96.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-957.12.2.vz7.96.7
------>
commit 3e28b5e4801445085003c71e791780b2dcdf7272
Author: Pavel Butsykin <pbutsykin@virtuozzo.com>
Date:   Wed May 29 17:35:44 2019 +0300

    fs/fuse kio: convert rpc state id to string
    
    This is preparation patch that will be needed to display the rpc state
    as string.
    
    Signed-off-by: Pavel Butsykin <pbutsykin@virtuozzo.com>
    
    =====================
    Patchset description:
    
    Statistics for vstorage kernel fast-path
    
    Vstorage provides plenty of statistics information via 'vstorage -c cl mnt-top',
    but when it comes kernel fast-path, it doesn't work. All because mnt-top
    command collects information from .vstorage.info directory, where vstorage-mount
    provides a lot of different statistical information in the form of files, but
    it was not implemented for for fast-path.
    
    This patch-set is aimed to implementation of the support of some statistics
    inforamtion files from .vstorage.info:
      cs_stats
      fstat
      fstat_lat
      iostat
      requests
    Which will be located at "/sys/fs/fuse/connections/*mnt_id*/kio_stat/". This
    will be enough to maintain vstorage mnt-top command for fast-path mount points.
    
    https://pmc.acronis.com/browse/VSTOR-20979
    
    Acked-by: Alexey Kuznetsov <kuznet@virtuozzo.com>
    
    Pavel Butsykin (14):
      fs/fuse: add conn_ctl to fuse_conn struct
      fs/fuse kio: create sysfs stat directory
      fs/fuse kio: implement iostat statistics info
      fs/fuse kio: make interface pcs_kio_file_list() for listing kio files
      fs/fuse kio: make interface pcs_kio_req_list() for listing kio reqs
      fs/fuse kio: add retry counter for kio requests
      fs/fuse kio: implement pcs_strerror()
      fs/fuse kio: implement requests statistics info
      fs/fuse kio: implement fstat statistics info
      fs/fuse kio: implement fstat_lat statistics info
      fs/fuse kio: remove useless pcs_cs initialization
      fs/fuse kio: implement cs statistics accounting
      fs/fuse kio: convert rpc state id to string
      fs/fuse kio: implement cs_stats statistics info
---
 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_ */