diff options
author | Johannes Thumshirn <johannes.thumshirn@wdc.com> | 2021-02-04 11:22:03 +0100 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2021-02-09 02:46:05 +0100 |
commit | 08f455593fff701e103876d4db5d3f4f6d0ff871 (patch) | |
tree | 21c7fd1247437897726a182c1b9eb91bdbae267f /fs/btrfs/zoned.c | |
parent | btrfs: extend btrfs_rmap_block for specifying a device (diff) | |
download | linux-08f455593fff701e103876d4db5d3f4f6d0ff871.tar.xz linux-08f455593fff701e103876d4db5d3f4f6d0ff871.zip |
btrfs: zoned: cache if block group is on a sequential zone
On a zoned filesystem, cache if a block group is on a sequential write
only zone.
On sequential write only zones, we can use REQ_OP_ZONE_APPEND for
writing data, therefore provide btrfs_use_zone_append() to figure out if
IO is targeting a sequential write only zone and we can use
REQ_OP_ZONE_APPEND for data writing.
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/zoned.c')
-rw-r--r-- | fs/btrfs/zoned.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c index 1de67d789b83..f6c68704c840 100644 --- a/fs/btrfs/zoned.c +++ b/fs/btrfs/zoned.c @@ -1101,6 +1101,9 @@ int btrfs_load_block_group_zone_info(struct btrfs_block_group *cache, bool new) } } + if (num_sequential > 0) + cache->seq_zone = true; + if (num_conventional > 0) { /* * Avoid calling calculate_alloc_pointer() for new BG. It @@ -1218,3 +1221,29 @@ void btrfs_free_redirty_list(struct btrfs_transaction *trans) } spin_unlock(&trans->releasing_ebs_lock); } + +bool btrfs_use_zone_append(struct btrfs_inode *inode, struct extent_map *em) +{ + struct btrfs_fs_info *fs_info = inode->root->fs_info; + struct btrfs_block_group *cache; + bool ret = false; + + if (!btrfs_is_zoned(fs_info)) + return false; + + if (!fs_info->max_zone_append_size) + return false; + + if (!is_data_inode(&inode->vfs_inode)) + return false; + + cache = btrfs_lookup_block_group(fs_info, em->block_start); + ASSERT(cache); + if (!cache) + return false; + + ret = cache->seq_zone; + btrfs_put_block_group(cache); + + return ret; +} |