diff options
Diffstat (limited to 'fs/btrfs/extent-tree.c')
-rw-r--r-- | fs/btrfs/extent-tree.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index e3c6bfea3751..a366415e03a6 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c | |||
@@ -443,6 +443,7 @@ int btrfs_inc_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root, | |||
443 | buf_leaf = btrfs_buffer_leaf(buf); | 443 | buf_leaf = btrfs_buffer_leaf(buf); |
444 | for (i = 0; i < btrfs_header_nritems(&buf_node->header); i++) { | 444 | for (i = 0; i < btrfs_header_nritems(&buf_node->header); i++) { |
445 | if (leaf) { | 445 | if (leaf) { |
446 | u64 disk_blocknr; | ||
446 | key = &buf_leaf->items[i].key; | 447 | key = &buf_leaf->items[i].key; |
447 | if (btrfs_disk_key_type(key) != BTRFS_EXTENT_DATA_KEY) | 448 | if (btrfs_disk_key_type(key) != BTRFS_EXTENT_DATA_KEY) |
448 | continue; | 449 | continue; |
@@ -451,8 +452,10 @@ int btrfs_inc_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root, | |||
451 | if (btrfs_file_extent_type(fi) == | 452 | if (btrfs_file_extent_type(fi) == |
452 | BTRFS_FILE_EXTENT_INLINE) | 453 | BTRFS_FILE_EXTENT_INLINE) |
453 | continue; | 454 | continue; |
454 | ret = btrfs_inc_extent_ref(trans, root, | 455 | disk_blocknr = btrfs_file_extent_disk_blocknr(fi); |
455 | btrfs_file_extent_disk_blocknr(fi), | 456 | if (disk_blocknr == 0) |
457 | continue; | ||
458 | ret = btrfs_inc_extent_ref(trans, root, disk_blocknr, | ||
456 | btrfs_file_extent_disk_num_blocks(fi)); | 459 | btrfs_file_extent_disk_num_blocks(fi)); |
457 | BUG_ON(ret); | 460 | BUG_ON(ret); |
458 | } else { | 461 | } else { |
@@ -1248,6 +1251,7 @@ static int drop_leaf_ref(struct btrfs_trans_handle *trans, | |||
1248 | leaf = btrfs_buffer_leaf(cur); | 1251 | leaf = btrfs_buffer_leaf(cur); |
1249 | nritems = btrfs_header_nritems(&leaf->header); | 1252 | nritems = btrfs_header_nritems(&leaf->header); |
1250 | for (i = 0; i < nritems; i++) { | 1253 | for (i = 0; i < nritems; i++) { |
1254 | u64 disk_blocknr; | ||
1251 | key = &leaf->items[i].key; | 1255 | key = &leaf->items[i].key; |
1252 | if (btrfs_disk_key_type(key) != BTRFS_EXTENT_DATA_KEY) | 1256 | if (btrfs_disk_key_type(key) != BTRFS_EXTENT_DATA_KEY) |
1253 | continue; | 1257 | continue; |
@@ -1258,8 +1262,10 @@ static int drop_leaf_ref(struct btrfs_trans_handle *trans, | |||
1258 | * FIXME make sure to insert a trans record that | 1262 | * FIXME make sure to insert a trans record that |
1259 | * repeats the snapshot del on crash | 1263 | * repeats the snapshot del on crash |
1260 | */ | 1264 | */ |
1261 | ret = btrfs_free_extent(trans, root, | 1265 | disk_blocknr = btrfs_file_extent_disk_blocknr(fi); |
1262 | btrfs_file_extent_disk_blocknr(fi), | 1266 | if (disk_blocknr == 0) |
1267 | continue; | ||
1268 | ret = btrfs_free_extent(trans, root, disk_blocknr, | ||
1263 | btrfs_file_extent_disk_num_blocks(fi), | 1269 | btrfs_file_extent_disk_num_blocks(fi), |
1264 | 0); | 1270 | 0); |
1265 | BUG_ON(ret); | 1271 | BUG_ON(ret); |