mm: bdi: expose the BDI object in sysfs for FUSE
Register FUSE's backing_dev_info under sysfs with the name "fuse-MAJOR:MINOR" Make the fuse control filesystem use s_dev instead of a fuse specific ID. This makes it easier to match directories under /sys/fs/fuse/connections/ with directories under /sys/class/bdi, and with actual mounts. Signed-off-by: Miklos Szeredi <mszeredi@suse.cz> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
committed by
Linus Torvalds
parent
fa799759f9
commit
b6f2fcbcfc
@@ -117,7 +117,7 @@ int fuse_ctl_add_conn(struct fuse_conn *fc)
|
|||||||
|
|
||||||
parent = fuse_control_sb->s_root;
|
parent = fuse_control_sb->s_root;
|
||||||
inc_nlink(parent->d_inode);
|
inc_nlink(parent->d_inode);
|
||||||
sprintf(name, "%llu", (unsigned long long) fc->id);
|
sprintf(name, "%u", fc->dev);
|
||||||
parent = fuse_ctl_add_dentry(parent, fc, name, S_IFDIR | 0500, 2,
|
parent = fuse_ctl_add_dentry(parent, fc, name, S_IFDIR | 0500, 2,
|
||||||
&simple_dir_inode_operations,
|
&simple_dir_inode_operations,
|
||||||
&simple_dir_operations);
|
&simple_dir_operations);
|
||||||
|
@@ -390,8 +390,8 @@ struct fuse_conn {
|
|||||||
/** Entry on the fuse_conn_list */
|
/** Entry on the fuse_conn_list */
|
||||||
struct list_head entry;
|
struct list_head entry;
|
||||||
|
|
||||||
/** Unique ID */
|
/** Device ID from super block */
|
||||||
u64 id;
|
dev_t dev;
|
||||||
|
|
||||||
/** Dentries in the control filesystem */
|
/** Dentries in the control filesystem */
|
||||||
struct dentry *ctl_dentry[FUSE_CTL_NUM_DENTRIES];
|
struct dentry *ctl_dentry[FUSE_CTL_NUM_DENTRIES];
|
||||||
|
@@ -447,7 +447,7 @@ static int fuse_show_options(struct seq_file *m, struct vfsmount *mnt)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct fuse_conn *new_conn(void)
|
static struct fuse_conn *new_conn(struct super_block *sb)
|
||||||
{
|
{
|
||||||
struct fuse_conn *fc;
|
struct fuse_conn *fc;
|
||||||
int err;
|
int err;
|
||||||
@@ -468,19 +468,26 @@ static struct fuse_conn *new_conn(void)
|
|||||||
atomic_set(&fc->num_waiting, 0);
|
atomic_set(&fc->num_waiting, 0);
|
||||||
fc->bdi.ra_pages = (VM_MAX_READAHEAD * 1024) / PAGE_CACHE_SIZE;
|
fc->bdi.ra_pages = (VM_MAX_READAHEAD * 1024) / PAGE_CACHE_SIZE;
|
||||||
fc->bdi.unplug_io_fn = default_unplug_io_fn;
|
fc->bdi.unplug_io_fn = default_unplug_io_fn;
|
||||||
|
fc->dev = sb->s_dev;
|
||||||
err = bdi_init(&fc->bdi);
|
err = bdi_init(&fc->bdi);
|
||||||
if (err) {
|
if (err)
|
||||||
kfree(fc);
|
goto error_kfree;
|
||||||
fc = NULL;
|
err = bdi_register_dev(&fc->bdi, fc->dev);
|
||||||
goto out;
|
if (err)
|
||||||
}
|
goto error_bdi_destroy;
|
||||||
fc->reqctr = 0;
|
fc->reqctr = 0;
|
||||||
fc->blocked = 1;
|
fc->blocked = 1;
|
||||||
fc->attr_version = 1;
|
fc->attr_version = 1;
|
||||||
get_random_bytes(&fc->scramble_key, sizeof(fc->scramble_key));
|
get_random_bytes(&fc->scramble_key, sizeof(fc->scramble_key));
|
||||||
}
|
}
|
||||||
out:
|
|
||||||
return fc;
|
return fc;
|
||||||
|
|
||||||
|
error_bdi_destroy:
|
||||||
|
bdi_destroy(&fc->bdi);
|
||||||
|
error_kfree:
|
||||||
|
mutex_destroy(&fc->inst_mutex);
|
||||||
|
kfree(fc);
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void fuse_conn_put(struct fuse_conn *fc)
|
void fuse_conn_put(struct fuse_conn *fc)
|
||||||
@@ -578,12 +585,6 @@ static void fuse_send_init(struct fuse_conn *fc, struct fuse_req *req)
|
|||||||
request_send_background(fc, req);
|
request_send_background(fc, req);
|
||||||
}
|
}
|
||||||
|
|
||||||
static u64 conn_id(void)
|
|
||||||
{
|
|
||||||
static u64 ctr = 1;
|
|
||||||
return ctr++;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int fuse_fill_super(struct super_block *sb, void *data, int silent)
|
static int fuse_fill_super(struct super_block *sb, void *data, int silent)
|
||||||
{
|
{
|
||||||
struct fuse_conn *fc;
|
struct fuse_conn *fc;
|
||||||
@@ -621,7 +622,7 @@ static int fuse_fill_super(struct super_block *sb, void *data, int silent)
|
|||||||
if (file->f_op != &fuse_dev_operations)
|
if (file->f_op != &fuse_dev_operations)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
fc = new_conn();
|
fc = new_conn(sb);
|
||||||
if (!fc)
|
if (!fc)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
@@ -659,7 +660,6 @@ static int fuse_fill_super(struct super_block *sb, void *data, int silent)
|
|||||||
if (file->private_data)
|
if (file->private_data)
|
||||||
goto err_unlock;
|
goto err_unlock;
|
||||||
|
|
||||||
fc->id = conn_id();
|
|
||||||
err = fuse_ctl_add_conn(fc);
|
err = fuse_ctl_add_conn(fc);
|
||||||
if (err)
|
if (err)
|
||||||
goto err_unlock;
|
goto err_unlock;
|
||||||
|
Reference in New Issue
Block a user