aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2011-11-17 15:40:49 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2012-01-08 19:35:37 -0500
commit815745cf3e46681241ad8025602ffbf2a452d514 (patch)
tree7902ae81b199b383b5552e71b6d1cd21aff17fdb /fs/btrfs
parent59553edf110e5576d91be9dd5bd53d110e0d0290 (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')
-rw-r--r--fs/btrfs/ctree.h2
-rw-r--r--fs/btrfs/disk-io.c4
-rw-r--r--fs/btrfs/export.c2
-rw-r--r--fs/btrfs/ioctl.c7
-rw-r--r--fs/btrfs/super.c75
5 files changed, 45 insertions, 45 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 67385033323d..dbb999a38272 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -2196,7 +2196,7 @@ static inline u32 btrfs_file_extent_inline_item_len(struct extent_buffer *eb,
2196 return btrfs_item_size(eb, e) - offset; 2196 return btrfs_item_size(eb, e) - offset;
2197} 2197}
2198 2198
2199static inline struct btrfs_root *btrfs_sb(struct super_block *sb) 2199static inline struct btrfs_fs_info *btrfs_sb(struct super_block *sb)
2200{ 2200{
2201 return sb->s_fs_info; 2201 return sb->s_fs_info;
2202} 2202}
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index b6d11eb4e430..f7d8b9ba519b 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -1894,8 +1894,8 @@ int open_ctree(struct super_block *sb,
1894 struct btrfs_key location; 1894 struct btrfs_key location;
1895 struct buffer_head *bh; 1895 struct buffer_head *bh;
1896 struct btrfs_super_block *disk_super; 1896 struct btrfs_super_block *disk_super;
1897 struct btrfs_root *tree_root = btrfs_sb(sb); 1897 struct btrfs_fs_info *fs_info = btrfs_sb(sb);
1898 struct btrfs_fs_info *fs_info = tree_root->fs_info; 1898 struct btrfs_root *tree_root = fs_info->tree_root;
1899 struct btrfs_root *extent_root; 1899 struct btrfs_root *extent_root;
1900 struct btrfs_root *csum_root; 1900 struct btrfs_root *csum_root;
1901 struct btrfs_root *chunk_root; 1901 struct btrfs_root *chunk_root;
diff --git a/fs/btrfs/export.c b/fs/btrfs/export.c
index 1b8dc33778f9..5f77166fd01c 100644
--- a/fs/btrfs/export.c
+++ b/fs/btrfs/export.c
@@ -67,7 +67,7 @@ static struct dentry *btrfs_get_dentry(struct super_block *sb, u64 objectid,
67 u64 root_objectid, u32 generation, 67 u64 root_objectid, u32 generation,
68 int check_generation) 68 int check_generation)
69{ 69{
70 struct btrfs_fs_info *fs_info = btrfs_sb(sb)->fs_info; 70 struct btrfs_fs_info *fs_info = btrfs_sb(sb);
71 struct btrfs_root *root; 71 struct btrfs_root *root;
72 struct inode *inode; 72 struct inode *inode;
73 struct btrfs_key key; 73 struct btrfs_key key;
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 5441ff1480fd..0c55f8f38091 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -276,14 +276,13 @@ static int btrfs_ioctl_getversion(struct file *file, int __user *arg)
276 276
277static noinline int btrfs_ioctl_fitrim(struct file *file, void __user *arg) 277static noinline int btrfs_ioctl_fitrim(struct file *file, void __user *arg)
278{ 278{
279 struct btrfs_root *root = fdentry(file)->d_sb->s_fs_info; 279 struct btrfs_fs_info *fs_info = btrfs_sb(fdentry(file)->d_sb);
280 struct btrfs_fs_info *fs_info = root->fs_info;
281 struct btrfs_device *device; 280 struct btrfs_device *device;
282 struct request_queue *q; 281 struct request_queue *q;
283 struct fstrim_range range; 282 struct fstrim_range range;
284 u64 minlen = ULLONG_MAX; 283 u64 minlen = ULLONG_MAX;
285 u64 num_devices = 0; 284 u64 num_devices = 0;
286 u64 total_bytes = btrfs_super_total_bytes(root->fs_info->super_copy); 285 u64 total_bytes = btrfs_super_total_bytes(fs_info->super_copy);
287 int ret; 286 int ret;
288 287
289 if (!capable(CAP_SYS_ADMIN)) 288 if (!capable(CAP_SYS_ADMIN))
@@ -312,7 +311,7 @@ static noinline int btrfs_ioctl_fitrim(struct file *file, void __user *arg)
312 311
313 range.len = min(range.len, total_bytes - range.start); 312 range.len = min(range.len, total_bytes - range.start);
314 range.minlen = max(range.minlen, minlen); 313 range.minlen = max(range.minlen, minlen);
315 ret = btrfs_trim_fs(root, &range); 314 ret = btrfs_trim_fs(fs_info->tree_root, &range);
316 if (ret < 0) 315 if (ret < 0)
317 return ret; 316 return ret;
318 317
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
148static void btrfs_put_super(struct super_block *sb) 148static 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:
500static struct dentry *get_default_root(struct super_block *sb, 500static 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
554find_root: 555find_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
636fail_close: 636fail_close:
637 close_ctree(tree_root); 637 close_ctree(fs_info->tree_root);
638 return err; 638 return err;
639} 639}
640 640
641int btrfs_sync_fs(struct super_block *sb, int wait) 641int 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
664static int btrfs_show_options(struct seq_file *seq, struct dentry *dentry) 665static 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
728static int btrfs_test_super(struct super_block *s, void *data) 729static 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
736static int btrfs_set_super(struct super_block *s, void *data) 737static 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
960static int btrfs_remount(struct super_block *sb, int *flags, char *data) 960static 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
1151static int btrfs_statfs(struct dentry *dentry, struct kstatfs *buf) 1152static 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
1204static void btrfs_kill_super(struct super_block *sb) 1205static 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
1247static int btrfs_freeze(struct super_block *sb) 1248static 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
1255static int btrfs_unfreeze(struct super_block *sb) 1256static 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