Skip to contentSkip to conversation

Btrfs: fix wrong return value of btrfs_lookup_csum()

PATCH In review Miao Xie 1 participant 1 message Mar 28, 2013 Btrfs file system

lore
Share & tools
lore

Miao Xie

author
#0 lore raw

PATCH 4/4 Btrfs: fix wrong return value of btrfs_lookup_csum()

If we don't find the expected csum item, but find a csum item which is adjacent to the specified extent, we should return -EFBIG, or we should return -ENOENT. But btrfs_lookup_csum() return -EFBIG even the csum item is not adjacent to the specified extent. Fix it.

---
 fs/btrfs/file-item.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
fs/btrfs/file-item.c +3 -1
index 9a447bc..bc89e2f 100644
@@ -117,9 +117,11 @@ struct btrfs_csum_item *btrfs_lookup_csum(struct btrfs_trans_handle *trans,
 		csums_in_item = btrfs_item_size_nr(leaf, path->slots[0]);
 		csums_in_item /= csum_size;
 
-		if (csum_offset >= csums_in_item) {
+		if (csum_offset == csums_in_item) {
 			ret = -EFBIG;
 			goto fail;
+		} else if (csum_offset > csums_in_item) {
+			goto fail;
 		}
 	}
 	item = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_csum_item);
Signature · 1 line
1.8.0.1