aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/free-space-cache.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/btrfs/free-space-cache.c')
-rw-r--r--fs/btrfs/free-space-cache.c30
1 files changed, 10 insertions, 20 deletions
diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
index 1027b854b90c..557502ca1a2a 100644
--- a/fs/btrfs/free-space-cache.c
+++ b/fs/btrfs/free-space-cache.c
@@ -1250,18 +1250,13 @@ tree_search_offset(struct btrfs_free_space_ctl *ctl,
1250 * if previous extent entry covers the offset, 1250 * if previous extent entry covers the offset,
1251 * we should return it instead of the bitmap entry 1251 * we should return it instead of the bitmap entry
1252 */ 1252 */
1253 n = &entry->offset_index; 1253 n = rb_prev(&entry->offset_index);
1254 while (1) { 1254 if (n) {
1255 n = rb_prev(n);
1256 if (!n)
1257 break;
1258 prev = rb_entry(n, struct btrfs_free_space, 1255 prev = rb_entry(n, struct btrfs_free_space,
1259 offset_index); 1256 offset_index);
1260 if (!prev->bitmap) { 1257 if (!prev->bitmap &&
1261 if (prev->offset + prev->bytes > offset) 1258 prev->offset + prev->bytes > offset)
1262 entry = prev; 1259 entry = prev;
1263 break;
1264 }
1265 } 1260 }
1266 } 1261 }
1267 return entry; 1262 return entry;
@@ -1287,18 +1282,13 @@ tree_search_offset(struct btrfs_free_space_ctl *ctl,
1287 } 1282 }
1288 1283
1289 if (entry->bitmap) { 1284 if (entry->bitmap) {
1290 n = &entry->offset_index; 1285 n = rb_prev(&entry->offset_index);
1291 while (1) { 1286 if (n) {
1292 n = rb_prev(n);
1293 if (!n)
1294 break;
1295 prev = rb_entry(n, struct btrfs_free_space, 1287 prev = rb_entry(n, struct btrfs_free_space,
1296 offset_index); 1288 offset_index);
1297 if (!prev->bitmap) { 1289 if (!prev->bitmap &&
1298 if (prev->offset + prev->bytes > offset) 1290 prev->offset + prev->bytes > offset)
1299 return prev; 1291 return prev;
1300 break;
1301 }
1302 } 1292 }
1303 if (entry->offset + BITS_PER_BITMAP * ctl->unit > offset) 1293 if (entry->offset + BITS_PER_BITMAP * ctl->unit > offset)
1304 return entry; 1294 return entry;