diff options
author | Miklos Szeredi <mszeredi@suse.cz> | 2008-04-30 03:54:34 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-04-30 11:29:49 -0400 |
commit | b6f2fcbcfca9db2bd7aa24940224fcd3bbdbb8aa (patch) | |
tree | ab70a4e93c1a512f791c3a0f77810c84e2b81ef1 /fs/fuse | |
parent | fa799759f9801137f665dbedda2c0815f1bf6f1b (diff) |
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>
Diffstat (limited to 'fs/fuse')
-rw-r--r-- | fs/fuse/control.c | 2 | ||||
-rw-r--r-- | fs/fuse/fuse_i.h | 4 | ||||
-rw-r--r-- | fs/fuse/inode.c | 30 |
3 files changed, 18 insertions, 18 deletions
diff --git a/fs/fuse/control.c b/fs/fuse/control.c index 105d4a271e07..4f3cab321415 100644 --- a/fs/fuse/control.c +++ b/fs/fuse/control.c | |||
@@ -117,7 +117,7 @@ int fuse_ctl_add_conn(struct fuse_conn *fc) | |||
117 | 117 | ||
118 | parent = fuse_control_sb->s_root; | 118 | parent = fuse_control_sb->s_root; |
119 | inc_nlink(parent->d_inode); | 119 | inc_nlink(parent->d_inode); |
120 | sprintf(name, "%llu", (unsigned long long) fc->id); | 120 | sprintf(name, "%u", fc->dev); |
121 | parent = fuse_ctl_add_dentry(parent, fc, name, S_IFDIR | 0500, 2, | 121 | parent = fuse_ctl_add_dentry(parent, fc, name, S_IFDIR | 0500, 2, |
122 | &simple_dir_inode_operations, | 122 | &simple_dir_inode_operations, |
123 | &simple_dir_operations); | 123 | &simple_dir_operations); |
diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h index 67aaf6ee38ea..c0481e48d161 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h | |||
@@ -390,8 +390,8 @@ struct fuse_conn { | |||
390 | /** Entry on the fuse_conn_list */ | 390 | /** Entry on the fuse_conn_list */ |
391 | struct list_head entry; | 391 | struct list_head entry; |
392 | 392 | ||
393 | /** Unique ID */ | 393 | /** Device ID from super block */ |
394 | u64 id; | 394 | dev_t dev; |
395 | 395 | ||
396 | /** Dentries in the control filesystem */ | 396 | /** Dentries in the control filesystem */ |
397 | struct dentry *ctl_dentry[FUSE_CTL_NUM_DENTRIES]; | 397 | struct dentry *ctl_dentry[FUSE_CTL_NUM_DENTRIES]; |
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c index 4df34da2284a..c4fcfd59cd80 100644 --- a/fs/fuse/inode.c +++ b/fs/fuse/inode.c | |||
@@ -447,7 +447,7 @@ static int fuse_show_options(struct seq_file *m, struct vfsmount *mnt) | |||
447 | return 0; | 447 | return 0; |
448 | } | 448 | } |
449 | 449 | ||
450 | static struct fuse_conn *new_conn(void) | 450 | static struct fuse_conn *new_conn(struct super_block *sb) |
451 | { | 451 | { |
452 | struct fuse_conn *fc; | 452 | struct fuse_conn *fc; |
453 | int err; | 453 | int err; |
@@ -468,19 +468,26 @@ static struct fuse_conn *new_conn(void) | |||
468 | atomic_set(&fc->num_waiting, 0); | 468 | atomic_set(&fc->num_waiting, 0); |
469 | fc->bdi.ra_pages = (VM_MAX_READAHEAD * 1024) / PAGE_CACHE_SIZE; | 469 | fc->bdi.ra_pages = (VM_MAX_READAHEAD * 1024) / PAGE_CACHE_SIZE; |
470 | fc->bdi.unplug_io_fn = default_unplug_io_fn; | 470 | fc->bdi.unplug_io_fn = default_unplug_io_fn; |
471 | fc->dev = sb->s_dev; | ||
471 | err = bdi_init(&fc->bdi); | 472 | err = bdi_init(&fc->bdi); |
472 | if (err) { | 473 | if (err) |
473 | kfree(fc); | 474 | goto error_kfree; |
474 | fc = NULL; | 475 | err = bdi_register_dev(&fc->bdi, fc->dev); |
475 | goto out; | 476 | if (err) |
476 | } | 477 | goto error_bdi_destroy; |
477 | fc->reqctr = 0; | 478 | fc->reqctr = 0; |
478 | fc->blocked = 1; | 479 | fc->blocked = 1; |
479 | fc->attr_version = 1; | 480 | fc->attr_version = 1; |
480 | get_random_bytes(&fc->scramble_key, sizeof(fc->scramble_key)); | 481 | get_random_bytes(&fc->scramble_key, sizeof(fc->scramble_key)); |
481 | } | 482 | } |
482 | out: | ||
483 | return fc; | 483 | return fc; |
484 | |||
485 | error_bdi_destroy: | ||
486 | bdi_destroy(&fc->bdi); | ||
487 | error_kfree: | ||
488 | mutex_destroy(&fc->inst_mutex); | ||
489 | kfree(fc); | ||
490 | return NULL; | ||
484 | } | 491 | } |
485 | 492 | ||
486 | void fuse_conn_put(struct fuse_conn *fc) | 493 | 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) | |||
578 | request_send_background(fc, req); | 585 | request_send_background(fc, req); |
579 | } | 586 | } |
580 | 587 | ||
581 | static u64 conn_id(void) | ||
582 | { | ||
583 | static u64 ctr = 1; | ||
584 | return ctr++; | ||
585 | } | ||
586 | |||
587 | static int fuse_fill_super(struct super_block *sb, void *data, int silent) | 588 | static int fuse_fill_super(struct super_block *sb, void *data, int silent) |
588 | { | 589 | { |
589 | struct fuse_conn *fc; | 590 | struct fuse_conn *fc; |
@@ -621,7 +622,7 @@ static int fuse_fill_super(struct super_block *sb, void *data, int silent) | |||
621 | if (file->f_op != &fuse_dev_operations) | 622 | if (file->f_op != &fuse_dev_operations) |
622 | return -EINVAL; | 623 | return -EINVAL; |
623 | 624 | ||
624 | fc = new_conn(); | 625 | fc = new_conn(sb); |
625 | if (!fc) | 626 | if (!fc) |
626 | return -ENOMEM; | 627 | return -ENOMEM; |
627 | 628 | ||
@@ -659,7 +660,6 @@ static int fuse_fill_super(struct super_block *sb, void *data, int silent) | |||
659 | if (file->private_data) | 660 | if (file->private_data) |
660 | goto err_unlock; | 661 | goto err_unlock; |
661 | 662 | ||
662 | fc->id = conn_id(); | ||
663 | err = fuse_ctl_add_conn(fc); | 663 | err = fuse_ctl_add_conn(fc); |
664 | if (err) | 664 | if (err) |
665 | goto err_unlock; | 665 | goto err_unlock; |