diff options
| author | Rashika <rashika.kheria@gmail.com> | 2013-10-30 17:15:20 -0400 |
|---|---|---|
| committer | Chris Mason <chris.mason@fusionio.com> | 2013-11-11 22:11:13 -0500 |
| commit | 2e9f5954978cd5b0c26e6eeb9fd4ccbdce0f5ecc (patch) | |
| tree | 67114f60511afa3d1ceca92c42870208a5f4b059 /fs/btrfs/disk-io.c | |
| parent | 48ec47364b6d493f0a9cdc116977bf3f34e5c3ec (diff) | |
btrfs: Add helper function for free_root_pointers()
The function free_root_pointers() in disk-io.h contains redundant code.
Therefore, this patch adds a helper function free_root_extent_buffers()
to free_root_pointers() to eliminate redundancy.
Reviewed-by: Zach Brown <zab@redhat.com>
Signed-off-by: Rashika Kheria <rashika.kheria@gmail.com>
Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Diffstat (limited to 'fs/btrfs/disk-io.c')
| -rw-r--r-- | fs/btrfs/disk-io.c | 60 |
1 files changed, 19 insertions, 41 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index a3ad3a27944d..22443fac9408 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c | |||
| @@ -2033,50 +2033,28 @@ static void btrfs_stop_all_workers(struct btrfs_fs_info *fs_info) | |||
| 2033 | btrfs_stop_workers(&fs_info->qgroup_rescan_workers); | 2033 | btrfs_stop_workers(&fs_info->qgroup_rescan_workers); |
| 2034 | } | 2034 | } |
| 2035 | 2035 | ||
| 2036 | static void free_root_extent_buffers(struct btrfs_root *root) | ||
| 2037 | { | ||
| 2038 | if (root) { | ||
| 2039 | free_extent_buffer(root->node); | ||
| 2040 | free_extent_buffer(root->commit_root); | ||
| 2041 | root->node = NULL; | ||
| 2042 | root->commit_root = NULL; | ||
| 2043 | } | ||
| 2044 | } | ||
| 2045 | |||
| 2036 | /* helper to cleanup tree roots */ | 2046 | /* helper to cleanup tree roots */ |
| 2037 | static void free_root_pointers(struct btrfs_fs_info *info, int chunk_root) | 2047 | static void free_root_pointers(struct btrfs_fs_info *info, int chunk_root) |
| 2038 | { | 2048 | { |
| 2039 | free_extent_buffer(info->tree_root->node); | 2049 | free_root_extent_buffers(info->tree_root); |
| 2040 | free_extent_buffer(info->tree_root->commit_root); | 2050 | |
| 2041 | info->tree_root->node = NULL; | 2051 | free_root_extent_buffers(info->dev_root); |
| 2042 | info->tree_root->commit_root = NULL; | 2052 | free_root_extent_buffers(info->extent_root); |
| 2043 | 2053 | free_root_extent_buffers(info->csum_root); | |
| 2044 | if (info->dev_root) { | 2054 | free_root_extent_buffers(info->quota_root); |
| 2045 | free_extent_buffer(info->dev_root->node); | 2055 | free_root_extent_buffers(info->uuid_root); |
| 2046 | free_extent_buffer(info->dev_root->commit_root); | 2056 | if (chunk_root) |
| 2047 | info->dev_root->node = NULL; | 2057 | free_root_extent_buffers(info->chunk_root); |
| 2048 | info->dev_root->commit_root = NULL; | ||
| 2049 | } | ||
| 2050 | if (info->extent_root) { | ||
| 2051 | free_extent_buffer(info->extent_root->node); | ||
| 2052 | free_extent_buffer(info->extent_root->commit_root); | ||
| 2053 | info->extent_root->node = NULL; | ||
| 2054 | info->extent_root->commit_root = NULL; | ||
| 2055 | } | ||
| 2056 | if (info->csum_root) { | ||
| 2057 | free_extent_buffer(info->csum_root->node); | ||
| 2058 | free_extent_buffer(info->csum_root->commit_root); | ||
| 2059 | info->csum_root->node = NULL; | ||
| 2060 | info->csum_root->commit_root = NULL; | ||
| 2061 | } | ||
| 2062 | if (info->quota_root) { | ||
| 2063 | free_extent_buffer(info->quota_root->node); | ||
| 2064 | free_extent_buffer(info->quota_root->commit_root); | ||
| 2065 | info->quota_root->node = NULL; | ||
| 2066 | info->quota_root->commit_root = NULL; | ||
| 2067 | } | ||
| 2068 | if (info->uuid_root) { | ||
| 2069 | free_extent_buffer(info->uuid_root->node); | ||
| 2070 | free_extent_buffer(info->uuid_root->commit_root); | ||
| 2071 | info->uuid_root->node = NULL; | ||
| 2072 | info->uuid_root->commit_root = NULL; | ||
| 2073 | } | ||
| 2074 | if (chunk_root) { | ||
| 2075 | free_extent_buffer(info->chunk_root->node); | ||
| 2076 | free_extent_buffer(info->chunk_root->commit_root); | ||
| 2077 | info->chunk_root->node = NULL; | ||
| 2078 | info->chunk_root->commit_root = NULL; | ||
| 2079 | } | ||
| 2080 | } | 2058 | } |
| 2081 | 2059 | ||
| 2082 | static void del_fs_roots(struct btrfs_fs_info *fs_info) | 2060 | static void del_fs_roots(struct btrfs_fs_info *fs_info) |
