diff options
author | Naohiro Aota <naohiro.aota@wdc.com> | 2020-11-10 14:26:08 +0300 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2020-12-09 21:16:03 +0300 |
commit | b70f509774ad4b75d4253ad23b65c35d89402026 (patch) | |
tree | 5390be7abefc309d9c0ecd6e449d05277a98c8e9 /fs/btrfs/zoned.h | |
parent | 5b316468983dfa9473ff0f1c42e4e30b4c267141 (diff) | |
download | linux-b70f509774ad4b75d4253ad23b65c35d89402026.tar.xz |
btrfs: check and enable ZONED mode
Introduce function btrfs_check_zoned_mode() to check if ZONED flag is
enabled on the file system and if the file system consists of zoned
devices with equal zone size.
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/zoned.h')
-rw-r--r-- | fs/btrfs/zoned.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/fs/btrfs/zoned.h b/fs/btrfs/zoned.h index 00c871f09d03..e4ee1a50be2d 100644 --- a/fs/btrfs/zoned.h +++ b/fs/btrfs/zoned.h @@ -4,6 +4,7 @@ #define BTRFS_ZONED_H #include <linux/types.h> +#include <linux/blkdev.h> struct btrfs_zoned_device_info { /* @@ -22,6 +23,7 @@ int btrfs_get_dev_zone(struct btrfs_device *device, u64 pos, struct blk_zone *zone); int btrfs_get_dev_zone_info(struct btrfs_device *device); void btrfs_destroy_dev_zone_info(struct btrfs_device *device); +int btrfs_check_zoned_mode(struct btrfs_fs_info *fs_info); #else /* CONFIG_BLK_DEV_ZONED */ static inline int btrfs_get_dev_zone(struct btrfs_device *device, u64 pos, struct blk_zone *zone) @@ -36,6 +38,15 @@ static inline int btrfs_get_dev_zone_info(struct btrfs_device *device) static inline void btrfs_destroy_dev_zone_info(struct btrfs_device *device) { } +static inline int btrfs_check_zoned_mode(const struct btrfs_fs_info *fs_info) +{ + if (!btrfs_is_zoned(fs_info)) + return 0; + + btrfs_err(fs_info, "zoned block devices support is not enabled"); + return -EOPNOTSUPP; +} + #endif static inline bool btrfs_dev_is_sequential(struct btrfs_device *device, u64 pos) @@ -84,4 +95,19 @@ static inline void btrfs_dev_clear_zone_empty(struct btrfs_device *device, u64 p btrfs_dev_set_empty_zone_bit(device, pos, false); } +static inline bool btrfs_check_device_zone_type(const struct btrfs_fs_info *fs_info, + struct block_device *bdev) +{ + u64 zone_size; + + if (btrfs_is_zoned(fs_info)) { + zone_size = bdev_zone_sectors(bdev) << SECTOR_SHIFT; + /* Do not allow non-zoned device */ + return bdev_is_zoned(bdev) && fs_info->zone_size == zone_size; + } + + /* Do not allow Host Manged zoned device */ + return bdev_zoned_model(bdev) != BLK_ZONED_HM; +} + #endif |