diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2011-11-17 15:40:49 -0500 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2012-01-08 19:35:37 -0500 |
commit | 815745cf3e46681241ad8025602ffbf2a452d514 (patch) | |
tree | 7902ae81b199b383b5552e71b6d1cd21aff17fdb /fs/btrfs/super.c | |
parent | 59553edf110e5576d91be9dd5bd53d110e0d0290 (diff) |
btrfs: let ->s_fs_info point to fs_info, not root...
the latter can be obtained from the former (by looking as ->tree_root)
just as cheaply as we currently are doing the other way round.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/btrfs/super.c')
-rw-r--r-- | fs/btrfs/super.c | 75 |
1 files changed, 38 insertions, 37 deletions
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index 15c8ae571e40..305adf6dc09a 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c | |||
@@ -147,7 +147,7 @@ void __btrfs_std_error(struct btrfs_fs_info *fs_info, const char *function, | |||
147 | 147 | ||
148 | static void btrfs_put_super(struct super_block *sb) | 148 | static void btrfs_put_super(struct super_block *sb) |
149 | { | 149 | { |
150 | (void)close_ctree(btrfs_sb(sb)); | 150 | (void)close_ctree(btrfs_sb(sb)->tree_root); |
151 | /* FIXME: need to fix VFS to return error? */ | 151 | /* FIXME: need to fix VFS to return error? */ |
152 | /* AV: return it _where_? ->put_super() can be triggered by any number | 152 | /* AV: return it _where_? ->put_super() can be triggered by any number |
153 | * of async events, up to and including delivery of SIGKILL to the | 153 | * of async events, up to and including delivery of SIGKILL to the |
@@ -500,7 +500,8 @@ out: | |||
500 | static struct dentry *get_default_root(struct super_block *sb, | 500 | static struct dentry *get_default_root(struct super_block *sb, |
501 | u64 subvol_objectid) | 501 | u64 subvol_objectid) |
502 | { | 502 | { |
503 | struct btrfs_root *root = sb->s_fs_info; | 503 | struct btrfs_fs_info *fs_info = btrfs_sb(sb); |
504 | struct btrfs_root *root = fs_info->tree_root; | ||
504 | struct btrfs_root *new_root; | 505 | struct btrfs_root *new_root; |
505 | struct btrfs_dir_item *di; | 506 | struct btrfs_dir_item *di; |
506 | struct btrfs_path *path; | 507 | struct btrfs_path *path; |
@@ -530,7 +531,7 @@ static struct dentry *get_default_root(struct super_block *sb, | |||
530 | * will mount by default if we haven't been given a specific subvolume | 531 | * will mount by default if we haven't been given a specific subvolume |
531 | * to mount. | 532 | * to mount. |
532 | */ | 533 | */ |
533 | dir_id = btrfs_super_root_dir(root->fs_info->super_copy); | 534 | dir_id = btrfs_super_root_dir(fs_info->super_copy); |
534 | di = btrfs_lookup_dir_item(NULL, root, path, dir_id, "default", 7, 0); | 535 | di = btrfs_lookup_dir_item(NULL, root, path, dir_id, "default", 7, 0); |
535 | if (IS_ERR(di)) { | 536 | if (IS_ERR(di)) { |
536 | btrfs_free_path(path); | 537 | btrfs_free_path(path); |
@@ -544,7 +545,7 @@ static struct dentry *get_default_root(struct super_block *sb, | |||
544 | */ | 545 | */ |
545 | btrfs_free_path(path); | 546 | btrfs_free_path(path); |
546 | dir_id = BTRFS_FIRST_FREE_OBJECTID; | 547 | dir_id = BTRFS_FIRST_FREE_OBJECTID; |
547 | new_root = root->fs_info->fs_root; | 548 | new_root = fs_info->fs_root; |
548 | goto setup_root; | 549 | goto setup_root; |
549 | } | 550 | } |
550 | 551 | ||
@@ -552,7 +553,7 @@ static struct dentry *get_default_root(struct super_block *sb, | |||
552 | btrfs_free_path(path); | 553 | btrfs_free_path(path); |
553 | 554 | ||
554 | find_root: | 555 | find_root: |
555 | new_root = btrfs_read_fs_root_no_name(root->fs_info, &location); | 556 | new_root = btrfs_read_fs_root_no_name(fs_info, &location); |
556 | if (IS_ERR(new_root)) | 557 | if (IS_ERR(new_root)) |
557 | return ERR_CAST(new_root); | 558 | return ERR_CAST(new_root); |
558 | 559 | ||
@@ -588,8 +589,7 @@ static int btrfs_fill_super(struct super_block *sb, | |||
588 | { | 589 | { |
589 | struct inode *inode; | 590 | struct inode *inode; |
590 | struct dentry *root_dentry; | 591 | struct dentry *root_dentry; |
591 | struct btrfs_root *tree_root = sb->s_fs_info; | 592 | struct btrfs_fs_info *fs_info = btrfs_sb(sb); |
592 | struct btrfs_fs_info *fs_info = tree_root->fs_info; | ||
593 | struct btrfs_key key; | 593 | struct btrfs_key key; |
594 | int err; | 594 | int err; |
595 | 595 | ||
@@ -634,20 +634,21 @@ static int btrfs_fill_super(struct super_block *sb, | |||
634 | return 0; | 634 | return 0; |
635 | 635 | ||
636 | fail_close: | 636 | fail_close: |
637 | close_ctree(tree_root); | 637 | close_ctree(fs_info->tree_root); |
638 | return err; | 638 | return err; |
639 | } | 639 | } |
640 | 640 | ||
641 | int btrfs_sync_fs(struct super_block *sb, int wait) | 641 | int btrfs_sync_fs(struct super_block *sb, int wait) |
642 | { | 642 | { |
643 | struct btrfs_trans_handle *trans; | 643 | struct btrfs_trans_handle *trans; |
644 | struct btrfs_root *root = btrfs_sb(sb); | 644 | struct btrfs_fs_info *fs_info = btrfs_sb(sb); |
645 | struct btrfs_root *root = fs_info->tree_root; | ||
645 | int ret; | 646 | int ret; |
646 | 647 | ||
647 | trace_btrfs_sync_fs(wait); | 648 | trace_btrfs_sync_fs(wait); |
648 | 649 | ||
649 | if (!wait) { | 650 | if (!wait) { |
650 | filemap_flush(root->fs_info->btree_inode->i_mapping); | 651 | filemap_flush(fs_info->btree_inode->i_mapping); |
651 | return 0; | 652 | return 0; |
652 | } | 653 | } |
653 | 654 | ||
@@ -663,8 +664,8 @@ int btrfs_sync_fs(struct super_block *sb, int wait) | |||
663 | 664 | ||
664 | static int btrfs_show_options(struct seq_file *seq, struct dentry *dentry) | 665 | static int btrfs_show_options(struct seq_file *seq, struct dentry *dentry) |
665 | { | 666 | { |
666 | struct btrfs_root *root = btrfs_sb(dentry->d_sb); | 667 | struct btrfs_fs_info *info = btrfs_sb(dentry->d_sb); |
667 | struct btrfs_fs_info *info = root->fs_info; | 668 | struct btrfs_root *root = info->tree_root; |
668 | char *compress_type; | 669 | char *compress_type; |
669 | 670 | ||
670 | if (btrfs_test_opt(root, DEGRADED)) | 671 | if (btrfs_test_opt(root, DEGRADED)) |
@@ -727,10 +728,10 @@ static int btrfs_show_options(struct seq_file *seq, struct dentry *dentry) | |||
727 | 728 | ||
728 | static int btrfs_test_super(struct super_block *s, void *data) | 729 | static int btrfs_test_super(struct super_block *s, void *data) |
729 | { | 730 | { |
730 | struct btrfs_root *test_root = data; | 731 | struct btrfs_fs_info *p = data; |
731 | struct btrfs_root *root = btrfs_sb(s); | 732 | struct btrfs_fs_info *fs_info = btrfs_sb(s); |
732 | 733 | ||
733 | return root->fs_info->fs_devices == test_root->fs_info->fs_devices; | 734 | return fs_info->fs_devices == p->fs_devices; |
734 | } | 735 | } |
735 | 736 | ||
736 | static int btrfs_set_super(struct super_block *s, void *data) | 737 | static int btrfs_set_super(struct super_block *s, void *data) |
@@ -922,8 +923,7 @@ static struct dentry *btrfs_mount(struct file_system_type *fs_type, int flags, | |||
922 | } | 923 | } |
923 | 924 | ||
924 | bdev = fs_devices->latest_bdev; | 925 | bdev = fs_devices->latest_bdev; |
925 | s = sget(fs_type, btrfs_test_super, btrfs_set_super, | 926 | s = sget(fs_type, btrfs_test_super, btrfs_set_super, fs_info); |
926 | fs_info->tree_root); | ||
927 | if (IS_ERR(s)) { | 927 | if (IS_ERR(s)) { |
928 | error = PTR_ERR(s); | 928 | error = PTR_ERR(s); |
929 | goto error_close_devices; | 929 | goto error_close_devices; |
@@ -939,7 +939,7 @@ static struct dentry *btrfs_mount(struct file_system_type *fs_type, int flags, | |||
939 | 939 | ||
940 | s->s_flags = flags | MS_NOSEC; | 940 | s->s_flags = flags | MS_NOSEC; |
941 | strlcpy(s->s_id, bdevname(bdev, b), sizeof(s->s_id)); | 941 | strlcpy(s->s_id, bdevname(bdev, b), sizeof(s->s_id)); |
942 | btrfs_sb(s)->fs_info->bdev_holder = fs_type; | 942 | btrfs_sb(s)->bdev_holder = fs_type; |
943 | error = btrfs_fill_super(s, fs_devices, data, | 943 | error = btrfs_fill_super(s, fs_devices, data, |
944 | flags & MS_SILENT ? 1 : 0); | 944 | flags & MS_SILENT ? 1 : 0); |
945 | } | 945 | } |
@@ -959,7 +959,8 @@ error_fs_info: | |||
959 | 959 | ||
960 | static int btrfs_remount(struct super_block *sb, int *flags, char *data) | 960 | static int btrfs_remount(struct super_block *sb, int *flags, char *data) |
961 | { | 961 | { |
962 | struct btrfs_root *root = btrfs_sb(sb); | 962 | struct btrfs_fs_info *fs_info = btrfs_sb(sb); |
963 | struct btrfs_root *root = fs_info->tree_root; | ||
963 | int ret; | 964 | int ret; |
964 | 965 | ||
965 | ret = btrfs_parse_options(root, data); | 966 | ret = btrfs_parse_options(root, data); |
@@ -975,13 +976,13 @@ static int btrfs_remount(struct super_block *sb, int *flags, char *data) | |||
975 | ret = btrfs_commit_super(root); | 976 | ret = btrfs_commit_super(root); |
976 | WARN_ON(ret); | 977 | WARN_ON(ret); |
977 | } else { | 978 | } else { |
978 | if (root->fs_info->fs_devices->rw_devices == 0) | 979 | if (fs_info->fs_devices->rw_devices == 0) |
979 | return -EACCES; | 980 | return -EACCES; |
980 | 981 | ||
981 | if (btrfs_super_log_root(root->fs_info->super_copy) != 0) | 982 | if (btrfs_super_log_root(fs_info->super_copy) != 0) |
982 | return -EINVAL; | 983 | return -EINVAL; |
983 | 984 | ||
984 | ret = btrfs_cleanup_fs_roots(root->fs_info); | 985 | ret = btrfs_cleanup_fs_roots(fs_info); |
985 | WARN_ON(ret); | 986 | WARN_ON(ret); |
986 | 987 | ||
987 | /* recover relocation */ | 988 | /* recover relocation */ |
@@ -1150,18 +1151,18 @@ static int btrfs_calc_avail_data_space(struct btrfs_root *root, u64 *free_bytes) | |||
1150 | 1151 | ||
1151 | static int btrfs_statfs(struct dentry *dentry, struct kstatfs *buf) | 1152 | static int btrfs_statfs(struct dentry *dentry, struct kstatfs *buf) |
1152 | { | 1153 | { |
1153 | struct btrfs_root *root = btrfs_sb(dentry->d_sb); | 1154 | struct btrfs_fs_info *fs_info = btrfs_sb(dentry->d_sb); |
1154 | struct btrfs_super_block *disk_super = root->fs_info->super_copy; | 1155 | struct btrfs_super_block *disk_super = fs_info->super_copy; |
1155 | struct list_head *head = &root->fs_info->space_info; | 1156 | struct list_head *head = &fs_info->space_info; |
1156 | struct btrfs_space_info *found; | 1157 | struct btrfs_space_info *found; |
1157 | u64 total_used = 0; | 1158 | u64 total_used = 0; |
1158 | u64 total_free_data = 0; | 1159 | u64 total_free_data = 0; |
1159 | int bits = dentry->d_sb->s_blocksize_bits; | 1160 | int bits = dentry->d_sb->s_blocksize_bits; |
1160 | __be32 *fsid = (__be32 *)root->fs_info->fsid; | 1161 | __be32 *fsid = (__be32 *)fs_info->fsid; |
1161 | int ret; | 1162 | int ret; |
1162 | 1163 | ||
1163 | /* holding chunk_muext to avoid allocating new chunks */ | 1164 | /* holding chunk_muext to avoid allocating new chunks */ |
1164 | mutex_lock(&root->fs_info->chunk_mutex); | 1165 | mutex_lock(&fs_info->chunk_mutex); |
1165 | rcu_read_lock(); | 1166 | rcu_read_lock(); |
1166 | list_for_each_entry_rcu(found, head, list) { | 1167 | list_for_each_entry_rcu(found, head, list) { |
1167 | if (found->flags & BTRFS_BLOCK_GROUP_DATA) { | 1168 | if (found->flags & BTRFS_BLOCK_GROUP_DATA) { |
@@ -1180,14 +1181,14 @@ static int btrfs_statfs(struct dentry *dentry, struct kstatfs *buf) | |||
1180 | buf->f_bsize = dentry->d_sb->s_blocksize; | 1181 | buf->f_bsize = dentry->d_sb->s_blocksize; |
1181 | buf->f_type = BTRFS_SUPER_MAGIC; | 1182 | buf->f_type = BTRFS_SUPER_MAGIC; |
1182 | buf->f_bavail = total_free_data; | 1183 | buf->f_bavail = total_free_data; |
1183 | ret = btrfs_calc_avail_data_space(root, &total_free_data); | 1184 | ret = btrfs_calc_avail_data_space(fs_info->tree_root, &total_free_data); |
1184 | if (ret) { | 1185 | if (ret) { |
1185 | mutex_unlock(&root->fs_info->chunk_mutex); | 1186 | mutex_unlock(&fs_info->chunk_mutex); |
1186 | return ret; | 1187 | return ret; |
1187 | } | 1188 | } |
1188 | buf->f_bavail += total_free_data; | 1189 | buf->f_bavail += total_free_data; |
1189 | buf->f_bavail = buf->f_bavail >> bits; | 1190 | buf->f_bavail = buf->f_bavail >> bits; |
1190 | mutex_unlock(&root->fs_info->chunk_mutex); | 1191 | mutex_unlock(&fs_info->chunk_mutex); |
1191 | 1192 | ||
1192 | /* We treat it as constant endianness (it doesn't matter _which_) | 1193 | /* We treat it as constant endianness (it doesn't matter _which_) |
1193 | because we want the fsid to come out the same whether mounted | 1194 | because we want the fsid to come out the same whether mounted |
@@ -1203,7 +1204,7 @@ static int btrfs_statfs(struct dentry *dentry, struct kstatfs *buf) | |||
1203 | 1204 | ||
1204 | static void btrfs_kill_super(struct super_block *sb) | 1205 | static void btrfs_kill_super(struct super_block *sb) |
1205 | { | 1206 | { |
1206 | struct btrfs_fs_info *fs_info = btrfs_sb(sb)->fs_info; | 1207 | struct btrfs_fs_info *fs_info = btrfs_sb(sb); |
1207 | kill_anon_super(sb); | 1208 | kill_anon_super(sb); |
1208 | free_fs_info(fs_info); | 1209 | free_fs_info(fs_info); |
1209 | } | 1210 | } |
@@ -1246,17 +1247,17 @@ static long btrfs_control_ioctl(struct file *file, unsigned int cmd, | |||
1246 | 1247 | ||
1247 | static int btrfs_freeze(struct super_block *sb) | 1248 | static int btrfs_freeze(struct super_block *sb) |
1248 | { | 1249 | { |
1249 | struct btrfs_root *root = btrfs_sb(sb); | 1250 | struct btrfs_fs_info *fs_info = btrfs_sb(sb); |
1250 | mutex_lock(&root->fs_info->transaction_kthread_mutex); | 1251 | mutex_lock(&fs_info->transaction_kthread_mutex); |
1251 | mutex_lock(&root->fs_info->cleaner_mutex); | 1252 | mutex_lock(&fs_info->cleaner_mutex); |
1252 | return 0; | 1253 | return 0; |
1253 | } | 1254 | } |
1254 | 1255 | ||
1255 | static int btrfs_unfreeze(struct super_block *sb) | 1256 | static int btrfs_unfreeze(struct super_block *sb) |
1256 | { | 1257 | { |
1257 | struct btrfs_root *root = btrfs_sb(sb); | 1258 | struct btrfs_fs_info *fs_info = btrfs_sb(sb); |
1258 | mutex_unlock(&root->fs_info->cleaner_mutex); | 1259 | mutex_unlock(&fs_info->cleaner_mutex); |
1259 | mutex_unlock(&root->fs_info->transaction_kthread_mutex); | 1260 | mutex_unlock(&fs_info->transaction_kthread_mutex); |
1260 | return 0; | 1261 | return 0; |
1261 | } | 1262 | } |
1262 | 1263 | ||