• Naohiro Aota's avatar
    btrfs: zoned: split ordered extent when bio is sent · d22002fd
    Naohiro Aota authored
    For a zone append write, the device decides the location the data is being
    written to. Therefore we cannot ensure that two bios are written
    consecutively on the device. In order to ensure that an ordered extent
    maps to a contiguous region on disk, we need to maintain a "one bio ==
    one ordered extent" rule.
    
    Implement splitting of an ordered extent and extent map on bio submission
    to adhere to the rule.
    
    extract_ordered_extent() hooks into btrfs_submit_data_bio() and splits the
    corresponding ordered extent so that the ordered extent's region fits into
    one bio and the corresponding device limits.
    
    Several sanity checks need to be done in extract_ordered_extent() e.g.
    
    - We cannot split once end_bio'd ordered extent because we cannot divide
      ordered->bytes_left for the split ones
    - We do not expect a compressed ordered extent
    - We should not have checksum list because we omit the list splitting.
      Since the function is called before btrfs_wq_submit_bio() or
      btrfs_csum_one_bio(), this should be always ensured.
    
    We also need to split an extent map by creating a new one. If not,
    unpin_extent_cache() complains about the difference between the start of
    the extent map and the file's logical offset.
    Reviewed-by: default avatarJosef Bacik <josef@toxicpanda.com>
    Signed-off-by: default avatarNaohiro Aota <naohiro.aota@wdc.com>
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    d22002fd
inode.c 292 KB