[v2,2/2] fs/fuse kio_pcs: check fuse_conn args

Submitted by Pavel Butsykin on May 17, 2018, 3:05 p.m.

Details

Message ID 20180517150515.28911-3-pbutsykin@virtuozzo.com
State New
Series "kpcs_probe: check fuse_conn args"
Headers show

Commit Message

Pavel Butsykin May 17, 2018, 3:05 p.m.
Allow initialization of kdirect only for vstorage/pstorage.

Signed-off-by: Pavel Butsykin <pbutsykin@virtuozzo.com>
---
 drivers/block/ploop/dev.c          | 4 ----
 fs/fuse/kio/pcs/pcs_fuse_kdirect.c | 9 ++++-----
 include/linux/fs.h                 | 5 +++++
 3 files changed, 9 insertions(+), 9 deletions(-)

Patch hide | download patch | download mbox

diff --git a/drivers/block/ploop/dev.c b/drivers/block/ploop/dev.c
index 0e72656ec8f9..c6094144c7a5 100644
--- a/drivers/block/ploop/dev.c
+++ b/drivers/block/ploop/dev.c
@@ -3880,10 +3880,6 @@  static int ploop_truncate(struct ploop_device * plo, unsigned long arg)
 	return err;
 }
 
-#define IS_PSTORAGE(sb) (sb->s_magic == FUSE_SUPER_MAGIC && \
-			 (!strcmp(sb->s_subtype, "pstorage") || \
-			  !strcmp(sb->s_subtype, "vstorage")))
-
 static int ploop_bd_full(struct backing_dev_info *bdi, long long nr, int root)
 {
 	struct ploop_device *plo      = bdi->congested_data;
diff --git a/fs/fuse/kio/pcs/pcs_fuse_kdirect.c b/fs/fuse/kio/pcs/pcs_fuse_kdirect.c
index b8503d55e246..3c8ab64c5fc1 100644
--- a/fs/fuse/kio/pcs/pcs_fuse_kdirect.c
+++ b/fs/fuse/kio/pcs/pcs_fuse_kdirect.c
@@ -144,16 +144,15 @@  void kpcs_conn_abort(struct fuse_conn *fc)
 }
 
 static int kpcs_probe(struct fuse_conn *fc, char *name)
-
 {
-	printk("%s TODO IMPLEMENT check fuse_conn args here!\n", __FUNCTION__);
-	if (!strncmp(name, kio_pcs_ops.name, FUSE_KIO_NAME))
+	if (IS_PSTORAGE(fc->sb))
 		return 1;
 
+	pr_err("FUSE: kio_pcs: kdirect is only available for"
+	       "pstorage/vstorage fuse mount\n");
 	return 0;
 }
 
-
 static int fuse_pcs_getfileinfo(struct fuse_conn *fc, struct file *file,
 				struct pcs_mds_fileinfo *info)
 {
@@ -1202,7 +1201,7 @@  err:
 static struct fuse_kio_ops kio_pcs_ops = {
 	.name		= "pcs",
 	.owner		= THIS_MODULE,
-	.probe		= kpcs_probe, /*TODO: check sb->dev name */
+	.probe		= kpcs_probe,
 
 	.conn_init	= kpcs_conn_init,
 	.conn_fini	= kpcs_conn_fini,
diff --git a/include/linux/fs.h b/include/linux/fs.h
index a1dc3521f979..21770550b6c1 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1713,6 +1713,11 @@  struct super_block {
 	struct list_lru		s_inode_lru ____cacheline_aligned_in_smp;
 };
 
+#define IS_PSTORAGE(sb) ((sb)->s_magic == FUSE_SUPER_MAGIC && \
+			 (sb)->s_subtype && \
+			 (!strcmp((sb)->s_subtype, "pstorage") || \
+			  !strcmp((sb)->s_subtype, "vstorage")))
+
 extern const unsigned super_block_wrapper_version;
 struct super_block_wrapper {
 	struct super_block sb;