diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2011-07-07 15:44:25 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2011-07-20 01:44:20 -0400 |
commit | 0ee5dc676a5f8fadede608c7281dfedb1ae714ea (patch) | |
tree | 887896f0e1b51f39e9be21a1e8d960ec50a817a7 | |
parent | fb408e6ccc32404a05783911b6f3fed56bd17b06 (diff) |
btrfs: kill magical embedded struct superblock
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r-- | fs/btrfs/ctree.h | 2 | ||||
-rw-r--r-- | fs/btrfs/disk-io.c | 15 | ||||
-rw-r--r-- | fs/btrfs/inode.c | 2 | ||||
-rw-r--r-- | fs/super.c | 32 | ||||
-rw-r--r-- | include/linux/fs.h | 2 |
5 files changed, 31 insertions, 22 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 9864cec801ed..9552afc24ef7 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h | |||
@@ -1219,7 +1219,7 @@ struct btrfs_root { | |||
1219 | * right now this just gets used so that a root has its own devid | 1219 | * right now this just gets used so that a root has its own devid |
1220 | * for stat. It may be used for more later | 1220 | * for stat. It may be used for more later |
1221 | */ | 1221 | */ |
1222 | struct super_block anon_super; | 1222 | dev_t anon_dev; |
1223 | }; | 1223 | }; |
1224 | 1224 | ||
1225 | struct btrfs_ioctl_defrag_range_args { | 1225 | struct btrfs_ioctl_defrag_range_args { |
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 1ac8db5dc0a3..b231ae13b269 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c | |||
@@ -1077,12 +1077,7 @@ static int __setup_root(u32 nodesize, u32 leafsize, u32 sectorsize, | |||
1077 | init_completion(&root->kobj_unregister); | 1077 | init_completion(&root->kobj_unregister); |
1078 | root->defrag_running = 0; | 1078 | root->defrag_running = 0; |
1079 | root->root_key.objectid = objectid; | 1079 | root->root_key.objectid = objectid; |
1080 | root->anon_super.s_root = NULL; | 1080 | root->anon_dev = 0; |
1081 | root->anon_super.s_dev = 0; | ||
1082 | INIT_LIST_HEAD(&root->anon_super.s_list); | ||
1083 | INIT_LIST_HEAD(&root->anon_super.s_instances); | ||
1084 | init_rwsem(&root->anon_super.s_umount); | ||
1085 | |||
1086 | return 0; | 1081 | return 0; |
1087 | } | 1082 | } |
1088 | 1083 | ||
@@ -1311,7 +1306,7 @@ again: | |||
1311 | spin_lock_init(&root->cache_lock); | 1306 | spin_lock_init(&root->cache_lock); |
1312 | init_waitqueue_head(&root->cache_wait); | 1307 | init_waitqueue_head(&root->cache_wait); |
1313 | 1308 | ||
1314 | ret = set_anon_super(&root->anon_super, NULL); | 1309 | ret = get_anon_bdev(&root->anon_dev); |
1315 | if (ret) | 1310 | if (ret) |
1316 | goto fail; | 1311 | goto fail; |
1317 | 1312 | ||
@@ -2393,10 +2388,8 @@ static void free_fs_root(struct btrfs_root *root) | |||
2393 | { | 2388 | { |
2394 | iput(root->cache_inode); | 2389 | iput(root->cache_inode); |
2395 | WARN_ON(!RB_EMPTY_ROOT(&root->inode_tree)); | 2390 | WARN_ON(!RB_EMPTY_ROOT(&root->inode_tree)); |
2396 | if (root->anon_super.s_dev) { | 2391 | if (root->anon_dev) |
2397 | down_write(&root->anon_super.s_umount); | 2392 | free_anon_bdev(root->anon_dev); |
2398 | kill_anon_super(&root->anon_super); | ||
2399 | } | ||
2400 | free_extent_buffer(root->node); | 2393 | free_extent_buffer(root->node); |
2401 | free_extent_buffer(root->commit_root); | 2394 | free_extent_buffer(root->commit_root); |
2402 | kfree(root->free_ino_ctl); | 2395 | kfree(root->free_ino_ctl); |
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index cb170ca51c64..ecf0fac712d6 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
@@ -6900,7 +6900,7 @@ static int btrfs_getattr(struct vfsmount *mnt, | |||
6900 | { | 6900 | { |
6901 | struct inode *inode = dentry->d_inode; | 6901 | struct inode *inode = dentry->d_inode; |
6902 | generic_fillattr(inode, stat); | 6902 | generic_fillattr(inode, stat); |
6903 | stat->dev = BTRFS_I(inode)->root->anon_super.s_dev; | 6903 | stat->dev = BTRFS_I(inode)->root->anon_dev; |
6904 | stat->blksize = PAGE_CACHE_SIZE; | 6904 | stat->blksize = PAGE_CACHE_SIZE; |
6905 | stat->blocks = (inode_get_bytes(inode) + | 6905 | stat->blocks = (inode_get_bytes(inode) + |
6906 | BTRFS_I(inode)->delalloc_bytes) >> 9; | 6906 | BTRFS_I(inode)->delalloc_bytes) >> 9; |
diff --git a/fs/super.c b/fs/super.c index 444da9579068..263edeb9f0e9 100644 --- a/fs/super.c +++ b/fs/super.c | |||
@@ -693,7 +693,7 @@ static DEFINE_IDA(unnamed_dev_ida); | |||
693 | static DEFINE_SPINLOCK(unnamed_dev_lock);/* protects the above */ | 693 | static DEFINE_SPINLOCK(unnamed_dev_lock);/* protects the above */ |
694 | static int unnamed_dev_start = 0; /* don't bother trying below it */ | 694 | static int unnamed_dev_start = 0; /* don't bother trying below it */ |
695 | 695 | ||
696 | int set_anon_super(struct super_block *s, void *data) | 696 | int get_anon_bdev(dev_t *p) |
697 | { | 697 | { |
698 | int dev; | 698 | int dev; |
699 | int error; | 699 | int error; |
@@ -720,24 +720,38 @@ int set_anon_super(struct super_block *s, void *data) | |||
720 | spin_unlock(&unnamed_dev_lock); | 720 | spin_unlock(&unnamed_dev_lock); |
721 | return -EMFILE; | 721 | return -EMFILE; |
722 | } | 722 | } |
723 | s->s_dev = MKDEV(0, dev & MINORMASK); | 723 | *p = MKDEV(0, dev & MINORMASK); |
724 | s->s_bdi = &noop_backing_dev_info; | ||
725 | return 0; | 724 | return 0; |
726 | } | 725 | } |
726 | EXPORT_SYMBOL(get_anon_bdev); | ||
727 | 727 | ||
728 | EXPORT_SYMBOL(set_anon_super); | 728 | void free_anon_bdev(dev_t dev) |
729 | |||
730 | void kill_anon_super(struct super_block *sb) | ||
731 | { | 729 | { |
732 | int slot = MINOR(sb->s_dev); | 730 | int slot = MINOR(dev); |
733 | |||
734 | generic_shutdown_super(sb); | ||
735 | spin_lock(&unnamed_dev_lock); | 731 | spin_lock(&unnamed_dev_lock); |
736 | ida_remove(&unnamed_dev_ida, slot); | 732 | ida_remove(&unnamed_dev_ida, slot); |
737 | if (slot < unnamed_dev_start) | 733 | if (slot < unnamed_dev_start) |
738 | unnamed_dev_start = slot; | 734 | unnamed_dev_start = slot; |
739 | spin_unlock(&unnamed_dev_lock); | 735 | spin_unlock(&unnamed_dev_lock); |
740 | } | 736 | } |
737 | EXPORT_SYMBOL(free_anon_bdev); | ||
738 | |||
739 | int set_anon_super(struct super_block *s, void *data) | ||
740 | { | ||
741 | int error = get_anon_bdev(&s->s_dev); | ||
742 | if (!error) | ||
743 | s->s_bdi = &noop_backing_dev_info; | ||
744 | return error; | ||
745 | } | ||
746 | |||
747 | EXPORT_SYMBOL(set_anon_super); | ||
748 | |||
749 | void kill_anon_super(struct super_block *sb) | ||
750 | { | ||
751 | dev_t dev = sb->s_dev; | ||
752 | generic_shutdown_super(sb); | ||
753 | free_anon_bdev(dev); | ||
754 | } | ||
741 | 755 | ||
742 | EXPORT_SYMBOL(kill_anon_super); | 756 | EXPORT_SYMBOL(kill_anon_super); |
743 | 757 | ||
diff --git a/include/linux/fs.h b/include/linux/fs.h index 8494aac189f0..a0011aef4338 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h | |||
@@ -1835,6 +1835,8 @@ void kill_litter_super(struct super_block *sb); | |||
1835 | void deactivate_super(struct super_block *sb); | 1835 | void deactivate_super(struct super_block *sb); |
1836 | void deactivate_locked_super(struct super_block *sb); | 1836 | void deactivate_locked_super(struct super_block *sb); |
1837 | int set_anon_super(struct super_block *s, void *data); | 1837 | int set_anon_super(struct super_block *s, void *data); |
1838 | int get_anon_bdev(dev_t *); | ||
1839 | void free_anon_bdev(dev_t); | ||
1838 | struct super_block *sget(struct file_system_type *type, | 1840 | struct super_block *sget(struct file_system_type *type, |
1839 | int (*test)(struct super_block *,void *), | 1841 | int (*test)(struct super_block *,void *), |
1840 | int (*set)(struct super_block *,void *), | 1842 | int (*set)(struct super_block *,void *), |