diff options
author | Li Zefan <lizefan@huawei.com> | 2012-07-09 22:21:07 -0400 |
---|---|---|
committer | Chris Mason <chris.mason@fusionio.com> | 2012-07-23 16:28:05 -0400 |
commit | b4d7c3c9456a311a45bc1ef8944b5ba5b176244f (patch) | |
tree | 217aeddfbcd502d8b61400cc0d87603f03c836f6 /fs/btrfs | |
parent | d5b025d510664382f9a197f7e7fb9fc60fe209bc (diff) |
Btrfs: kill free_space pointer from inode structure
Inodes always allocate free space with BTRFS_BLOCK_GROUP_DATA type,
which means every inode has the same BTRFS_I(inode)->free_space pointer.
This shrinks struct btrfs_inode by 4 bytes (or 8 bytes on 64 bits).
Signed-off-by: Li Zefan <lizefan@huawei.com>
Diffstat (limited to 'fs/btrfs')
-rw-r--r-- | fs/btrfs/btrfs_inode.h | 3 | ||||
-rw-r--r-- | fs/btrfs/ctree.h | 3 | ||||
-rw-r--r-- | fs/btrfs/extent-tree.c | 20 | ||||
-rw-r--r-- | fs/btrfs/inode.c | 3 |
4 files changed, 10 insertions, 19 deletions
diff --git a/fs/btrfs/btrfs_inode.h b/fs/btrfs/btrfs_inode.h index 21b8cfe08e95..5b2ad6bc4fe7 100644 --- a/fs/btrfs/btrfs_inode.h +++ b/fs/btrfs/btrfs_inode.h | |||
@@ -87,9 +87,6 @@ struct btrfs_inode { | |||
87 | /* node for the red-black tree that links inodes in subvolume root */ | 87 | /* node for the red-black tree that links inodes in subvolume root */ |
88 | struct rb_node rb_node; | 88 | struct rb_node rb_node; |
89 | 89 | ||
90 | /* the space_info for where this inode's data allocations are done */ | ||
91 | struct btrfs_space_info *space_info; | ||
92 | |||
93 | unsigned long runtime_flags; | 90 | unsigned long runtime_flags; |
94 | 91 | ||
95 | /* full 64 bit generation number, struct vfs_inode doesn't have a big | 92 | /* full 64 bit generation number, struct vfs_inode doesn't have a big |
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index fa5c45b39075..6761490b91cd 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h | |||
@@ -1240,6 +1240,8 @@ struct btrfs_fs_info { | |||
1240 | */ | 1240 | */ |
1241 | struct list_head space_info; | 1241 | struct list_head space_info; |
1242 | 1242 | ||
1243 | struct btrfs_space_info *data_sinfo; | ||
1244 | |||
1243 | struct reloc_control *reloc_ctl; | 1245 | struct reloc_control *reloc_ctl; |
1244 | 1246 | ||
1245 | spinlock_t delalloc_lock; | 1247 | spinlock_t delalloc_lock; |
@@ -2607,7 +2609,6 @@ int btrfs_remove_block_group(struct btrfs_trans_handle *trans, | |||
2607 | struct btrfs_root *root, u64 group_start); | 2609 | struct btrfs_root *root, u64 group_start); |
2608 | u64 btrfs_reduce_alloc_profile(struct btrfs_root *root, u64 flags); | 2610 | u64 btrfs_reduce_alloc_profile(struct btrfs_root *root, u64 flags); |
2609 | u64 btrfs_get_alloc_profile(struct btrfs_root *root, int data); | 2611 | u64 btrfs_get_alloc_profile(struct btrfs_root *root, int data); |
2610 | void btrfs_set_inode_space_info(struct btrfs_root *root, struct inode *ionde); | ||
2611 | void btrfs_clear_space_info_full(struct btrfs_fs_info *info); | 2612 | void btrfs_clear_space_info_full(struct btrfs_fs_info *info); |
2612 | int btrfs_check_data_free_space(struct inode *inode, u64 bytes); | 2613 | int btrfs_check_data_free_space(struct inode *inode, u64 bytes); |
2613 | void btrfs_free_reserved_data_space(struct inode *inode, u64 bytes); | 2614 | void btrfs_free_reserved_data_space(struct inode *inode, u64 bytes); |
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 7843542484c9..6621ed72f3c3 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c | |||
@@ -3139,6 +3139,8 @@ static int update_space_info(struct btrfs_fs_info *info, u64 flags, | |||
3139 | init_waitqueue_head(&found->wait); | 3139 | init_waitqueue_head(&found->wait); |
3140 | *space_info = found; | 3140 | *space_info = found; |
3141 | list_add_rcu(&found->list, &info->space_info); | 3141 | list_add_rcu(&found->list, &info->space_info); |
3142 | if (flags & BTRFS_BLOCK_GROUP_DATA) | ||
3143 | info->data_sinfo = found; | ||
3142 | return 0; | 3144 | return 0; |
3143 | } | 3145 | } |
3144 | 3146 | ||
@@ -3268,12 +3270,6 @@ u64 btrfs_get_alloc_profile(struct btrfs_root *root, int data) | |||
3268 | return get_alloc_profile(root, flags); | 3270 | return get_alloc_profile(root, flags); |
3269 | } | 3271 | } |
3270 | 3272 | ||
3271 | void btrfs_set_inode_space_info(struct btrfs_root *root, struct inode *inode) | ||
3272 | { | ||
3273 | BTRFS_I(inode)->space_info = __find_space_info(root->fs_info, | ||
3274 | BTRFS_BLOCK_GROUP_DATA); | ||
3275 | } | ||
3276 | |||
3277 | /* | 3273 | /* |
3278 | * This will check the space that the inode allocates from to make sure we have | 3274 | * This will check the space that the inode allocates from to make sure we have |
3279 | * enough space for bytes. | 3275 | * enough space for bytes. |
@@ -3282,6 +3278,7 @@ int btrfs_check_data_free_space(struct inode *inode, u64 bytes) | |||
3282 | { | 3278 | { |
3283 | struct btrfs_space_info *data_sinfo; | 3279 | struct btrfs_space_info *data_sinfo; |
3284 | struct btrfs_root *root = BTRFS_I(inode)->root; | 3280 | struct btrfs_root *root = BTRFS_I(inode)->root; |
3281 | struct btrfs_fs_info *fs_info = root->fs_info; | ||
3285 | u64 used; | 3282 | u64 used; |
3286 | int ret = 0, committed = 0, alloc_chunk = 1; | 3283 | int ret = 0, committed = 0, alloc_chunk = 1; |
3287 | 3284 | ||
@@ -3294,7 +3291,7 @@ int btrfs_check_data_free_space(struct inode *inode, u64 bytes) | |||
3294 | committed = 1; | 3291 | committed = 1; |
3295 | } | 3292 | } |
3296 | 3293 | ||
3297 | data_sinfo = BTRFS_I(inode)->space_info; | 3294 | data_sinfo = fs_info->data_sinfo; |
3298 | if (!data_sinfo) | 3295 | if (!data_sinfo) |
3299 | goto alloc; | 3296 | goto alloc; |
3300 | 3297 | ||
@@ -3335,10 +3332,9 @@ alloc: | |||
3335 | goto commit_trans; | 3332 | goto commit_trans; |
3336 | } | 3333 | } |
3337 | 3334 | ||
3338 | if (!data_sinfo) { | 3335 | if (!data_sinfo) |
3339 | btrfs_set_inode_space_info(root, inode); | 3336 | data_sinfo = fs_info->data_sinfo; |
3340 | data_sinfo = BTRFS_I(inode)->space_info; | 3337 | |
3341 | } | ||
3342 | goto again; | 3338 | goto again; |
3343 | } | 3339 | } |
3344 | 3340 | ||
@@ -3385,7 +3381,7 @@ void btrfs_free_reserved_data_space(struct inode *inode, u64 bytes) | |||
3385 | /* make sure bytes are sectorsize aligned */ | 3381 | /* make sure bytes are sectorsize aligned */ |
3386 | bytes = (bytes + root->sectorsize - 1) & ~((u64)root->sectorsize - 1); | 3382 | bytes = (bytes + root->sectorsize - 1) & ~((u64)root->sectorsize - 1); |
3387 | 3383 | ||
3388 | data_sinfo = BTRFS_I(inode)->space_info; | 3384 | data_sinfo = root->fs_info->data_sinfo; |
3389 | spin_lock(&data_sinfo->lock); | 3385 | spin_lock(&data_sinfo->lock); |
3390 | data_sinfo->bytes_may_use -= bytes; | 3386 | data_sinfo->bytes_may_use -= bytes; |
3391 | trace_btrfs_space_reservation(root->fs_info, "space_info", | 3387 | trace_btrfs_space_reservation(root->fs_info, "space_info", |
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 321c415dea7f..ee45ebf42192 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
@@ -4082,7 +4082,6 @@ static int btrfs_init_locked_inode(struct inode *inode, void *p) | |||
4082 | struct btrfs_iget_args *args = p; | 4082 | struct btrfs_iget_args *args = p; |
4083 | inode->i_ino = args->ino; | 4083 | inode->i_ino = args->ino; |
4084 | BTRFS_I(inode)->root = args->root; | 4084 | BTRFS_I(inode)->root = args->root; |
4085 | btrfs_set_inode_space_info(args->root, inode); | ||
4086 | return 0; | 4085 | return 0; |
4087 | } | 4086 | } |
4088 | 4087 | ||
@@ -4667,7 +4666,6 @@ static struct inode *btrfs_new_inode(struct btrfs_trans_handle *trans, | |||
4667 | BTRFS_I(inode)->root = root; | 4666 | BTRFS_I(inode)->root = root; |
4668 | BTRFS_I(inode)->generation = trans->transid; | 4667 | BTRFS_I(inode)->generation = trans->transid; |
4669 | inode->i_generation = BTRFS_I(inode)->generation; | 4668 | inode->i_generation = BTRFS_I(inode)->generation; |
4670 | btrfs_set_inode_space_info(root, inode); | ||
4671 | 4669 | ||
4672 | if (S_ISDIR(mode)) | 4670 | if (S_ISDIR(mode)) |
4673 | owner = 0; | 4671 | owner = 0; |
@@ -6944,7 +6942,6 @@ struct inode *btrfs_alloc_inode(struct super_block *sb) | |||
6944 | return NULL; | 6942 | return NULL; |
6945 | 6943 | ||
6946 | ei->root = NULL; | 6944 | ei->root = NULL; |
6947 | ei->space_info = NULL; | ||
6948 | ei->generation = 0; | 6945 | ei->generation = 0; |
6949 | ei->last_trans = 0; | 6946 | ei->last_trans = 0; |
6950 | ei->last_sub_trans = 0; | 6947 | ei->last_sub_trans = 0; |