[04/15] fs/fuse kio: make interface pcs_kio_file_list() for listing kio files

Submitted by Pavel Butsykin on May 17, 2019, 1:20 p.m.

Details

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

Commit Message

Pavel Butsykin May 17, 2019, 1:20 p.m.
This is a preparation patch that implements common interface
pcs_kio_file_list(), which will be needed to collect kio files statistics.

Signed-off-by: Pavel Butsykin <pbutsykin@virtuozzo.com>
---
 fs/fuse/kio/pcs/pcs_fuse_kdirect.c | 22 +++++++++++++++++-----
 fs/fuse/kio/pcs/pcs_req.h          |  5 +++++
 2 files changed, 22 insertions(+), 5 deletions(-)

Patch hide | download patch | download mbox

diff --git a/fs/fuse/kio/pcs/pcs_fuse_kdirect.c b/fs/fuse/kio/pcs/pcs_fuse_kdirect.c
index 75bd8c6b91bc..2060ef3b1fc4 100644
--- a/fs/fuse/kio/pcs/pcs_fuse_kdirect.c
+++ b/fs/fuse/kio/pcs/pcs_fuse_kdirect.c
@@ -1511,7 +1511,7 @@  void __kfuse_trace(struct fuse_conn * fc, unsigned long ip, const char * fmt, ..
 	put_cpu();
 }
 
-static void kpcs_kill_requests(struct fuse_conn *fc, struct inode *inode)
+void pcs_kio_file_list(struct fuse_conn *fc, kio_file_itr kfile_cb, void *ctx)
 {
 	struct fuse_file *ff;
 
@@ -1529,13 +1529,25 @@  static void kpcs_kill_requests(struct fuse_conn *fc, struct inode *inode)
 			continue;
 
 		di = pcs_inode_from_fuse(fi);
-
-		spin_lock(&di->kq_lock);
-		fuse_kill_requests(fc, inode, &di->kq);
-		spin_unlock(&di->kq_lock);
+		kfile_cb(ff, di, ctx);
 	}
 }
 
+static void kpcs_kill_lreq_itr(struct fuse_file *ff, struct pcs_dentry_info *di,
+			       void *ctx)
+{
+	struct inode *inode = ctx;
+
+	spin_lock(&di->kq_lock);
+	fuse_kill_requests(ff->fc, inode, &di->kq);
+	spin_unlock(&di->kq_lock);
+}
+
+static void kpcs_kill_requests(struct fuse_conn *fc, struct inode *inode)
+{
+	pcs_kio_file_list(fc, kpcs_kill_lreq_itr, inode);
+}
+
 static struct fuse_kio_ops kio_pcs_ops = {
 	.name		= "pcs",
 	.owner		= THIS_MODULE,
diff --git a/fs/fuse/kio/pcs/pcs_req.h b/fs/fuse/kio/pcs/pcs_req.h
index 3a9534b1a5af..a1c7e372f297 100644
--- a/fs/fuse/kio/pcs/pcs_req.h
+++ b/fs/fuse/kio/pcs/pcs_req.h
@@ -9,6 +9,7 @@ 
 #include "pcs_rpc.h"
 #include "pcs_cs.h"
 #include "fuse_stat.h"
+#include "../../fuse_i.h"
 
 ///////////////////////////
 
@@ -328,4 +329,8 @@  void pcs_process_ireq(struct pcs_int_request *ireq);
 
 void pcs_ireq_queue_fail(struct list_head *queue, int error);
 
+typedef void (*kio_file_itr)(struct fuse_file *ff, struct pcs_dentry_info *di,
+			     void *ctx);
+void pcs_kio_file_list(struct fuse_conn *fc, kio_file_itr kfile_cb, void *ctx);
+
 #endif /* _PCS_REQ_H_ */