On 1/15/21 1:53 AM, Naohiro Aota wrote:
From: Johannes Thumshirn <johannes.thumshirn@xxxxxxx>
Run zoned btrfs mode on non-zoned devices. This is done by "slicing
up" the block-device into static sized chunks and fake a conventional zone
on each of them. The emulated zone size is determined from the size of
device extent.
This is mainly aimed at testing parts of the zoned mode, i.e. the zoned
chunk allocator, on regular block devices.
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@xxxxxxx>
Signed-off-by: Naohiro Aota <naohiro.aota@xxxxxxx>
---
fs/btrfs/zoned.c | 149 +++++++++++++++++++++++++++++++++++++++++++----
fs/btrfs/zoned.h | 14 +++--
2 files changed, 147 insertions(+), 16 deletions(-)
diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c
index 684dad749a8c..13b240e5db4e 100644
--- a/fs/btrfs/zoned.c
+++ b/fs/btrfs/zoned.c
@@ -119,6 +119,37 @@ static inline u32 sb_zone_number(int shift, int mirror)
return 0;
}
+/*
+ * Emulate blkdev_report_zones() for a non-zoned device. It slice up
+ * the block device into static sized chunks and fake a conventional zone
+ * on each of them.
+ */
+static int emulate_report_zones(struct btrfs_device *device, u64 pos,
+ struct blk_zone *zones, unsigned int nr_zones)
+{
+ const sector_t zone_sectors =
+ device->fs_info->zone_size >> SECTOR_SHIFT;
+ sector_t bdev_size = device->bdev->bd_part->nr_sects;
This needs to be changed to bdev_nr_sectors(), it fails to compile on misc-next.
This patch also fails to apply to misc-next as well. Thanks,
Josef