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.1 ------> commit 741d63d1d296ed17dcdcb0bbaec5a51e212c308f Author: Pavel Butsykin <pbutsy...@virtuozzo.com> Date: Tue May 21 18:47:42 2019 +0300
fs/fuse kio: implement requests statistics info This statistic shows information about all inflight kio requests. Made by analogy with .vstorage.info/requests statistics of user-mod client. example: READ 13 0 0/0 0 Success /fio_test/randasyncread_jobs24_4k.1.0 READ 4 0 0/0 0 Success /fio_test/randasyncread_jobs24_4k.0.0 Signed-off-by: Pavel Butsykin <pbutsy...@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 Pavel Butsykin (15): fs/fuse: add conn_ctl to fuse_conn struct fs/fuse kio: create sysfs stat directory fs/fuse kio: implement iostat fs/fuse kio: make common interface pcs_kio_file_list() for listing kio files fs/fuse kio: make common 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 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: add locked cs_get_avg_in_flight() --- fs/fuse/kio/pcs/fuse_stat.c | 82 +++++++++++++++++++++++++++++++++++++++++++++ fs/fuse/kio/pcs/fuse_stat.h | 1 + 2 files changed, 83 insertions(+) diff --git a/fs/fuse/kio/pcs/fuse_stat.c b/fs/fuse/kio/pcs/fuse_stat.c index aa8e70fc9fd6..1b3af5137d14 100644 --- a/fs/fuse/kio/pcs/fuse_stat.c +++ b/fs/fuse/kio/pcs/fuse_stat.c @@ -8,6 +8,25 @@ extern struct super_block *fuse_control_sb; +static const char *fuse_kio_op_name(unsigned opcode) +{ + switch (opcode) { + case FUSE_READ: + return "READ"; + case FUSE_WRITE: + return "WRITE"; + case FUSE_FSYNC: + return "FSYNC"; + case FUSE_FLUSH: + return "FLUSH"; + case FUSE_FALLOCATE: + return "FALLOCATE"; + default: + break; + } + return "UNKNOWN"; +} + static inline void fuse_val_stat_update(struct fuse_val_stat *s, u64 val) { if (!s->events) @@ -65,6 +84,64 @@ static inline unsigned long long fuse_val_cnt_events(struct fuse_val_cnt const* #define CNT_TOTAL(c) fuse_val_cnt_total(&(c)) #define CNT_EVENTS(c) fuse_val_cnt_events(&(c)) + +static void fuse_kio_stat_req_itr(struct fuse_file *ff, struct fuse_req *req, + void *ctx) +{ + struct seq_file *m = ctx; + struct pcs_fuse_req *r = pcs_req_from_fuse(req); + struct pcs_int_request *ireq = &r->exec.ireq; + + seq_printf(m, "%-16s ", fuse_kio_op_name(req->in.h.opcode)); + seq_printf(m, "%-8llu %-8llu ", ktime_to_ms(ktime_sub(ktime_get(), ireq->ts)), req->in.h.unique); + seq_printf(m, "%5u/%-5u %-5u ", 0, atomic_read(&r->exec.ctl.retry_cnt), r->exec.ctl.last_err.value); + seq_printf(m, "%-16s ", pcs_strerror(r->exec.ctl.last_err.value)); + seq_dentry(m, ff->ff_dentry, ""); + seq_putc(m, '\n'); +} + +static int pcs_fuse_requests_show(struct seq_file *m, void *v) +{ + struct inode *inode = m->private; + struct pcs_fuse_stat *stat; + struct fuse_conn *fc; + + if (!inode) + return 0; + + mutex_lock(&fuse_mutex); + stat = inode->i_private; + if (!stat) { + mutex_unlock(&fuse_mutex); + return 0; + } + + seq_printf(m, "# type duration(msec) id stage/retry errno status path\n"); + + fc = container_of(stat, struct pcs_fuse_cluster, cc.stat)->fc; + if (fc) { + spin_lock(&fc->lock); + pcs_kio_req_list(fc, fuse_kio_stat_req_itr, m); + spin_unlock(&fc->lock); + } + mutex_unlock(&fuse_mutex); + + return 0; +} + +static int pcs_fuse_requests_open(struct inode *inode, struct file *file) +{ + return single_open(file, pcs_fuse_requests_show, inode); +} + +static const struct file_operations pcs_fuse_requests_ops = { + .owner = THIS_MODULE, + .open = pcs_fuse_requests_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, +}; + static int pcs_fuse_iostat_show(struct seq_file *m, void *v) { struct inode *inode = m->private; @@ -237,6 +314,9 @@ void pcs_fuse_stat_init(struct pcs_fuse_stat *stat) S_IFREG | S_IRUSR, 1, NULL, &pcs_fuse_iostat_ops, stat); + stat->requests = fuse_kio_add_dentry(stat->kio_stat, fc, "requests", + S_IFREG | S_IRUSR, 1, NULL, + &pcs_fuse_requests_ops, stat); out: mutex_unlock(&fuse_mutex); } @@ -250,6 +330,8 @@ void pcs_fuse_stat_fini(struct pcs_fuse_stat *stat) if (fuse_control_sb) { if (stat->iostat) fuse_kio_rm_dentry(stat->iostat); + if (stat->requests) + fuse_kio_rm_dentry(stat->requests); fuse_kio_rm_dentry(stat->kio_stat); } mutex_unlock(&fuse_mutex); diff --git a/fs/fuse/kio/pcs/fuse_stat.h b/fs/fuse/kio/pcs/fuse_stat.h index d25a4c2c4bd7..a6f3a7abe456 100644 --- a/fs/fuse/kio/pcs/fuse_stat.h +++ b/fs/fuse/kio/pcs/fuse_stat.h @@ -29,6 +29,7 @@ struct pcs_fuse_stat { struct dentry *kio_stat; struct dentry *iostat; + struct dentry *requests; }; void pcs_fuse_stat_init(struct pcs_fuse_stat *stat); _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel