diff options
Diffstat (limited to 'fs/btrfs/free-space-cache.c')
-rw-r--r-- | fs/btrfs/free-space-cache.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c index 6377713f639c..41ac927401d0 100644 --- a/fs/btrfs/free-space-cache.c +++ b/fs/btrfs/free-space-cache.c | |||
@@ -190,9 +190,11 @@ int btrfs_truncate_free_space_cache(struct btrfs_root *root, | |||
190 | struct btrfs_path *path, | 190 | struct btrfs_path *path, |
191 | struct inode *inode) | 191 | struct inode *inode) |
192 | { | 192 | { |
193 | struct btrfs_block_rsv *rsv; | ||
193 | loff_t oldsize; | 194 | loff_t oldsize; |
194 | int ret = 0; | 195 | int ret = 0; |
195 | 196 | ||
197 | rsv = trans->block_rsv; | ||
196 | trans->block_rsv = root->orphan_block_rsv; | 198 | trans->block_rsv = root->orphan_block_rsv; |
197 | ret = btrfs_block_rsv_check(trans, root, | 199 | ret = btrfs_block_rsv_check(trans, root, |
198 | root->orphan_block_rsv, | 200 | root->orphan_block_rsv, |
@@ -210,6 +212,8 @@ int btrfs_truncate_free_space_cache(struct btrfs_root *root, | |||
210 | */ | 212 | */ |
211 | ret = btrfs_truncate_inode_items(trans, root, inode, | 213 | ret = btrfs_truncate_inode_items(trans, root, inode, |
212 | 0, BTRFS_EXTENT_DATA_KEY); | 214 | 0, BTRFS_EXTENT_DATA_KEY); |
215 | |||
216 | trans->block_rsv = rsv; | ||
213 | if (ret) { | 217 | if (ret) { |
214 | WARN_ON(1); | 218 | WARN_ON(1); |
215 | return ret; | 219 | return ret; |
@@ -1168,9 +1172,9 @@ static void recalculate_thresholds(struct btrfs_free_space_ctl *ctl) | |||
1168 | div64_u64(extent_bytes, (sizeof(struct btrfs_free_space))); | 1172 | div64_u64(extent_bytes, (sizeof(struct btrfs_free_space))); |
1169 | } | 1173 | } |
1170 | 1174 | ||
1171 | static void bitmap_clear_bits(struct btrfs_free_space_ctl *ctl, | 1175 | static inline void __bitmap_clear_bits(struct btrfs_free_space_ctl *ctl, |
1172 | struct btrfs_free_space *info, u64 offset, | 1176 | struct btrfs_free_space *info, |
1173 | u64 bytes) | 1177 | u64 offset, u64 bytes) |
1174 | { | 1178 | { |
1175 | unsigned long start, count; | 1179 | unsigned long start, count; |
1176 | 1180 | ||
@@ -1181,6 +1185,13 @@ static void bitmap_clear_bits(struct btrfs_free_space_ctl *ctl, | |||
1181 | bitmap_clear(info->bitmap, start, count); | 1185 | bitmap_clear(info->bitmap, start, count); |
1182 | 1186 | ||
1183 | info->bytes -= bytes; | 1187 | info->bytes -= bytes; |
1188 | } | ||
1189 | |||
1190 | static void bitmap_clear_bits(struct btrfs_free_space_ctl *ctl, | ||
1191 | struct btrfs_free_space *info, u64 offset, | ||
1192 | u64 bytes) | ||
1193 | { | ||
1194 | __bitmap_clear_bits(ctl, info, offset, bytes); | ||
1184 | ctl->free_space -= bytes; | 1195 | ctl->free_space -= bytes; |
1185 | } | 1196 | } |
1186 | 1197 | ||
@@ -1984,7 +1995,7 @@ static u64 btrfs_alloc_from_bitmap(struct btrfs_block_group_cache *block_group, | |||
1984 | return 0; | 1995 | return 0; |
1985 | 1996 | ||
1986 | ret = search_start; | 1997 | ret = search_start; |
1987 | bitmap_clear_bits(ctl, entry, ret, bytes); | 1998 | __bitmap_clear_bits(ctl, entry, ret, bytes); |
1988 | 1999 | ||
1989 | return ret; | 2000 | return ret; |
1990 | } | 2001 | } |
@@ -2039,7 +2050,6 @@ u64 btrfs_alloc_from_cluster(struct btrfs_block_group_cache *block_group, | |||
2039 | continue; | 2050 | continue; |
2040 | } | 2051 | } |
2041 | } else { | 2052 | } else { |
2042 | |||
2043 | ret = entry->offset; | 2053 | ret = entry->offset; |
2044 | 2054 | ||
2045 | entry->offset += bytes; | 2055 | entry->offset += bytes; |