[PATCH 48/52] virtio-fs: pass version table pointer to fuse

Vivek Goyal
2018-12-10T17:13:14Z

From: Miklos Szeredi <mszeredi@redhat.com>

Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
---
fs/fuse/fuse_i.h | 12 ++++++++++++
fs/fuse/inode.c | 10 ++++++++++
fs/fuse/virtio_fs.c | 2 ++
3 files changed, 24 insertions(+)

diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
index 30c7b4b56200..8a2604606d51 100644
--- a/fs/fuse/fuse_i.h
+++ b/fs/fuse/fuse_i.h
@@ -100,6 +100,12 @@ struct fuse_mount_data {

/* fuse_dev pointer to fill in, should contain NULL on entry */
void **fudptr;
+
+ /* version table length in bytes */
+ size_t vertab_len;
+
+ /* version table kernel address */
+ void *vertab_kaddr;
};

/* One forget request */
@@ -898,6 +904,12 @@ struct fuse_conn {
struct list_head free_ranges;

unsigned long nr_ranges;
+
+ /** Size of version table */
+ uint64_t version_table_size;
+
+ /** Shared version entry for each active inode */
+ s64 *version_table;
};

static inline struct fuse_conn *get_fuse_conn_super(struct super_block *sb)
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
index 4d2d623e607f..1ab4df442390 100644
--- a/fs/fuse/inode.c
+++ b/fs/fuse/inode.c
@@ -52,6 +52,7 @@ MODULE_PARM_DESC(max_user_congthresh,
"unprivileged user can set");

#define FUSE_SUPER_MAGIC 0x65735546
+#define VERSION_TABLE_MAGIC 0x7265566465726853

#define FUSE_DEFAULT_BLKSIZE 512

@@ -1215,6 +1216,15 @@ int fuse_fill_super_common(struct super_block *sb,
fuse_conn_init(fc, sb->s_user_ns, mount_data->dax_dev,
mount_data->fiq_ops, mount_data->fiq_priv);
fc->release = fuse_free_conn;
+ fc->version_table_size = mount_data->vertab_len / sizeof(s64);
+ fc->version_table = mount_data->vertab_kaddr;
+
+ if (fc->version_table[0] != VERSION_TABLE_MAGIC) {
+ pr_warn("bad version table magic: 0x%16llx\n",
+ fc->version_table[0]);
+ fc->version_table_size = 0;
+ fc->version_table = NULL;
+ }

if (mount_data->dax_dev) {
err = fuse_dax_mem_range_init(fc, mount_data->dax_dev);
diff --git a/fs/fuse/virtio_fs.c b/fs/fuse/virtio_fs.c
index 7d5b23455639..88b00055589b 100644
--- a/fs/fuse/virtio_fs.c
+++ b/fs/fuse/virtio_fs.c
@@ -1246,6 +1246,8 @@ static int virtio_fs_fill_super(struct super_block *sb, void *data,
d.fiq_priv = fs;
d.fudptr = (void **)&fs->vqs[2].fud;
d.destroy = true; /* Send destroy request on unmount */
+ d.vertab_len = fs->vertab_len;
+ d.vertab_kaddr = fs->vertab_kaddr;
err = fuse_fill_super_common(sb, &d);

if (err < 0)
--
2.13.6