Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

btrfs: check return value of btrfs_partially_delete_raid_extent()

btrfs_partially_delete_raid_extent() returns an error code (e.g.
-ENOMEM from kzalloc(), or errors from btrfs_del_item/btrfs_insert_item()),
but all three call sites in btrfs_delete_raid_extent() discard the
return value, silently losing errors and potentially leaving the stripe
tree in an inconsistent state.

Fix by capturing the return value into ret at all three call sites and
breaking out of the loop on error where appropriate.

Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: robbieko <robbieko@synology.com>
Signed-off-by: David Sterba <dsterba@suse.com>

authored by

robbieko and committed by
David Sterba
a8d58a7c fe0cdfd7

+12 -7
+12 -7
fs/btrfs/raid-stripe-tree.c
··· 223 223 /* The "left" item. */ 224 224 path->slots[0]--; 225 225 btrfs_item_key_to_cpu(leaf, &key, path->slots[0]); 226 - btrfs_partially_delete_raid_extent(trans, path, &key, 227 - diff_start, 0); 226 + ret = btrfs_partially_delete_raid_extent(trans, path, 227 + &key, 228 + diff_start, 0); 228 229 break; 229 230 } 230 231 ··· 241 240 if (found_start < start) { 242 241 u64 diff_start = start - found_start; 243 242 244 - btrfs_partially_delete_raid_extent(trans, path, &key, 245 - diff_start, 0); 243 + ret = btrfs_partially_delete_raid_extent(trans, path, 244 + &key, 245 + diff_start, 0); 246 + if (ret) 247 + break; 246 248 247 249 start += (key.offset - diff_start); 248 250 length -= (key.offset - diff_start); ··· 268 264 if (found_end > end) { 269 265 u64 diff_end = found_end - end; 270 266 271 - btrfs_partially_delete_raid_extent(trans, path, &key, 272 - key.offset - length, 273 - length); 267 + ret = btrfs_partially_delete_raid_extent(trans, path, 268 + &key, 269 + key.offset - length, 270 + length); 274 271 ASSERT(key.offset - diff_end == length); 275 272 break; 276 273 }