diff options
author | Josef Bacik <josef@redhat.com> | 2011-08-04 15:34:57 -0400 |
---|---|---|
committer | Josef Bacik <josef@redhat.com> | 2011-10-19 15:12:32 -0400 |
commit | dba68306f3fae681b1005137f130f5bcfdfed34a (patch) | |
tree | eb19fa46bc8f7130fd68393420255876cc8f73fb /fs/btrfs/inode.c | |
parent | 7709cde33f12db71efb377fae4ae7aab6c94ebc6 (diff) |
Btrfs: kill the orphan space calculation for snapshots
This patch kills off the calculation for the amount of space needed for the
orphan operations during a snapshot. The thing is we only do snapshots on
commit, so any space that is in the block_rsv->freed[] isn't going to be in the
new snapshot anyway, so there isn't any reason to require that space to be
reserved for the snapshot to occur. Thanks,
Signed-off-by: Josef Bacik <josef@redhat.com>
Diffstat (limited to 'fs/btrfs/inode.c')
-rw-r--r-- | fs/btrfs/inode.c | 83 |
1 files changed, 0 insertions, 83 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 98b9fa2d77f7..5f5f8a577e69 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
@@ -2079,89 +2079,6 @@ void btrfs_run_delayed_iputs(struct btrfs_root *root) | |||
2079 | up_read(&root->fs_info->cleanup_work_sem); | 2079 | up_read(&root->fs_info->cleanup_work_sem); |
2080 | } | 2080 | } |
2081 | 2081 | ||
2082 | /* | ||
2083 | * calculate extra metadata reservation when snapshotting a subvolume | ||
2084 | * contains orphan files. | ||
2085 | */ | ||
2086 | void btrfs_orphan_pre_snapshot(struct btrfs_trans_handle *trans, | ||
2087 | struct btrfs_pending_snapshot *pending, | ||
2088 | u64 *bytes_to_reserve) | ||
2089 | { | ||
2090 | struct btrfs_root *root; | ||
2091 | struct btrfs_block_rsv *block_rsv; | ||
2092 | u64 num_bytes; | ||
2093 | int index; | ||
2094 | |||
2095 | root = pending->root; | ||
2096 | if (!root->orphan_block_rsv || list_empty(&root->orphan_list)) | ||
2097 | return; | ||
2098 | |||
2099 | block_rsv = root->orphan_block_rsv; | ||
2100 | |||
2101 | /* orphan block reservation for the snapshot */ | ||
2102 | num_bytes = block_rsv->size; | ||
2103 | |||
2104 | /* | ||
2105 | * after the snapshot is created, COWing tree blocks may use more | ||
2106 | * space than it frees. So we should make sure there is enough | ||
2107 | * reserved space. | ||
2108 | */ | ||
2109 | index = trans->transid & 0x1; | ||
2110 | if (block_rsv->reserved + block_rsv->freed[index] < block_rsv->size) { | ||
2111 | num_bytes += block_rsv->size - | ||
2112 | (block_rsv->reserved + block_rsv->freed[index]); | ||
2113 | } | ||
2114 | |||
2115 | *bytes_to_reserve += num_bytes; | ||
2116 | } | ||
2117 | |||
2118 | void btrfs_orphan_post_snapshot(struct btrfs_trans_handle *trans, | ||
2119 | struct btrfs_pending_snapshot *pending) | ||
2120 | { | ||
2121 | struct btrfs_root *root = pending->root; | ||
2122 | struct btrfs_root *snap = pending->snap; | ||
2123 | struct btrfs_block_rsv *block_rsv; | ||
2124 | u64 num_bytes; | ||
2125 | int index; | ||
2126 | int ret; | ||
2127 | |||
2128 | if (!root->orphan_block_rsv || list_empty(&root->orphan_list)) | ||
2129 | return; | ||
2130 | |||
2131 | /* refill source subvolume's orphan block reservation */ | ||
2132 | block_rsv = root->orphan_block_rsv; | ||
2133 | index = trans->transid & 0x1; | ||
2134 | if (block_rsv->reserved + block_rsv->freed[index] < block_rsv->size) { | ||
2135 | num_bytes = block_rsv->size - | ||
2136 | (block_rsv->reserved + block_rsv->freed[index]); | ||
2137 | ret = btrfs_block_rsv_migrate(&pending->block_rsv, | ||
2138 | root->orphan_block_rsv, | ||
2139 | num_bytes); | ||
2140 | BUG_ON(ret); | ||
2141 | } | ||
2142 | |||
2143 | /* setup orphan block reservation for the snapshot */ | ||
2144 | block_rsv = btrfs_alloc_block_rsv(snap); | ||
2145 | BUG_ON(!block_rsv); | ||
2146 | |||
2147 | btrfs_add_durable_block_rsv(root->fs_info, block_rsv); | ||
2148 | snap->orphan_block_rsv = block_rsv; | ||
2149 | |||
2150 | num_bytes = root->orphan_block_rsv->size; | ||
2151 | ret = btrfs_block_rsv_migrate(&pending->block_rsv, | ||
2152 | block_rsv, num_bytes); | ||
2153 | BUG_ON(ret); | ||
2154 | |||
2155 | #if 0 | ||
2156 | /* insert orphan item for the snapshot */ | ||
2157 | WARN_ON(!root->orphan_item_inserted); | ||
2158 | ret = btrfs_insert_orphan_item(trans, root->fs_info->tree_root, | ||
2159 | snap->root_key.objectid); | ||
2160 | BUG_ON(ret); | ||
2161 | snap->orphan_item_inserted = 1; | ||
2162 | #endif | ||
2163 | } | ||
2164 | |||
2165 | enum btrfs_orphan_cleanup_state { | 2082 | enum btrfs_orphan_cleanup_state { |
2166 | ORPHAN_CLEANUP_STARTED = 1, | 2083 | ORPHAN_CLEANUP_STARTED = 1, |
2167 | ORPHAN_CLEANUP_DONE = 2, | 2084 | ORPHAN_CLEANUP_DONE = 2, |