• Christoph Hellwig's avatar
    btrfs: don't rely on unchanging ->bi_bdev for zone append remaps · 04f0847c
    Christoph Hellwig authored
    btrfs_record_physical_zoned relies on a bio->bi_bdev samples in the
    bio_end_io handler to find the reverse map for remapping the zone append
    write, but stacked block device drivers can and usually do change bi_bdev
    when sending on the bio to a lower device.  This can happen e.g. with the
    nvme-multipath driver when a NVMe SSD sets the shared namespace bit.
    
    But there is no real need for the bdev in btrfs_record_physical_zoned,
    as it is only passed to btrfs_rmap_block, which uses it to pick the
    mapping to report if there are multiple reverse mappings.  As zone
    writes can only do simple non-mirror writes right now, and anything
    more complex will use the stripe tree there is no chance of the multiple
    mappings case actually happening.
    
    Instead open code the subset of btrfs_rmap_block in
    btrfs_record_physical_zoned, which also removes a memory allocation and
    remove the bdev field in the ordered extent.
    
    Fixes: d8e3fb10 ("btrfs: zoned: use ZONE_APPEND write for zoned mode")
    Reviewed-by: default avatarJosef Bacik <josef@toxicpanda.com>
    Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    04f0847c
ordered-data.h 6.32 KB