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: copy devid in btrfs_partially_delete_raid_extent()

When btrfs_partially_delete_raid_extent() rebuilds a truncated/shifted
stripe extent into newitem, the loop copies the physical address for
each stride but forgets to copy the devid. The resulting item written
back to the stripe tree has zeroed-out devids, corrupting the stripe
mapping.

Fix this by reading the devid with btrfs_raid_stride_devid() and
writing it into the new item with btrfs_set_stack_raid_stride_devid()
before copying the physical address.

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

authored by

robbieko and committed by
David Sterba
513f8a52 4d95b9ef

+3
+3
fs/btrfs/raid-stripe-tree.c
··· 45 45 46 46 for (int i = 0; i < btrfs_num_raid_stripes(item_size); i++) { 47 47 struct btrfs_raid_stride *stride = &extent->strides[i]; 48 + u64 devid; 48 49 u64 phys; 49 50 51 + devid = btrfs_raid_stride_devid(leaf, stride); 52 + btrfs_set_stack_raid_stride_devid(&newitem->strides[i], devid); 50 53 phys = btrfs_raid_stride_physical(leaf, stride) + frontpad; 51 54 btrfs_set_stack_raid_stride_physical(&newitem->strides[i], phys); 52 55 }