Add support for storage element depopulation
Subsystems (7)
Damien Le Moal
maintainerv4 cover Add support for storage element depopulation
Jens,
These patches define a new set of block device operations for generically using from the block layer the storage element depopulation feature of zoned block devices. Support for this feature is added to the SCSI disk driver and an emulation of this feature added to the zloop driver.
The management operations can be accessed using block layer API, which is intended for file systems (e.g. zonefs and XFS), as well as using ioctls for users using zoned disks directly from user space.
Changes from v3:
- Reworked patch 1 to only provide the disk_zone_is_offline() helper function. Failing of read operations to offline zones is handled directly by the zloop driver and the new patch 7 is added to handle failing early read operations to offline zones of ZBC SCSI disks.
- Added patch 2
- Addressed further valid comments from Sashiko
(https://sashiko.dev/#/patchset/20261006124510.882017-1-dlemoal%40kernel.org)
The biggest changes are in patch 2 to save the number of storage elements of a disk in struct gendisk and to serialize the execution of the storage element management operations using the zone revalidation mutex.
- Rebased on latest block/for-next
Changes from v2:
- Addressed further valid comments from Sashiko
(https://sashiko.dev/#/patchset/20261006124510.882017-1-dlemoal%40kernel.org)
- Rebased on latest block/for-next
Changes from v1:
- Addressed the many valid comments that Sashiko had
(https://sashiko.dev/#/patchset/20261005094632.580753-1-dlemoal%40kernel.org)
- Rebased on latest block/for-next
Damien Le Moal (9):
block: introduce disk_zone_is_offline()
block: refactor blk_revalidate_disk_zones()
block: introduce storage element management
block: add storage element management ioctls
zloop: add storage element emulation
zloop: add degrade_element control command
scsi: sd: fail read commands to offline zones early
scsi: sd_zbc: always revalidate zones for disks supporting head depopulation
scsi: sd_zbc: define storage element management operations
.../admin-guide/blockdev/zoned_loop.rst | 8 +- block/blk-zoned.c | 486 +++++++++++- block/blk.h | 14 + block/genhd.c | 4 + block/ioctl.c | 5 + drivers/block/zloop.c | 708 ++++++++++++++++-- drivers/scsi/sd.c | 11 +- drivers/scsi/sd.h | 3 + drivers/scsi/sd_zbc.c | 259 ++++++- include/linux/blkdev.h | 31 + include/uapi/linux/blkzoned.h | 82 ++ include/uapi/linux/fs.h | 1 + 12 files changed, 1535 insertions(+), 77 deletions(-)
Signature · 1 line
2.55.0
Damien Le Moal
maintainerPATCH v4 1/9 block: introduce disk_zone_is_offline()
Introduce the helper function disk_zone_is_offline() for testing if a zone of a gendisk has the offline condition. The zone to test is identified using a sector number that must belong to the target zone to check.
--- block/blk-zoned.c | 16 ++++++++++++++++ include/linux/blkdev.h | 9 +++++++++ 2 files changed, 25 insertions(+)
block/blk-zoned.c +16 -0
@@ -292,6 +292,22 @@ static bool disk_zone_is_seq(struct gendisk *disk, sector_t sector)return !blk_zstate_is_conv (zs); } +/** +* disk_zone_is_offline - check if a sector belongs to an offline zone +* @disk: gendisk to check +* @sector: sector number +* +* Check if @sector on @disk is contained in an offline zone. +*/ +bool disk_zone_is_offline (struct gendisk *disk,sector_t sector) +{ +if (!blk_queue_is_zoned (disk->queue)) +return false; + +return disk_zone_get_cond (disk, sector) ==BLK_ZONE_COND_OFFLINE ; +} +EXPORT_SYMBOL_GPL (disk_zone_is_offline); +/** * bdev_zone_is_seq - check if a sector belongs to a sequential write zone * @bdev: block device to check
include/linux/blkdev.h +9 -0
@@ -942,6 +942,9 @@ static inline unsigned int disk_zone_capacity(struct gendisk *disk,return disk->last_zone_capacity;return disk->zone_capacity; } + +bool disk_zone_is_offline (struct gendisk *disk,sector_t sector); +static inline unsigned int bdev_zone_capacity (struct block_device *bdev,sector_t pos) {
@@ -956,6 +959,12 @@ static inline unsigned int disk_nr_zones(struct gendisk *disk)return 0 ; } +static inline bool disk_zone_is_offline (struct gendisk *disk, +sector_t sector) +{ +return false; +} +static inline bool bdev_zone_is_seq (struct block_device *bdev,sector_t sector) {return false;
Signature · 1 line
2.55.0
Damien Le Moal
maintainerPATCH v4 2/9 block: refactor blk_revalidate_disk_zones()
In reply to Damien Le MoalSplit out most of the code of blk_revalidate_disk_zones() into the internal function disk_revalidate_zones(). This will allow calling this new helper together with other code under the zone revalidation mutex. No functional change.
--- block/blk-zoned.c | 63 +++++++++++++++++++++++++---------------------- 1 file changed, 34 insertions(+), 29 deletions(-)
block/blk-zoned.c +34 -29
@@ -2542,20 +2542,7 @@ static int blk_revalidate_zone_cb(struct blk_zone *zone, unsigned int idx,return ret; } -/** -* blk_revalidate_disk_zones - (re)allocate and initialize zone write plugs -* @disk: Target disk -* -* Helper function for low-level device drivers to check, (re) allocate and -* initialize resources used for managing zoned disks. This function should -* normally be called by blk-mq based drivers when a zoned gendisk is probed -* and when the zone configuration of the gendisk changes (e.g. after a format). -* Before calling this function, the device driver must already have set the -* device zone size (chunk_sector limit) and the max zone append limit. -* BIO based drivers can also use this function as long as the device queue -* can be safely frozen. -*/ -int blk_revalidate_disk_zones (struct gendisk *disk) +static int disk_revalidate_zones (struct gendisk *disk) {struct blk_revalidate_zone_args args = { };struct blk_report_zones_args rep_args = {
@@ -2566,19 +2553,10 @@ int blk_revalidate_disk_zones(struct gendisk *disk)int retries =2 ;int ret; -if (WARN_ON_ONCE (!blk_queue_is_zoned (disk->queue))) -return -EIO ; - -/* -* Serialize calls to this function so that we can safely look at and -* eventually change the disk zone information. -*/ -mutex_lock (&disk->zone_revalidate_mutex); - again: ret =disk_revalidate_capacity (disk, &args);if (ret) - goto unlock; +return ret;/* * Allocate zone resources if they are needed and we have not done
@@ -2591,14 +2569,14 @@ int blk_revalidate_disk_zones(struct gendisk *disk) ret =disk_alloc_zone_resources (disk, args.capacity);if (ret) {memalloc_noio_restore (noio_flag); - goto unlock; +return ret; } } ret =disk_init_revalidate_args (disk, &args);if (ret) {memalloc_noio_restore (noio_flag); - goto unlock; +return ret; } ret = disk->fops->report_zones (disk,0 ,UINT_MAX , &rep_args);
@@ -2615,8 +2593,6 @@ int blk_revalidate_disk_zones(struct gendisk *disk)if (ret) goto free_args; -mutex_unlock (&disk->zone_revalidate_mutex); -return 0 ; free_args:
@@ -2632,7 +2608,36 @@ int blk_revalidate_disk_zones(struct gendisk *disk) }pr_warn ("%s: failed to revalidate zones\n" , disk->disk_name); -unlock: + +return ret; +} + +/** +* blk_revalidate_disk_zones - (re)allocate and initialize zone write plugs +* @disk: Target disk +* +* Helper function for low-level device drivers to check, (re) allocate and +* initialize resources used for managing zoned disks. This function should +* normally be called by blk-mq based drivers when a zoned gendisk is probed +* and when the zone configuration of the gendisk changes (e.g. after a format). +* Before calling this function, the device driver must already have set the +* device zone size (chunk_sector limit) and the max zone append limit. +* BIO based drivers can also use this function as long as the device queue +* can be safely frozen. +*/ +int blk_revalidate_disk_zones (struct gendisk *disk) +{ +int ret; + +if (WARN_ON_ONCE (!blk_queue_is_zoned (disk->queue))) +return -EIO ; + +/* +* Serialize calls to this function so that we can safely look at and +* eventually change the disk zone information. +*/ +mutex_lock (&disk->zone_revalidate_mutex); + ret =disk_revalidate_zones (disk);mutex_unlock (&disk->zone_revalidate_mutex);return ret;
Signature · 1 line
2.55.0
Damien Le Moal
maintainerPATCH v4 3/9 block: introduce storage element management
In reply to Damien Le MoalRecent SCSI (SBC) and ATA (ACS) standards define the storage element depopulation feature. This feature is intended for managing hard-disks heads, either combined read-write heads or pairs of read and write heads, allowing to keep disks with defective heads longer in production by allowing "depopulating" (removing) defective heads.
This feature comes in two different flavors:
- A destructive version which removes a head and reformats the disk at a lower capacity point, restoaring a fully functional contiguous LBA address space.
- A data preserving version restricted to host-managed zoned disks, which marks the zones served by a removed head as offline or read-only.
In preparation for using the data-preserving flavor of the depopulation feature in file systems natively supporting zoned block devices, introduce a set of storage element management operations and functions to define generic calls into block device drivers for managing storage elements.
The set of operations is defined with struct blk_se_ops and includes three operations:
- report_elements: get information on a device storage elements state reported with the new struct blk_se.
- remove_element: depopulate a defective storage element
- restore_elements: restore depopulated storage elements
Each operation is called from the functions bdev_report_storage_elements(), bdev_remove_storage_element() and bdev_restore_storage_elements().
Removing a healthy storage element from a device is possible and useful for testing. The storage element restoration operation restore_elements allows repopulating such healthy element. Repopulating defective storage elements is generally not allowed by devices. The remove_element and restore_elements operations are executed under the zone revalidation lock so that they are serialized iand also serialized against user initiated device revalidation, thus allowing to always have a consistent view of the device zone conditions.
The device drivers of zoned block devices can indicate support for the storage element depopulation feature by specifying the storage element management operations with the se_ops field of struct block_device_operations.
--- block/blk-zoned.c | 257 +++++++++++++++++++++++++++++++++- block/blk.h | 5 + block/genhd.c | 4 + include/linux/blkdev.h | 22 +++ include/uapi/linux/blkzoned.h | 62 ++++++++ 5 files changed, 349 insertions(+), 1 deletion(-)
block/blk-zoned.c +256 -1
@@ -18,6 +18,7 @@#include <linux/mempool.h> #include <linux/kthread.h> #include <linux/freezer.h> +#include <linux/delay.h> #include <trace/events/block.h>
@@ -2721,5 +2722,259 @@ int queue_zone_wplugs_show(void *data, struct seq_file *m)return 0 ; } -#endif + +static int disk_se_mgmt_in_progress (struct gendisk *disk, +struct blk_se *elements, +bool *in_progress) +{ +unsigned int i, nr_se = disk->nr_storage_elements; +int ret; + +/* +* Check if we have storage elements being removed or restored. +*/ + ret = disk->fops->se_ops->report_elements (disk, elements, &nr_se); +if (ret) { +pr_err ("Failed to get storage elements\n" ); +return ret; + } + +for (i =0 ; i < nr_se; i++) { +switch (elements[i].status) { +case BLK_SE_STS_REMOVE_IN_PROGRESS : +case BLK_SE_STS_RESTORE_IN_PROGRESS : + *in_progress = true; +return 0 ; +default : +break ; + } + } + + *in_progress = false; + +return 0 ; +} + +static int disk_wait_for_se_mgmt_completion (struct gendisk *disk) +{ +struct blk_se *elements; +unsigned int noio_flag; +bool in_progress; +int ret; + + noio_flag =memalloc_noio_save (); + elements = kzalloc_objs(struct blk_se, disk->nr_storage_elements); +memalloc_noio_restore (noio_flag); +if (!elements) +return -ENOMEM ; + +/* +* Poll the storage elements heath state to detect the end of a +* removal or restoration operation. Since we do not know how long the +* operation may take, we cannot have a timeout on this loop. So check +* for fatal signals so that the user can terminate this retry loop if +* the device misbehaves. +*/ +while (1 ) { + ret =disk_se_mgmt_in_progress (disk, elements, &in_progress); +if (ret || !in_progress) +break ; + +if (fatal_signal_pending (current)) { + ret = -EINTR ; +break ; + } + +/* Not done yet: wait and retry. */ +msleep (1000 ); + } + +kfree (elements); + +return ret; +} + +/** +* bdev_report_storage_elements - report the storage elements of a zoned +* block device +* @bdev: the zoned block device to check +* @elements: array of storage element descriptors to fill +* @nr_elements: maximum size of @elements +* +* Fill at most @nr_elements storage element descriptors in the array +* @elements. The number of storage elements filled in the array is returned +* using @nr_elements. If @elements is NULL, only @nr_elements is returned to +* indicate the maximum number of storage elements of @bdev. +* +* Returns 0 on success and a negative error code on failure. +*/ +int bdev_report_storage_elements (struct block_device *bdev, +struct blk_se *elements, +unsigned int *nr_elements) +{ +struct gendisk *disk = bdev->bd_disk; + +if (!blk_queue_is_zoned (disk->queue) || !disk->nr_storage_elements) +return -EOPNOTSUPP ; + +if (!nr_elements) +return -EINVAL ; + +if (!elements) { + *nr_elements = disk->nr_storage_elements; +return 0 ; + } + + *nr_elements =min (*nr_elements, disk->nr_storage_elements); +if (!*nr_elements) +return -EINVAL ; + +return disk->fops->se_ops->report_elements (disk, elements, + nr_elements); +} +EXPORT_SYMBOL_GPL (bdev_report_storage_elements); + +/** +* bdev_remove_storage_element - Remove (depopulate) a storage element of a +* zoned block device +* @bdev: block device to operate on +* @element_id: ID of the storage element to remove +* +* Remove (depopulate) the storage element identified by @element_id from the +* block device @bdev. The caller is responsible for taking care of any +* necessary device write cache flush and invalidation of cached data for the +* zones that will be offlined. +* +* Returns 0 on success and a negative error code on failure. +*/ +int bdev_remove_storage_element (struct block_device *bdev, +unsigned int element_id) +{ +struct gendisk *disk = bdev->bd_disk; +unsigned int memflags; +int ret; + +if (!blk_queue_is_zoned (disk->queue) || !disk->nr_storage_elements) +return -EOPNOTSUPP ; + +/* Zero is not a valid storage element ID. */ +if (!element_id) +return -EINVAL ; + +/* +* Serialize against concurrent revalidation and concurrent storage +* element management operations so that we can see consistent zone +* condition changes. +*/ +mutex_lock (&disk->zone_revalidate_mutex); + +/* +* Freeze and unfreeze the queue to flush any outstanding command. +* The caller is responsible for not queuing up more I/Os by higher +* level means. +*/ + memflags =blk_mq_freeze_queue (disk->queue); +blk_mq_unfreeze_queue (disk->queue, memflags); + + ret = disk->fops->se_ops->remove_element (disk, element_id); +if (ret) + goto unlock; + +/* Revalidate the device zones once the opration completes. */ + ret =disk_wait_for_se_mgmt_completion (disk); +if (ret) + goto unlock; + + ret =disk_revalidate_zones (disk); + +unlock: +mutex_unlock (&disk->zone_revalidate_mutex); + +return ret; +} +EXPORT_SYMBOL_GPL (bdev_remove_storage_element); + +/** +* bdev_restore_storage_elements - Restore all depopulated storage elements of +* a zoned block device +* @bdev: block device to operate on +* +* Restore all storage elements of @bdev that have been depopulated. Not all +* elements may be restored by this operation. +* +* Returns 0 on success and a negative error code on failure. +*/ +int bdev_restore_storage_elements (struct block_device *bdev) +{ +struct gendisk *disk = bdev->bd_disk; +unsigned int memflags; +int ret; + +if (!blk_queue_is_zoned (disk->queue) || !disk->nr_storage_elements) +return -EOPNOTSUPP ; + +/* +* Serialize against concurrent revalidation and concurrent storage +* element management operations so that we can see consistent zone +* condition changes. +*/ +mutex_lock (&disk->zone_revalidate_mutex); + +/* +* Freeze and unfreeze the queue to flush any outstanding commands. +* The caller is responsible for not queuing up more I/O by higher +* level means. +*/ + memflags =blk_mq_freeze_queue (disk->queue); +blk_mq_unfreeze_queue (disk->queue, memflags); + + ret = disk->fops->se_ops->restore_elements (disk); +if (ret) + goto unlock; + + ret =disk_wait_for_se_mgmt_completion (disk); +if (ret) + goto unlock; + + ret =disk_revalidate_zones (disk); + +unlock: +mutex_unlock (&disk->zone_revalidate_mutex); + +return ret; +} +EXPORT_SYMBOL_GPL (bdev_restore_storage_elements); + +int disk_init_storage_element_mgmt (struct gendisk *disk) +{ +int ret; + +/* +* Storage element operations are for zoned disks only and +* optional... +*/ +if (!blk_queue_is_zoned (disk->queue) || !disk->fops->se_ops) +return 0 ; + +/* ...but if supported, all operations must be defined. */ +if (!disk->fops->se_ops->report_elements || + !disk->fops->se_ops->remove_element || + !disk->fops->se_ops->restore_elements) { +pr_err ("%s: invalid storage element operations\n" , + disk->disk_name); +return -EINVAL ; + } + +/* +* Get the number of storage elements of the disk. If this fails, +* do not report an error as the failure may be because the zoned disk +* does not support storage element management. +*/ + ret = disk->fops->se_ops->report_elements (disk,NULL , + &disk->nr_storage_elements); +if (ret) + disk->nr_storage_elements =0 ; + +return 0 ; +}
block/blk.h +5 -0
@@ -527,6 +527,7 @@ static inline void ioc_clear_queue(struct request_queue *q)#endif /* CONFIG_BLK_ICQ */ #ifdef CONFIG_BLK_DEV_ZONED +int disk_init_storage_element_mgmt (struct gendisk *disk);void disk_init_zone_resources (struct gendisk *disk);void disk_release_zone_resources (struct gendisk *disk);static inline bool bio_zone_write_plugging (struct bio *bio)
@@ -579,6 +580,10 @@ int blkdev_zone_mgmt_ioctl(struct block_device *bdev, blk_mode_t mode, unsigned int cmd, unsigned long arg);bool bdev_zone_mgmt_allowed (struct block_device *bdev,sector_t sector);#else /* CONFIG_BLK_DEV_ZONED */ +static inline int disk_init_storage_element_mgmt (struct gendisk *disk) +{ +return 0 ; +}static inline void disk_init_zone_resources (struct gendisk *disk) { }
block/genhd.c +4 -0
@@ -435,6 +435,10 @@ static int __add_disk(struct device *parent, struct gendisk *disk,if (WARN_ON_ONCE (bdev_nr_sectors (disk->part0) >BLK_DEV_MAX_SECTORS ))return -EINVAL ; + ret =disk_init_storage_element_mgmt (disk); +if (ret) +return ret; +if (queue_is_mq (disk->queue)) {/* * ->submit_bio and ->poll_bio are bypassed for blk-mq drivers.
include/linux/blkdev.h +22 -0
@@ -189,6 +189,11 @@ struct gendisk {struct disk_events *ev;#ifdef CONFIG_BLK_DEV_ZONED +/* +* Total number of storage elements of the disk. This is always 0 for +* disks that do not support storage element management. +*/ +unsigned int nr_storage_elements;/* * Zoned block device information. Reads of this information must be * protected with blk_queue_enter() / blk_queue_exit() or by holding a
@@ -1583,6 +1588,22 @@ enum blk_unique_id { BLK_UID_NAA = 3, }; +/* Storage element management operations. */ +struct blk_se_ops { +int (*report_elements)(struct gendisk *disk, +struct blk_se *elements, +unsigned int *nr_elements); +int (*remove_element)(struct gendisk *disk,unsigned int element_id); +int (*restore_elements)(struct gendisk *disk); +}; + +int bdev_report_storage_elements (struct block_device *bdev, +struct blk_se *elements, +unsigned int *nr_elements); +int bdev_remove_storage_element (struct block_device *bdev, +unsigned int element_id); +int bdev_restore_storage_elements (struct block_device *bdev); +struct block_device_operations {void (*submit_bio)(struct bio *bio); int (*poll_bio)(struct bio *bio, struct io_comp_batch *iob,
@@ -1610,6 +1631,7 @@ struct block_device_operations { enum blk_unique_id id_type);struct module *owner;const struct pr_ops *pr_ops; +const struct blk_se_ops *se_ops;/* * Special callback for probing GPT entry at a given sector.
include/uapi/linux/blkzoned.h +62 -0
66 lines not on this page · raw message
Signature · 1 line
2.55.0
Damien Le Moal
maintainerPATCH v4 4/9 block: add storage element management ioctls
In reply to Damien Le MoalDefine the new ioctl commands BLKGETNRSTORELEMS, BLKREPORTSTORELEMS, BLKREMOVESTORELEM, and BLKRESTORESTORELEMS to provide users accessing zoned block devices directly with an interface to the storage elements management operations of the block layer.
The ioctls BLKGETNRSTORELEMS and BLKREPORTSTORELEMS are defined to respectively get the number of storage elements of a zoned device and to get an array of struct blk_storage_element describing the current state of the device storage elements.
The ioctl BLKREMOVESTORELEM can be used to remove (depopulate) a storage element that has a degraded status (i.e. BLK_SE_STS_DEGRADED).
Finally, the BLKRESTORESTORELEMS ioctl interfaces with bdev_restore_storage_elements() to restore the depopulated storage elements of a zoned device.
--- block/blk-zoned.c | 150 ++++++++++++++++++++++++++++++++++ block/blk.h | 9 ++ block/ioctl.c | 5 ++ include/uapi/linux/blkzoned.h | 20 +++++ include/uapi/linux/fs.h | 1 + 5 files changed, 185 insertions(+)
block/blk-zoned.c +150 -0
@@ -19,6 +19,7 @@#include <linux/kthread.h> #include <linux/freezer.h> #include <linux/delay.h> +#include <linux/uaccess.h> #include <trace/events/block.h>
@@ -2835,6 +2836,56 @@ int bdev_report_storage_elements(struct block_device *bdev, }EXPORT_SYMBOL_GPL (bdev_report_storage_elements); +static int blkdev_get_nr_storage_elements_ioctl (struct block_device *bdev, +void __user *argp) +{ +struct gendisk *disk = bdev->bd_disk; + +if (put_user (disk->nr_storage_elements, (unsigned int __user *)argp)) +return -EFAULT ; + +return 0 ; +} + +static int blkdev_report_storage_elements_ioctl (struct block_device *bdev, +void __user *argp) +{ +struct gendisk *disk = bdev->bd_disk; +struct blk_se_report *rep; +int ret; + +if (!argp) +return -EINVAL ; + + rep =kzalloc_flex (*rep, elements, disk->nr_storage_elements); +if (!rep) +return -ENOMEM ; + +if (copy_from_user (rep, argp,sizeof (struct blk_se_report ))) { + ret = -EFAULT ; + goto free_rep; + } + + rep->nr_elements =min (rep->nr_elements, disk->nr_storage_elements); +if (!rep->nr_elements) { + ret = -EINVAL ; + goto free_rep; + } + + ret =bdev_report_storage_elements (bdev, rep->elements, + &rep->nr_elements); +if (ret) + goto free_rep; + + if (copy_to_user(argp, rep, struct_size_t(struct blk_se_report, + elements, rep->nr_elements))) + ret = -EFAULT ; + +free_rep: +kfree (rep); +return ret; +} +/** * bdev_remove_storage_element - Remove (depopulate) a storage element of a * zoned block device
@@ -2895,6 +2946,54 @@ int bdev_remove_storage_element(struct block_device *bdev, }EXPORT_SYMBOL_GPL (bdev_remove_storage_element); +static int blkdev_flush_and_truncate (struct block_device *bdev, +blk_mode_t mode) +{ +int ret; + +filemap_invalidate_lock (bdev->bd_mapping); + ret =blkdev_issue_flush (bdev->bd_disk->part0); +if (!ret) + ret =truncate_bdev_range (bdev, mode,0 , +bdev_nr_bytes (bdev) -1 ); +filemap_invalidate_unlock (bdev->bd_mapping); + +return ret; +} + +static int blkdev_remove_storage_element_ioctl (struct block_device *bdev, +blk_mode_t mode,void __user *argp) +{ +unsigned int element_id; +int ret; + +if (!(mode &BLK_OPEN_WRITE )) +return -EBADF ; +if (bdev_read_only (bdev)) +return -EPERM ; + +if (get_user (element_id, (unsigned int __user *)argp)) +return -EFAULT ; + +inode_lock (bdev->bd_mapping->host); + +/* +* Flush the device volatile write cache and invalidate all cached data +* so that reads do not return old data for zones that went offline. +* Since a user can only write to zoned devices using direct IOs, we +* should never have any dirty page invalidated and so no data loss as +* long as the device cache flush succeeds, that is, as long as the +* flush does not use degraded storage elements. +*/ + ret =blkdev_flush_and_truncate (bdev, mode); +if (!ret) + ret =bdev_remove_storage_element (bdev, element_id); + +inode_unlock (bdev->bd_mapping->host); + +return ret; +} +/** * bdev_restore_storage_elements - Restore all depopulated storage elements of * a zoned block device
@@ -2946,6 +3045,32 @@ int bdev_restore_storage_elements(struct block_device *bdev) }EXPORT_SYMBOL_GPL (bdev_restore_storage_elements); +static int blkdev_restore_storage_elements_ioctl (struct block_device *bdev, +blk_mode_t mode) +{ +int ret; + +if (!(mode &BLK_OPEN_WRITE )) +return -EBADF ; +if (bdev_read_only (bdev)) +return -EPERM ; + +inode_lock (bdev->bd_mapping->host); + +/* +* Storage element restoration is a destructive operation that will +* reset all zones. So fflush the device volatile write cache and +* invalidate all cached data that we may have. +*/ + ret =blkdev_flush_and_truncate (bdev, mode); +if (!ret) + ret =bdev_restore_storage_elements (bdev); + +inode_unlock (bdev->bd_mapping->host); + +return ret; +} +int disk_init_storage_element_mgmt (struct gendisk *disk) {int ret;
@@ -2978,3 +3103,28 @@ int disk_init_storage_element_mgmt(struct gendisk *disk)return 0 ; } + +int blkdev_zone_storage_elements_ioctl (struct block_device *bdev, +blk_mode_t mode,unsigned int cmd, +void __user *argp) +{ +struct gendisk *disk = bdev->bd_disk; + +if (!disk->nr_storage_elements) +return -ENOTTY ; + +switch (cmd) { +case BLKGETNRSTORELEMS : +return blkdev_get_nr_storage_elements_ioctl (bdev, argp); +case BLKREPORTSTORELEMS : +return blkdev_report_storage_elements_ioctl (bdev, argp); +case BLKREMOVESTORELEM : +return blkdev_remove_storage_element_ioctl (bdev, mode, argp); +case BLKRESTORESTORELEMS : +return blkdev_restore_storage_elements_ioctl (bdev, mode); +default : +break ; + } + +return -ENOTTY ; +}
block/blk.h +9 -0
@@ -579,6 +579,9 @@ int blkdev_report_zones_ioctl(struct block_device *bdev, unsigned int cmd,int blkdev_zone_mgmt_ioctl (struct block_device *bdev,blk_mode_t mode,unsigned int cmd,unsigned long arg);bool bdev_zone_mgmt_allowed (struct block_device *bdev,sector_t sector); +int blkdev_zone_storage_elements_ioctl (struct block_device *bdev, +blk_mode_t mode,unsigned int cmd, +void __user *argp);#else /* CONFIG_BLK_DEV_ZONED */ static inline int disk_init_storage_element_mgmt (struct gendisk *disk) {
@@ -630,6 +633,12 @@ static inline bool bdev_zone_mgmt_allowed(struct block_device *bdev, {return false; } +static inline int blkdev_zone_storage_elements_ioctl (struct block_device *bdev, +blk_mode_t mode,unsigned int cmd, +void __user *argp) +{ +return -ENOTTY ; +}#endif /* CONFIG_BLK_DEV_ZONED */ struct block_device *bdev_alloc (struct gendisk *disk,u8 partno);
block/ioctl.c +5 -0
@@ -679,6 +679,11 @@ static int blkdev_common_ioctl(struct block_device *bdev, blk_mode_t mode,return put_uint (argp,bdev_zone_sectors (bdev));case BLKGETNRZONES :return put_uint (argp,bdev_nr_zones (bdev)); +case BLKGETNRSTORELEMS : +case BLKREPORTSTORELEMS : +case BLKREMOVESTORELEM : +case BLKRESTORESTORELEMS : +return blkdev_zone_storage_elements_ioctl (bdev, mode, cmd, argp);case BLKROGET :return put_int (argp,bdev_read_only (bdev) !=0 );case BLKSSZGET :/* get block device logical block size */
include/uapi/linux/blkzoned.h +20 -0
@@ -270,4 +270,24 @@ struct blk_se { __u8 reserved[13]; }; +struct blk_se_report { +__u32 nr_elements; +__u32 reserved; +struct blk_se elements[]; +}; + +/** +* Zoned block device storage element management ioctl's: +* +* @BLKGETNRSTORELEMS: Get the number of storage elements of the device. +* @BLKREPORTSTORELEMS: Get the device storage elements. +* @BLKREMOVESTORELEM: Remove (depopulate) one storage element of a device. +* @BLKRESTORESTORELEM: Restore (repopulate if possible) all storage elements +* that have been removed. +*/ +#define BLKGETNRSTORELEMS _IOR(0x12, 143, __u32) +#define BLKREPORTSTORELEMS _IOWR(0x12, 144, struct blk_se_report) +#define BLKREMOVESTORELEM _IOW(0x12, 145, __u32) +#define BLKRESTORESTORELEMS _IO(0x12, 146) +#endif /* _UAPI_BLKZONED_H */
include/uapi/linux/fs.h +1 -0
@@ -309,6 +309,7 @@ struct file_attr {/* 130-136 and 142 are used by zoned block device ioctls (uapi/linux/blkzoned.h) */ /* 137-141 are used by blk-crypto ioctls (uapi/linux/blk-crypto.h) */ #define BLKTRACESETUP2 _IOWR(0x12, 142, struct blk_user_trace_setup2) +/* 143-146 are used by storage element management for zoned block devices. */ #define BMAP_IOCTL 1/* obsolete - kept for compatibility */ #define FIBMAP _IO(0x00,1)/* bmap access */
Signature · 1 line
2.55.0
Damien Le Moal
maintainerPATCH v4 5/9 zloop: add storage element emulation
In reply to Damien Le MoalEmulate the storage element depopulation feature of SMR disks in the zloop driver. This emulation is controlled using the new stor_elements option.
This option can take several values:
- ZLOOP_STOR_ELEMENTS_NONE (0): no emulation (default)
- ZLOOP_STOR_ELEMENTS_RDWR (1): emulate all access storage elements (e.g. read+write heads)
- ZLOOP_STOR_ELEMENTS_PAIRS (2): emulate fractional access storage elements (e.g. pairs of read and write heads)
If enabled with the value 1 or 2, the number of storage elements, or of pairs of fractional access storage elements, is automatically calculated based on the number of zones of the device so that we have at least 2 and at most 32 storage elements (or 2 pairs of fractional access storage elements).
The mapping of zones to storage elements is defined simply as the modulo of a zone number and a storage element ID. E.g, removing a storage element from a set of 4 storage elements will offline 1 zone every 4 zones.
The storage element management operations are specified with the zloop_se_ops (struct blk_storage_elements_ops).
--- .../admin-guide/blockdev/zoned_loop.rst | 8 +- drivers/block/zloop.c | 619 ++++++++++++++++-- 2 files changed, 584 insertions(+), 43 deletions(-)
Documentation/admin-guide/blockdev/zoned_loop.rst +7 -1
@@ -61,7 +61,7 @@ The options available for the add command can be listed by reading the /dev/zloop-control device:: $ cat /dev/zloop-control - add id=%d,capacity_mb=%u,zone_size_mb=%u,zone_capacity_mb=%u,conv_zones=%u,max_open_zones=%u,base_dir=%s,nr_queues=%u,queue_depth=%u,buffered_io,zone_append=%u,ordered_zone_append,discard_write_cache + add id=%d,capacity_mb=%u,zone_size_mb=%u,zone_capacity_mb=%u,conv_zones=%u,max_open_zones=%u,base_dir=%s,nr_queues=%u,queue_depth=%u,buffered_io,zone_append=%u,ordered_zone_append,discard_write_cache,stor_elements=%u remove id=%d In more details, the options that can be used with the "add" command are as
@@ -113,6 +113,12 @@ discard_write_cache Discard all data that was not explicitly persisted using a each zone file to the size recorded during the last flush operation. This simulates power fail events where uncommitted data is lost. +stor_elements Control storage element emulation. The default value is 0, + indicating no emulation. A value of 1 indicates that all + access storage elements (equivalent to read+write head of + a disk) are emulated. A value of 2 enables fractional + access storage element (equivalent to pairs of read and + write heads of a disk) emulation . =================== ========================================================= 3) Deleting a Zoned Device
drivers/block/zloop.c +577 -42
863 lines not on this page · raw message
Signature · 1 line
2.55.0
Damien Le Moal
maintainerPATCH v4 6/9 zloop: add degrade_element control command
In reply to Damien Le MoalAllow users to mark storage elements of a zloop device as degraded using the new "degrade_element" control command. The element to degrade is indicated using the element_id option. Example:
echo "degrade_element id=0,element_id=2" > /dev/zloop-control
If the element ID identifies an all access storage element, read and write operations targeting a zone served by the degraded lement are failed. For a partial access storage element, read or write operations are failed depending on the storage element type. This check for an element status is done without taking the storage elements mutex lock, so in order to avoid memory access ordering issues, storage element status access is changed to use READ_ONCE() and WRITE_ONCE()
--- drivers/block/zloop.c | 91 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 88 insertions(+), 3 deletions(-)
drivers/block/zloop.c +88 -3
@@ -38,6 +38,7 @@ enum {ZLOOP_OPT_DISCARD_WRITE_CACHE = (1 <<11 ),ZLOOP_OPT_MAX_OPEN_ZONES = (1 <<12 ),ZLOOP_OPT_STOR_ELEMENTS = (1 <<13 ), + ZLOOP_OPT_ELEMENT_ID = (1 << 14), }; static const match_table_t zloop_opt_tokens = {
@@ -55,6 +56,7 @@ static const match_table_t zloop_opt_tokens = { { ZLOOP_OPT_DISCARD_WRITE_CACHE, "discard_write_cache" }, { ZLOOP_OPT_MAX_OPEN_ZONES, "max_open_zones=%u" }, { ZLOOP_OPT_STOR_ELEMENTS, "stor_elements=%u" }, + { ZLOOP_OPT_ELEMENT_ID, "element_id=%u" }, { ZLOOP_OPT_ERR, NULL } };
@@ -81,6 +83,7 @@ enum zloop_stor_elements {#define ZLOOP_DEF_ZONE_APPEND true#define ZLOOP_DEF_ORDERED_ZONE_APPEND false#define ZLOOP_DEF_STOR_ELEMENTS ZLOOP_STOR_ELEMENTS_NONE +#define ZLOOP_DEF_ELEMENT_ID 0/* Arbitrary limit on the zone size (16GB). */ #define ZLOOP_MAX_ZONE_SIZE_MB 16384
@@ -101,6 +104,7 @@ struct zloop_options {bool ordered_zone_append;bool discard_write_cache;enum zloop_stor_elements stor_elements; +unsigned int element_id; };/*
@@ -1001,7 +1005,8 @@ static bool zloop_prep_rq(struct zloop_device *zlo, struct request *rq) se = &zlo->elements[zone->wr_se_id -1 ]; else se = &zlo->elements[zone->rd_se_id -1 ]; -if (READ_ONCE (se->status) ==BLK_SE_STS_REMOVE_IN_PROGRESS ) { +if (READ_ONCE (se->status) ==BLK_SE_STS_DEGRADED || +READ_ONCE (se->status) ==BLK_SE_STS_REMOVE_IN_PROGRESS ) { ret = false; goto unlock; }
@@ -1173,6 +1178,31 @@ static int zloop_report_elements(struct gendisk *disk,return 0 ; } +static int zloop_degrade_element (struct zloop_device *zlo, +unsigned int element_id) +{ +struct blk_se *se; +int ret =0 ; + +if (zlo->stor_elements ==ZLOOP_STOR_ELEMENTS_NONE ) +return -EOPNOTSUPP ; + +if (!element_id || element_id > zlo->nr_elements) +return -EINVAL ; + +mutex_lock (&zlo->stor_elements_lock); + + se = &zlo->elements[element_id -1 ]; +if (READ_ONCE (se->status) ==BLK_SE_STS_OK ) +WRITE_ONCE (se->status,BLK_SE_STS_DEGRADED ); +else + ret = -EINVAL ; + +mutex_unlock (&zlo->stor_elements_lock); + +return ret; +} +static void zloop_remove_element_work (struct work_struct *work) { struct zloop_device *zlo = container_of(work, struct zloop_device,
@@ -2000,6 +2030,42 @@ static int zloop_ctl_remove(struct zloop_options *opts)return 0 ; } +static int zloop_ctl_degrade_element (struct zloop_options *opts) +{ +struct zloop_device *zlo; +int ret =0 ; + +if (!(opts->mask &ZLOOP_OPT_ID )) { +pr_err ("No ID specified for degrade_element\n" ); +return -EINVAL ; + } + +if (opts->mask & ~(ZLOOP_OPT_ID |ZLOOP_OPT_ELEMENT_ID )) { +pr_err ("Invalid option specified for degrade_element\n" ); +return -EINVAL ; + } + +mutex_lock (&zloop_ctl_mutex); + + zlo =idr_find (&zloop_index_idr, opts->id); +if (!zlo || zlo->state == Zlo_creating) + ret = -ENODEV ; +else if (zlo->state == Zlo_deleting) + ret = -EINVAL ; +if (ret) + goto unlock; + + ret =zloop_degrade_element (zlo, opts->element_id); +if (!ret) +pr_info ("Degraded element %u of device %u\n" , + opts->element_id, opts->id); + +unlock: +mutex_unlock (&zloop_ctl_mutex); + +return ret; +} +static int zloop_parse_options (struct zloop_options *opts,const char *buf) {substring_t args[MAX_OPT_ARGS ];
@@ -2020,6 +2086,7 @@ static int zloop_parse_options(struct zloop_options *opts, const char *buf) opts->zone_append =ZLOOP_DEF_ZONE_APPEND ; opts->ordered_zone_append =ZLOOP_DEF_ORDERED_ZONE_APPEND ; opts->stor_elements =ZLOOP_DEF_STOR_ELEMENTS ; + opts->element_id =ZLOOP_DEF_ELEMENT_ID ;if (!buf)return 0 ;
@@ -2171,6 +2238,13 @@ static int zloop_parse_options(struct zloop_options *opts, const char *buf) } opts->stor_elements = token;break ; +case ZLOOP_OPT_ELEMENT_ID : +if (match_uint (args, &token)) { + ret = -EINVAL ; + goto out; + } + opts->element_id = token; +break ;case ZLOOP_OPT_ERR :default :pr_warn ("unknown parameter or missing value '%s'\n" , p);
@@ -2199,14 +2273,16 @@ static int zloop_parse_options(struct zloop_options *opts, const char *buf)enum {ZLOOP_CTL_ADD ,ZLOOP_CTL_REMOVE , +ZLOOP_CTL_DEGRADE_ELEMENT , };static struct zloop_ctl_op {int code;const char *name; } zloop_ctl_ops[] = { - {ZLOOP_CTL_ADD ,"add" }, - {ZLOOP_CTL_REMOVE ,"remove" }, + {ZLOOP_CTL_ADD ,"add" }, + {ZLOOP_CTL_REMOVE ,"remove" }, + {ZLOOP_CTL_DEGRADE_ELEMENT ,"degrade_element" }, {-1 ,NULL }, };
@@ -2254,6 +2330,9 @@ static ssize_t zloop_ctl_write(struct file *file, const char __user *ubuf,case ZLOOP_CTL_REMOVE : ret =zloop_ctl_remove (&opts);break ; +case ZLOOP_CTL_DEGRADE_ELEMENT : + ret =zloop_ctl_degrade_element (&opts); +break ;default :pr_err ("Invalid operation\n" ); ret = -EINVAL ;
@@ -2277,6 +2356,8 @@ static int zloop_ctl_show(struct seq_file *seq_file, void *private) tok = &zloop_opt_tokens[i];if (!tok->pattern)break ; +if (tok->token ==ZLOOP_OPT_ELEMENT_ID ) +continue ;if (i)seq_putc (seq_file,',' );seq_puts (seq_file, tok->pattern);
@@ -2287,6 +2368,10 @@ static int zloop_ctl_show(struct seq_file *seq_file, void *private)seq_puts (seq_file, zloop_ctl_ops[1 ].name);seq_puts (seq_file," id=%d\n" ); +/* Degrade element operation */ +seq_puts (seq_file, zloop_ctl_ops[2 ].name); +seq_puts (seq_file," id=%d,element_id=%d\n" ); +return 0 ; }
Signature · 1 line
2.55.0
Damien Le Moal
maintainerPATCH v4 7/9 scsi: sd: fail read commands to offline zones early
In reply to Damien Le MoalIssuing read commands to offline zones of a ZBC disk will result in failures. So do not issue such command and fail then early in sd_setup_read_write_cmnd(). This change also checks write commands, which is fine but should actually never happen as the block layer zone write plugging code already fails write BIOs to offline zones early in the submission path.
--- drivers/scsi/sd.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/scsi/sd.c +7 -1
@@ -1424,7 +1424,8 @@ static blk_status_t sd_setup_read_write_cmnd(struct scsi_cmnd *cmd) {struct request *rq =scsi_cmd_to_rq (cmd);struct scsi_device *sdp = cmd->device; -struct scsi_disk *sdkp =scsi_disk (rq->q->disk); +struct gendisk *disk = rq->q->disk; +struct scsi_disk *sdkp =scsi_disk (disk);sector_t lba =sectors_to_logical (sdp,blk_rq_pos (rq));sector_t threshold;unsigned int nr_blocks =sectors_to_logical (sdp,blk_rq_sectors (rq));
@@ -1456,6 +1457,11 @@ static blk_status_t sd_setup_read_write_cmnd(struct scsi_cmnd *cmd) goto fail; } +/* Prevent read/write to offline zones of ZBC disks. */ +if (sdkp->device->type ==TYPE_ZBC && +disk_zone_is_offline (disk,blk_rq_pos (rq))) + goto fail; +/* * Some SD card readers can't handle accesses which touch the * last one or two logical blocks. Split accesses as needed.
Signature · 1 line
2.55.0
Damien Le Moal
maintainerPATCH v4 8/9 scsi: sd_zbc: always revalidate zones for disks supporting head depopulation
In reply to Damien Le Moalsd_zbc_revalidate_zones() skips revalidating the zones of a ZBC device if the zone size and total number of zones of the disk has not changed. This is to avoid a call to the rather slow blk_revalidate_disk_zones().
However, for ZBC devices that support data preserving head depopulation (REMOVE ELEMENT AND MODIFY ZONES command), a disk capacity and number of zones does not change after a head is depopulated but the condition of zones changes as the zones served by the head that was depopulated become either read-only or offline. In this case, not calling blk_revalidate_disk_zones() prevents the block layer from taking appropriate actions on the zone write plugs of the disk for the zones that became read-only or offline.
Avoid any issue with the block layer view of the zone conditions by not skipping the call to blk_revalidate_disk_zones() for disks that support the REMOVE ELEMENT AND MODIFY ZONES command. This check is done from sd_zbc_read_zones() using the helper function sd_zbc_check_modify_zones(). The new scsi disk flag modify_zones_supported is defined to remember the result of this check.
--- drivers/scsi/sd.h | 1 + drivers/scsi/sd_zbc.c | 26 +++++++++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-)
drivers/scsi/sd.h +1 -0
@@ -156,6 +156,7 @@ struct scsi_disk { unsigned ignore_medium_access_errors : 1; unsigned rscs : 1; /* reduced stream control support */ unsigned use_atomic_write_boundary : 1; + unsigned modify_zones_supported : 1; };#define to_scsi_disk (obj) container_of(obj, struct scsi_disk, disk_dev)
drivers/scsi/sd_zbc.c +25 -1
@@ -516,6 +516,21 @@ static int sd_zbc_check_capacity(struct scsi_disk *sdkp, unsigned char *buf,return 0 ; } +/* +* sd_zbc_check_modify_zones - Check if the device supports depopulation +* @sdkp: Target disk +* @buf: command buffer +* +* Check if the device supports the REMOVE ELEMENT AND MODIFY ZONES command. +*/ +static inline bool sd_zbc_check_modify_zones (struct scsi_disk *sdkp, +unsigned char *buf) +{ +return scsi_report_opcode (sdkp->device, buf,SD_BUF_SIZE , +SERVICE_ACTION_IN_16 , +SAI_REMOVE_ELEMENT_AND_MODIFY_ZONES ) ==1 ; +} +static void sd_zbc_print_zones (struct scsi_disk *sdkp) {if (sdkp->device->type !=TYPE_ZBC || !sdkp->capacity)
@@ -554,9 +569,15 @@ int sd_zbc_revalidate_zones(struct scsi_disk *sdkp)if (!blk_queue_is_zoned (q))return 0 ; +/* +* If the zone size and number of zones has not changed, and the disk +* does not support depopulating heads, skip the rather slow call to +* blk_revalidate_disk_zones(). +*/ if (sdkp->zone_info.zone_blocks == zone_blocks && sdkp->zone_info.nr_zones == nr_zones && - disk->nr_zones == nr_zones) + disk->nr_zones == nr_zones && + !sdkp->modify_zones_supported)return 0 ; sdkp->zone_info.zone_blocks = zone_blocks;
@@ -620,6 +641,9 @@ int sd_zbc_read_zones(struct scsi_disk *sdkp, struct queue_limits *lim,if (ret !=0 ) goto err; +/* Check if REMOVE ELEMENT AND MODIFY ZONES is supported. */ + sdkp->modify_zones_supported =sd_zbc_check_modify_zones (sdkp, buf); + nr_zones =round_up (sdkp->capacity, zone_blocks) >>ilog2 (zone_blocks);if (nr_zones >INT_MAX ) { sd_printk(KERN_ERR, sdkp, "Too many zones (%llu)\n",
Signature · 1 line
2.55.0
Damien Le Moal
maintainerPATCH v4 9/9 scsi: sd_zbc: define storage element management operations
In reply to Damien Le MoalDefine the storage element management operations using struct blk_storage_elements_ops. These operations are valid only on SMR disks supporting the storage element depopulation feature.
--- drivers/scsi/sd.c | 3 + drivers/scsi/sd.h | 2 + drivers/scsi/sd_zbc.c | 233 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 238 insertions(+)
drivers/scsi/sd.c +3 -0
@@ -3943,6 +3943,9 @@ static const struct block_device_operations sd_fops = { .get_unique_id = sd_get_unique_id, .free_disk = scsi_disk_free_disk, .pr_ops = &sd_pr_ops, +#ifdef CONFIG_BLK_DEV_ZONED + .se_ops = &sd_zbc_se_ops, +#endif };/**
drivers/scsi/sd.h +2 -0
@@ -243,6 +243,8 @@ unsigned int sd_zbc_complete(struct scsi_cmnd *cmd, unsigned int good_bytes,int sd_zbc_report_zones (struct gendisk *disk,sector_t sector,unsigned int nr_zones,struct blk_report_zones_args *args); +extern const struct blk_se_ops sd_zbc_se_ops; +#else /* CONFIG_BLK_DEV_ZONED */ static inline int sd_zbc_read_zones(struct scsi_disk *sdkp,
drivers/scsi/sd_zbc.c +233 -0
239 lines not on this page · raw message
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH v4 5/9] zloop: add storage element emulation
In reply to Damien Le MoalThank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider: - [High] block: IDR and module leak on zloop_ctl_add error path - [High] block: zone reset vfs_truncate…
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] block: IDR and module leak on zloop_ctl_add error path
- [High] block: zone reset vfs_truncate races with in-flight IO
- [Medium] block/zloop: elements left in RESTORE_IN_PROGRESS on error
--
commit 2aa446d71ddca7634ded310055adccb68fd83788
Author: Damien Le Moal <[email protected]>
Subject: zloop: add storage element emulation
Emulate the storage element depopulation feature of SMR disks in the zloop driver. This emulation is controlled using the new stor_elements option.
Quoted 4 lines
drivers/block/zloop.c static int zloop_close_zone(struct zloop_device *zlo, unsigned int zone_no) · line 494
Quoted 10 lines
drivers/block/zloop.c +6
-1@@ -420,7 +486,22 @@ static int zloop_close_zone(struct zloop_device *zlo, unsigned int zone_no)return ret; } -static int zloop_reset_zone (struct zloop_device *zlo,unsigned int zone_no) +static int zloop_do_reset_zone (struct zloop_device *zlo, +struct zloop_zone *zone) +{ +if (vfs_truncate (&zone->file->f_path,0 )) +return -EIO ; +
[Severity: High]
Is there a potential race between this background truncation and active I/O?
When zloop_restore_elements() sets zlo->restore_in_progress = true and schedules the background restore work, it rejects new I/O but doesn't appear to drain in-flight I/O (for example, by using blk_mq_freeze_queue()).
If an in-flight REQ_OP_WRITE in zloop_cmd_workfn() executes zloop_seq_write_prep() (which acquires zone->wp_lock, but not zone->lock) at the same time this worker calls vfs_truncate(), could the worker truncate the file to 0 just before the write completes at the old write pointer? This might desync zone->wp and create a massive sparse file.
[ ... ]
Quoted 10 lines
drivers/block/zloop.c +10
-0+static void zloop_restore_elements_work (struct work_struct *work) +{ + struct zloop_device *zlo = container_of(work, struct zloop_device, + restore_elements_work.work); +struct zloop_zone *zone; +struct blk_se *se; +unsigned int i; +int ret; + +mutex_lock (&zlo->stor_elements_lock);
drivers/block/zloop.c static int zloop_report_zones(struct gendisk *disk, sector_t sector, · line 1342
Quoted 10 lines
drivers/block/zloop.c +10
-0+ +/* Reset all zones. */ +for (i =0 , zone = zlo->zones; i < zlo->nr_zones; i++, zone++) { +if (test_bit (ZLOOP_ZONE_CONV , &zone->flags)) { +zloop_restore_conv_zone (zlo, zone); +continue ; + } + ret =zloop_restore_seq_zone (zlo, zone); +if (ret) + goto out_unlock;
[Severity: Medium]
If a zone file truncation fails here, are the storage elements left indefinitely in the BLK_SE_STS_RESTORE_IN_PROGRESS state?
The error path jumps to out_unlock, which clears zlo->restore_in_progress but skips updating the se->status for individual elements. Should this error path transition the elements to BLK_SE_STS_RESTORE_ERROR instead, so that userspace queries (like zloop_report_elements()) return an accurate status?
Quoted 14 lines
drivers/block/zloop.c +14
-0+ } + +/* Restore all removed elements. */ +for (i =0 , se = zlo->elements; i < zlo->nr_elements; i++, se++) { +if (READ_ONCE (se->status) ==BLK_SE_STS_RESTORE_IN_PROGRESS ) +WRITE_ONCE (se->status,BLK_SE_STS_OK ); + } + + zlo->nr_removed_elements =0 ; + +out_unlock: +WRITE_ONCE (zlo->restore_in_progress, false); +mutex_unlock (&zlo->stor_elements_lock); +}
[ ... ]
Quoted 12 lines
drivers/block/zloop.c +4
-0@@ -1361,6 +1870,10 @@ static int zloop_ctl_add(struct zloop_options *opts) zlo->id, zlo->nr_zones, ((sector_t )zlo->zone_size <<SECTOR_SHIFT ) >>20 , zlo->block_size); +if (zlo->nr_elements) +pr_info ("zloop%d: %d storage elements\n" , + zlo->id, zlo->nr_elements); + pr_info("zloop%d: using %s%s zone append\n", zlo->id, zlo->ordered_zone_append ? "ordered " : "",
drivers/block/zloop.c static int zloop_ctl_add(struct zloop_options *opts) · line 1887
Quoted 5 lines
drivers/block/zloop.c +2
-0@@ -1370,6 +1883,8 @@ static int zloop_ctl_add(struct zloop_options *opts) out_cleanup_disk:put_disk (zlo->disk); +return ret; +
[Severity: High]
Does this early return bypass the IDR removal and module reference put?
If we return here, the out_free_idr label (which calls idr_remove()) and the final out label (which calls module_put(THIS_MODULE)) are completely skipped.
Since put_disk() ultimately triggers zloop_free_disk() which frees the zlo structure via kvfree(zlo), does leaving the freed pointer in zloop_index_idr create a dangling pointer for subsequent lookups? It also appears the module reference would be leaked permanently.
Quoted 3 lines
drivers/block/zloop.c +0
-0out_cleanup_tags:blk_mq_free_tag_set (&zlo->tag_set); out_close_files:
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=5
[email protected]
AI reviewRe: [PATCH v4 3/9] block: introduce storage element management
In reply to Damien Le MoalThank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [High] block: permanent zone state desync on signal or memory allocation failure - [Medium] block…
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] block: permanent zone state desync on signal or memory allocation failure
- [Medium] block: ignored storage element management error status
--
commit 47105e9f6e8f70ce8710089fec4d093f5ff51fde
Author: Damien Le Moal <[email protected]>
Subject: block: introduce storage element management
This commit introduces storage element management for zoned block devices. It defines generic operations to report, remove, and restore storage elements so that disks with defective heads can remain in production by depopulating the defective elements.
Quoted 3 lines
block/blk-zoned.c +0
-0
[ ... ]
Quoted 4 lines
block/blk-zoned.c +4
-0+static int disk_se_mgmt_in_progress (struct gendisk *disk, +struct blk_se *elements, +bool *in_progress) +{
[ ... ]
block/blk-zoned.c int queue_zone_wplugs_show(void *data, struct seq_file *m) · line 2750
Quoted 8 lines
block/blk-zoned.c +8
-0+for (i =0 ; i < nr_se; i++) { +switch (elements[i].status) { +case BLK_SE_STS_REMOVE_IN_PROGRESS : +case BLK_SE_STS_RESTORE_IN_PROGRESS : + *in_progress = true; +return 0 ; +default : +break ;
[Severity: Medium]
Do error statuses like BLK_SE_STS_REMOVE_ERROR fall through to the default case here?
If the device encounters an error during the removal, it changes the element's status to an error state. The polling loop then sees no elements are in progress, sets in_progress to false, and returns 0 instead of bubbling up the error.
Quoted 10 lines
block/blk-zoned.c +10
-0+ } + } + + *in_progress = false; + +return 0 ; +} + +static int disk_wait_for_se_mgmt_completion (struct gendisk *disk) +{
block/blk-zoned.c int queue_zone_wplugs_show(void *data, struct seq_file *m) · line 2770
Quoted 10 lines
block/blk-zoned.c +10
-0+struct blk_se *elements; +unsigned int noio_flag; +bool in_progress; +int ret; + + noio_flag =memalloc_noio_save (); + elements = kzalloc_objs(struct blk_se, disk->nr_storage_elements); +memalloc_noio_restore (noio_flag); +if (!elements) +return -ENOMEM ;
[Severity: High]
Does attempting to allocate the polling buffer after the hardware operation has already been initiated introduce a memory failure path that aborts synchronization?
If kzalloc_objs fails and returns -ENOMEM, the wait loop is skipped, which later bypasses the critical disk_revalidate_zones step in bdev_remove_storage_element. Could this leave the kernel's zone state permanently out of sync with the physical device conditions?
Quoted 6 lines
block/blk-zoned.c +6
-0+ +/* +* Poll the storage elements heath state to detect the end of a +* removal or restoration operation. Since we do not know how long the +* operation may take, we cannot have a timeout on this loop. So check +* for fatal signals so that the user can terminate this retry loop if
block/blk-zoned.c int queue_zone_wplugs_show(void *data, struct seq_file *m) · line 2786
Quoted 10 lines
block/blk-zoned.c +10
-0+* the device misbehaves. +*/ +while (1 ) { + ret =disk_se_mgmt_in_progress (disk, elements, &in_progress); +if (ret || !in_progress) +break ; + +if (fatal_signal_pending (current)) { + ret = -EINTR ; +break ;
[Severity: High]
Does permitting fatal signals to abandon the wait loop leave the hardware executing in the background with no mechanism to trigger a revalidation upon actual completion?
This error path propagates the aborted wait and also skips the vital zone revalidation step that keeps the kernel's view consistent with the device.
Quoted 10 lines
block/blk-zoned.c +10
-0+ } + +/* Not done yet: wait and retry. */ +msleep (1000 ); + } + +kfree (elements); + +return ret; +}
[ ... ]
Quoted 3 lines
block/blk-zoned.c +3
-0+int bdev_remove_storage_element (struct block_device *bdev, +unsigned int element_id) +{
[ ... ]
Quoted 5 lines
block/blk-zoned.c +5
-0+ ret = disk->fops->se_ops->remove_element (disk, element_id); +if (ret) + goto unlock; + +/* Revalidate the device zones once the opration completes. */
block/blk-zoned.c int queue_zone_wplugs_show(void *data, struct seq_file *m) · line 2894
Quoted 10 lines
block/blk-zoned.c +10
-0+ ret =disk_wait_for_se_mgmt_completion (disk); +if (ret) + goto unlock; + + ret =disk_revalidate_zones (disk); + +unlock: +mutex_unlock (&disk->zone_revalidate_mutex); + +return ret;
[Severity: Medium]
Because disk_se_mgmt_in_progress returns 0 on error states, does this unconditionally return 0 without verifying if the target element actually achieved the BLK_SE_STS_REMOVED status?
The caller might be incorrectly informed that the removal succeeded when it actually failed. Should the status of the specific element_id be explicitly verified for success after the polling wait completes?
Quoted 1 line
+}
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
[email protected]
AI reviewRe: [PATCH v4 4/9] block: add storage element management ioctls
In reply to Damien Le MoalThank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [High] block: concurrent direct I/O races with storage element reconfiguration - [High] block: Unbounded…
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] block: concurrent direct I/O races with storage element reconfiguration
- [High] block: Unbounded polling loop holds inode_lock and zone_revalidate_mutex causing Hung Task panics --
commit e4cab0ff5a156be0f826cb9112e51fcf1c9f08e0
Author: Damien Le Moal <[email protected]>
block: add storage element management ioctls
Define the new ioctl commands BLKGETNRSTORELEMS, BLKREPORTSTORELEMS, BLKREMOVESTORELEM, and BLKRESTORESTORELEMS to provide users accessing zoned block devices directly with an interface to the storage elements management operations of the block layer.
Quoted 4 lines
block/blk-zoned.c +0
-0
[ ... ]
Quoted 36 lines
block/blk-zoned.c +32
-0@@ -2895,6 +2946,54 @@ int bdev_remove_storage_element(struct block_device *bdev, }EXPORT_SYMBOL_GPL (bdev_remove_storage_element); +static int blkdev_flush_and_truncate (struct block_device *bdev, +blk_mode_t mode) +{ +int ret; + +filemap_invalidate_lock (bdev->bd_mapping); + ret =blkdev_issue_flush (bdev->bd_disk->part0); +if (!ret) + ret =truncate_bdev_range (bdev, mode,0 , +bdev_nr_bytes (bdev) -1 ); +filemap_invalidate_unlock (bdev->bd_mapping); + +return ret; +} + +static int blkdev_remove_storage_element_ioctl (struct block_device *bdev, +blk_mode_t mode,void __user *argp) +{ +unsigned int element_id; +int ret; + +if (!(mode &BLK_OPEN_WRITE )) +return -EBADF ; +if (bdev_read_only (bdev)) +return -EPERM ; + +if (get_user (element_id, (unsigned int __user *)argp)) +return -EFAULT ; + +inode_lock (bdev->bd_mapping->host); + +/*
block/blk-zoned.c int bdev_remove_storage_element(struct block_device *bdev, · line 2990
Quoted 10 lines
block/blk-zoned.c +10
-0+* Flush the device volatile write cache and invalidate all cached data +* so that reads do not return old data for zones that went offline. +* Since a user can only write to zoned devices using direct IOs, we +* should never have any dirty page invalidated and so no data loss as +* long as the device cache flush succeeds, that is, as long as the +* flush does not use degraded storage elements. +*/ + ret =blkdev_flush_and_truncate (bdev, mode); +if (!ret) + ret =bdev_remove_storage_element (bdev, element_id);
[Severity: High]
Does this actually prevent concurrent direct I/O?
The comment implies that inode_lock() will prevent concurrent direct I/O during the hardware operation. However, blkdev_write_iter() and blkdev_read_iter() explicitly bypass inode_lock() for block devices when IOCB_DIRECT is set.
Since bdev_remove_storage_element() explicitly unfreezes the block queue to allow the management command to execute, couldn't concurrent O_DIRECT reads and writes be issued to the device, bypassing the VFS lock and racing with the destructive hardware reconfiguration?
[Severity: High]
Can holding these locks during the operation cause a Hung Task panic?
bdev_remove_storage_element() acquires zone_revalidate_mutex and then waits for the hardware operation to complete via disk_wait_for_se_mgmt_completion(), which contains an unbounded polling loop using msleep(1000).
Because this loop runs while both inode_lock() and zone_revalidate_mutex are held, any concurrent task attempting to acquire either lock—such as blk_revalidate_disk_zones() or a buffered I/O operation—will be blocked in TASK_UNINTERRUPTIBLE. If the hardware reconfiguration takes longer than 120 seconds, won't this trigger the kernel's Hung Task watchdog and panic the system?
Quoted 5 lines
block/blk-zoned.c +5
-0+ +inode_unlock (bdev->bd_mapping->host); + +return ret; +}
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
[email protected]
AI reviewRe: [PATCH v4 9/9] scsi: sd_zbc: define storage element management operations
In reply to Damien Le MoalThank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [High] scsi: sd_zbc: concurrent I/O races with storage element modification due to unfrozen queue…
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] scsi: sd_zbc: concurrent I/O races with storage element modification due to unfrozen queue
- [Medium] scsi: sd_zbc: nr_zones calculation for ALL_ACCESS_STORAGE omits runt zone --
commit f862e7a8a5445f6170e01d1055958c0159fb3b36
Author: Damien Le Moal <[email protected]>
scsi: sd_zbc: define storage element management operations
This commit defines storage element management operations (report, remove, restore) via struct blk_se_ops. These operations are intended for SMR disks supporting the storage element depopulation feature.
Quoted 4 lines
drivers/scsi/sd_zbc.c +0
-0
[ ... ]
Quoted 15 lines
drivers/scsi/sd_zbc.c +11
-0@@ -548,6 +548,239 @@ static void sd_zbc_print_zones(struct scsi_disk *sdkp) sdkp->zone_info.zone_blocks); } +static void sd_zbc_parse_storage_element (struct scsi_disk *sdkp,u8 *desc, +struct blk_se *element) +{ +struct scsi_device *sdp = sdkp->device; +sector_t zone_sectors =sd_zbc_zone_sectors (sdkp); +u64 capacity; + +memset (element,0 ,sizeof (*element)); + + element->id =get_unaligned_be32 (&desc[4 ]); +
drivers/scsi/sd_zbc.c static void sd_zbc_print_zones(struct scsi_disk *sdkp) · line 571
Quoted 10 lines
drivers/scsi/sd_zbc.c +10
-0+switch (desc[14 ]) { +case SCSI_PHYS_ELEM_TYPE_ALL_ACCESS_STORAGE : + element->type =BLK_SE_TYPE_RDWR ; + capacity =get_unaligned_be64 (&desc[16 ]); +if (!zone_sectors || capacity ==ULLONG_MAX ) + element->nr_zones =0 ; +else + element->nr_zones = +logical_to_sectors (sdp, capacity) >> +ilog2 (zone_sectors);
[Severity: Medium]
For devices with a "runt" zone at the end, the total capacity is not a perfect multiple of the zone size. Since the bitwise right shift performs integer division that rounds down, could this silently truncate the remainder blocks?
If so, does this cause the element to under-report the total number of zones by one, creating a mismatch with the core block layer's zone count (which properly rounds up)?
Quoted 2 lines
drivers/scsi/sd_zbc.c +2
-0+break ; +case SCSI_PHYS_ELEM_TYPE_FRAC_ACCESS_STORAGE :
[ ... ]
Quoted 13 lines
drivers/scsi/sd_zbc.c +13
-0+static int sd_zbc_remove_storage_element (struct gendisk *disk, +unsigned int element_id) +{ +struct scsi_disk *sdkp =scsi_disk (disk); +struct scsi_device *sdp = sdkp->device; +const int timeout = sdp->request_queue->rq_timeout; +struct scsi_sense_hdr sshdr; +const struct scsi_exec_args exec_args = { + .sshdr = &sshdr, + }; +unsigned char cmd[16 ]; +int result; +
drivers/scsi/sd_zbc.c static void sd_zbc_print_zones(struct scsi_disk *sdkp) · line 730
Quoted 10 lines
drivers/scsi/sd_zbc.c +10
-0+if (!sdkp->modify_zones_supported) +return -EOPNOTSUPP ; + +memset (cmd,0 ,16 ); + cmd[0 ] =SERVICE_ACTION_IN_16 ; + cmd[1 ] =SAI_REMOVE_ELEMENT_AND_MODIFY_ZONES ; +put_unaligned_be32 (element_id, &cmd[10 ]); + + result =scsi_execute_cmd (sdp, cmd,REQ_OP_DRV_IN ,NULL ,0 , + timeout,1 , &exec_args);
[Severity: High]
The block layer explicitly unfreezes the queue before invoking the se_ops callback. For example, in bdev_remove_storage_element():
memflags = blk_mq_freeze_queue(disk->queue);
blk_mq_unfreeze_queue(disk->queue, memflags);
ret = disk->fops->se_ops->remove_element(disk, element_id);Because the queue is unfrozen when sd_zbc_remove_storage_element() is called, another process could issue direct I/Os (e.g. via io_uring) to the queue. Can the hardware zone topology modification sent via this SCSI command race with concurrent I/O operations and lead to I/O failures or data corruption?
Quoted 3 lines
drivers/scsi/sd_zbc.c +3
-0+if (result) { +sd_printk (KERN_ERR , sdkp, +"REMOVE ELEMENT AND MODIFY ZONES failed\n" );
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=9
[email protected]
AI reviewRe: [PATCH v4 8/9] scsi: sd_zbc: always revalidate zones for disks supporting head depopulation
In reply to Damien Le MoalThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] scsi: sd: data race on struct scsi_disk bitfields can clobber WCE or modify_zones_supported --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] scsi: sd: data race on struct scsi_disk bitfields can clobber WCE or modify_zones_supported --
commit a445da75935ac3ec4cee9fc525679769cf828446
Author: Damien Le Moal <[email protected]>
scsi: sd_zbc: always revalidate zones for disks supporting head depopulation
This commit introduces a new check for ZBC devices that support data preserving head depopulation to ensure zone conditions are properly revalidated. It adds a new modify_zones_supported bitfield to struct scsi_disk and sets it during sd_zbc_read_zones(). The flag is then used to skip or perform zone revalidation depending on the disk's support for this feature.
Quoted 11 lines
drivers/scsi/sd.h +1
-0@@ -156,6 +156,7 @@ struct scsi_disk { unsigned ignore_medium_access_errors : 1; unsigned rscs : 1; /* reduced stream control support */ unsigned use_atomic_write_boundary : 1; + unsigned modify_zones_supported : 1; };#define to_scsi_disk (obj) container_of(obj, struct scsi_disk, disk_dev)
[ ... ]
Quoted 4 lines
drivers/scsi/sd_zbc.c +0
-0
[ ... ]
drivers/scsi/sd_zbc.c int sd_zbc_read_zones(struct scsi_disk *sdkp, struct queue_limits *lim, · line 645
Quoted 6 lines
drivers/scsi/sd_zbc.c +2
-0@@ -620,6 +641,9 @@ int sd_zbc_read_zones(struct scsi_disk *sdkp, struct queue_limits *lim,if (ret !=0 ) goto err; +/* Check if REMOVE ELEMENT AND MODIFY ZONES is supported. */ + sdkp->modify_zones_supported =sd_zbc_check_modify_zones (sdkp, buf);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[Severity: High]
Does this bitfield assignment introduce a data race that can silently corrupt neighboring bitfields like WCE?
Since C compilers implement bitfield assignments as non-atomic read-modify-write operations on the underlying machine word, updating modify_zones_supported here in sd_zbc_read_zones() during disk revalidation might race with sysfs stores.
For example, if a user or udev script writes to /sys/class/block/*/device/cache_type concurrently with a disk revalidation event, cache_type_store() in drivers/scsi/sd.c updates neighboring bits:
drivers/scsi/sd.c:cache_type_store() {
...
sdkp->WCE = wce;
sdkp->RCD = rcd;
...
}If these operations interleave without holding a lock that synchronizes the revalidation paths and sysfs writes, one update could silently overwrite the other. This could potentially disable or enable write caching unexpectedly or lose the modify_zones_supported flag.
Quoted 4 lines
drivers/scsi/sd_zbc.c +1
-0+ nr_zones =round_up (sdkp->capacity, zone_blocks) >>ilog2 (zone_blocks);if (nr_zones >INT_MAX ) { sd_printk(KERN_ERR, sdkp, "Too many zones (%llu)\n",
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=8
Damien Le Moal
maintainerRe: [PATCH v4 8/9] scsi: sd_zbc: always revalidate zones for disks supporting head depopulation
Quoted 38 lines · On 2026/10/09 11:32, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] scsi: sd: data race on structscsi_diskbitfields can clobber WCE ormodify_zones_supported--commit
a445da75935ac3ec4cee9fc525679769cf828446
Author: Damien Le Moal <[email protected]>scsi:
sd_zbc: always revalidate zones for disks supporting head depopulationThis commit introduces a new check for ZBC devices that support data preserving head depopulation to ensure zone conditions are properly revalidated. It adds a new
modify_zones_supportedbitfield to structscsi_diskand sets it duringsd_zbc_read_zones(). The flag is then used to skip or perform zone revalidation depending on the disk's support for this feature.Quoted 11 lines
drivers/scsi/sd.h +1
-0@@ -156,6 +156,7 @@ struct scsi_disk { unsigned ignore_medium_access_errors : 1; unsigned rscs : 1; /* reduced stream control support */ unsigned use_atomic_write_boundary : 1; + unsigned modify_zones_supported : 1; };#define to_scsi_disk (obj) container_of(obj, struct scsi_disk, disk_dev)[ ... ]
Quoted 4 lines
drivers/scsi/sd_zbc.c +0
-0[ ... ]
Quoted 4 lines
drivers/scsi/sd_zbc.c +0
-0@@ -620,6 +641,9 @@ int sd_zbc_read_zones(struct scsi_disk *sdkp, struct queue_limits *lim,if (ret !=0 ) goto err;
Quoted 7 lines
drivers/scsi/sd_zbc.c int sd_zbc_read_zones(struct scsi_disk *sdkp, struct queue_limits *lim, · line 645
Quoted 2 lines
drivers/scsi/sd_zbc.c +2
-0+/* Check if REMOVE ELEMENT AND MODIFY ZONES is supported. */ + sdkp->modify_zones_supported =sd_zbc_check_modify_zones (sdkp, buf);^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^[Severity: High]
Does this bitfield assignment introduce a data race that can silently corrupt neighboring bitfields like WCE?
Maybe... But this is not a new issue. All "flags" of a SCSI disks are defined as "unsigned int :1" bits. Everything should be rewritten to use a proper unsigne long bitfield with bit manipulation functions. So I am not going to fix that here.
Signature · 2 lines
Damien Le Moal Western Digital Research
Re: [PATCH v4 1/9] block: introduce disk_zone_is_offline()
In reply to Damien Le MoalQuoted 3 lines · Damien Le Moal
Introduce the helper function
disk_zone_is_offline()for testing if a zone of a gendisk has the offline condition. The zone to test is identified using a sector number that must belong to the target zone to check.
Looks good:
Re: [PATCH v4 2/9] block: refactor blk_revalidate_disk_zones()
In reply to Damien Le MoalQuoted 4 lines · Damien Le Moal
Split out most of the code of
blk_revalidate_disk_zones()into the internal functiondisk_revalidate_zones(). This will allow calling this new helper together with other code under the zone revalidation mutex. No functional change.
Looks good: