Skip to content

Commit 7e4a3f7

Browse files
fdmananakdave
authored andcommitted
btrfs: do not ignore error from btrfs_next_leaf() when inserting checksums
We are currently treating any non-zero return value from btrfs_next_leaf() the same way, by going to the code that inserts a new checksum item in the tree. However if btrfs_next_leaf() returns an error (a value < 0), we should just stop and return the error, and not behave as if nothing has happened, since in that case we do not have a way to know if there is a next leaf or we are currently at the last leaf already. So fix that by returning the error from btrfs_next_leaf(). Signed-off-by: Filipe Manana <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent cc14600 commit 7e4a3f7

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

fs/btrfs/file-item.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -889,10 +889,12 @@ int btrfs_csum_file_blocks(struct btrfs_trans_handle *trans,
889889
nritems = btrfs_header_nritems(path->nodes[0]);
890890
if (!nritems || (path->slots[0] >= nritems - 1)) {
891891
ret = btrfs_next_leaf(root, path);
892-
if (ret == 1)
892+
if (ret < 0) {
893+
goto out;
894+
} else if (ret > 0) {
893895
found_next = 1;
894-
if (ret != 0)
895896
goto insert;
897+
}
896898
slot = path->slots[0];
897899
}
898900
btrfs_item_key_to_cpu(path->nodes[0], &found_key, slot);

0 commit comments

Comments
 (0)