Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Miklos Szeredi and committed by
Linus Torvalds
b6f2fcbc fa799759

+18 -18
+1 -1
fs/fuse/control.c
··· 117 117 118 118 parent = fuse_control_sb->s_root; 119 119 inc_nlink(parent->d_inode); 120 - sprintf(name, "%llu", (unsigned long long) fc->id); 120 + sprintf(name, "%u", fc->dev); 121 121 parent = fuse_ctl_add_dentry(parent, fc, name, S_IFDIR | 0500, 2, 122 122 &simple_dir_inode_operations, 123 123 &simple_dir_operations);
+2 -2
fs/fuse/fuse_i.h
··· 390 390 /** Entry on the fuse_conn_list */ 391 391 struct list_head entry; 392 392 393 - /** Unique ID */ 394 - u64 id; 393 + /** Device ID from super block */ 394 + dev_t dev; 395 395 396 396 /** Dentries in the control filesystem */ 397 397 struct dentry *ctl_dentry[FUSE_CTL_NUM_DENTRIES];
+15 -15
fs/fuse/inode.c
··· 447 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 452 struct fuse_conn *fc; 453 453 int err; ··· 468 468 atomic_set(&fc->num_waiting, 0); 469 469 fc->bdi.ra_pages = (VM_MAX_READAHEAD * 1024) / PAGE_CACHE_SIZE; 470 470 fc->bdi.unplug_io_fn = default_unplug_io_fn; 471 + fc->dev = sb->s_dev; 471 472 err = bdi_init(&fc->bdi); 472 - if (err) { 473 - kfree(fc); 474 - fc = NULL; 475 - goto out; 476 - } 473 + if (err) 474 + goto error_kfree; 475 + err = bdi_register_dev(&fc->bdi, fc->dev); 476 + if (err) 477 + goto error_bdi_destroy; 477 478 fc->reqctr = 0; 478 479 fc->blocked = 1; 479 480 fc->attr_version = 1; 480 481 get_random_bytes(&fc->scramble_key, sizeof(fc->scramble_key)); 481 482 } 482 - out: 483 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 493 void fuse_conn_put(struct fuse_conn *fc) ··· 585 578 request_send_background(fc, req); 586 579 } 587 580 588 - static u64 conn_id(void) 589 - { 590 - static u64 ctr = 1; 591 - return ctr++; 592 - } 593 - 594 581 static int fuse_fill_super(struct super_block *sb, void *data, int silent) 595 582 { 596 583 struct fuse_conn *fc; ··· 622 621 if (file->f_op != &fuse_dev_operations) 623 622 return -EINVAL; 624 623 625 - fc = new_conn(); 624 + fc = new_conn(sb); 626 625 if (!fc) 627 626 return -ENOMEM; 628 627 ··· 660 659 if (file->private_data) 661 660 goto err_unlock; 662 661 663 - fc->id = conn_id(); 664 662 err = fuse_ctl_add_conn(fc); 665 663 if (err) 666 664 goto err_unlock;