@@ -7351,6 +7351,11 @@ static int btrfs_dio_iomap_begin(struct inode *inode, loff_t start,
u64 len = length;
bool unlock_extents = false;
+ if (write && fs_info->max_zone_append_size) {
+ length = min_t(u64, length, fs_info->max_zone_append_size);
+ len = length;
+ }
+
if (!write)
len = min_t(u64, len, fs_info->sectorsize);
@@ -7692,6 +7697,8 @@ static void btrfs_end_dio_bio(struct bio *bio)
if (err)
dip->dio_bio->bi_status = err;
+ btrfs_record_physical_zoned(dip->inode, dip->logical_offset, bio);
+
bio_put(bio);
btrfs_dio_private_put(dip);
}
@@ -7701,7 +7708,8 @@ static inline blk_status_t btrfs_submit_dio_bio(struct bio *bio,
{
struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
struct btrfs_dio_private *dip = bio->bi_private;
- bool write = bio_op(bio) == REQ_OP_WRITE;
+ bool write = bio_op(bio) == REQ_OP_WRITE ||
+ bio_op(bio) == REQ_OP_ZONE_APPEND;
blk_status_t ret;
/* Check btrfs_submit_bio_hook() for rules about async submit. */
@@ -7846,6 +7854,12 @@ static blk_qc_t btrfs_submit_direct(struct inode *inode, struct iomap *iomap,
bio->bi_end_io = btrfs_end_dio_bio;
btrfs_io_bio(bio)->logical = file_offset;
+ if (write && btrfs_fs_incompat(fs_info, ZONED) &&
+ fs_info->max_zone_append_size) {
+ bio->bi_opf &= ~REQ_OP_MASK;
+ bio->bi_opf |= REQ_OP_ZONE_APPEND;
+ }
+
ASSERT(submit_len >= clone_len);
submit_len -= clone_len;
This commit enables zone append writing as same as in buffered write. Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com> --- fs/btrfs/inode.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)