Minor improvements for the zoned block storage code
Subsystems (2)
v2 cover Minor improvements for the zoned block storage code
Hi Jens,
This patch series includes several minor improvements for the zoned block storage code. None of these patches changes the behavior of that code.
Please consider these patches for the next merge window.
Thanks,
Bart.
Changes compared to v1:
- Dropped two patches about which there is no agreement.
- Added Reviewed-by: tags.
Bart Van Assche (4):
blk-zoned: Minimize #include directives
blk-zoned: Document locking assumptions
blk-zoned: Improve the queue reference count strategy documentation
blk-zoned: Split queue_zone_wplugs_show()
block/blk-zoned.c | 58 ++++++++++++++++++++++++----------------------- 1 file changed, 30 insertions(+), 28 deletions(-)
PATCH v2 1/4 blk-zoned: Minimize #include directives
Only include those header files that are necessary.
--- block/blk-zoned.c | 4 ---- 1 file changed, 4 deletions(-)
block/blk-zoned.c +0 -4
@@ -11,12 +11,8 @@*/ #include <linux/kernel.h> -#include <linux/module.h> #include <linux/blkdev.h> #include <linux/blk-mq.h> -#include <linux/mm.h> -#include <linux/vmalloc.h> -#include <linux/sched/mm.h> #include <linux/spinlock.h> #include <linux/refcount.h> #include <linux/mempool.h>
PATCH v2 2/4 blk-zoned: Document locking assumptions
In reply to Bart Van AsscheDocument which functions expect that their callers must hold a lock.
--- block/blk-zoned.c | 4 ++++ 1 file changed, 4 insertions(+)
block/blk-zoned.c +4 -0
@@ -459,6 +459,8 @@ static inline void disk_put_zone_wplug(struct blk_zone_wplug *zwplug)static inline bool disk_should_remove_zone_wplug (struct gendisk *disk,struct blk_zone_wplug *zwplug) { +lockdep_assert_held (&zwplug->lock); +/* If the zone write plug was already removed, we are done. */ if (zwplug->flags &BLK_ZONE_WPLUG_UNHASHED )return false;
@@ -913,6 +915,8 @@ static bool blk_zone_wplug_prepare_bio(struct blk_zone_wplug *zwplug, {struct gendisk *disk = bio->bi_bdev->bd_disk; +lockdep_assert_held (&zwplug->lock); +/* * If we lost track of the zone write pointer due to a write error, * the user must either execute a report zones, reset the zone or finish
PATCH v2 3/4 blk-zoned: Improve the queue reference count strategy documentation
In reply to Bart Van AsscheFor the blk_queue_exit() calls, document where the corresponding code can be found that increases q->q_usage_counter.
--- block/blk-zoned.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
block/blk-zoned.c +2 -4
@@ -582,6 +582,7 @@ static inline void blk_zone_wplug_bio_io_error(struct blk_zone_wplug *zwplug,bio_clear_flag (bio,BIO_ZONE_WRITE_PLUGGING );bio_io_error (bio);disk_put_zone_wplug (zwplug); +/* Drop the reference taken by disk_zone_wplug_add_bio(() */ blk_queue_exit (q); }
@@ -893,10 +894,7 @@ void blk_zone_write_plug_init_request(struct request *req)break ; } -/* -* Drop the extra reference on the queue usage we got when -* plugging the BIO and advance the write pointer offset. -*/ +/* Drop the reference taken by disk_zone_wplug_add_bio(). */ blk_queue_exit (q); zwplug->wp_offset +=bio_sectors (bio);
PATCH v2 4/4 blk-zoned: Split queue_zone_wplugs_show()
In reply to Bart Van AsscheReduce the indentation level of the code in queue_zone_wplugs_show() by moving the body of the loop in that function into a new function.
--- block/blk-zoned.c | 44 ++++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 20 deletions(-)
block/blk-zoned.c +24 -20
@@ -1774,37 +1774,41 @@ int blk_zone_issue_zeroout(struct block_device *bdev, sector_t sector,EXPORT_SYMBOL_GPL (blk_zone_issue_zeroout);#ifdef CONFIG_BLK_DEBUG_FS +static void queue_zone_wplug_show (struct blk_zone_wplug *zwplug, +struct seq_file *m) +{ +unsigned int zwp_wp_offset, zwp_flags; +unsigned int zwp_zone_no, zwp_ref; +unsigned int zwp_bio_list_size; +unsigned long flags; + +spin_lock_irqsave (&zwplug->lock, flags); + zwp_zone_no = zwplug->zone_no; + zwp_flags = zwplug->flags; + zwp_ref =refcount_read (&zwplug->ref); + zwp_wp_offset = zwplug->wp_offset; + zwp_bio_list_size =bio_list_size (&zwplug->bio_list); +spin_unlock_irqrestore (&zwplug->lock, flags); + +seq_printf (m,"%u 0x%x %u %u %u\n" , zwp_zone_no, zwp_flags, zwp_ref, + zwp_wp_offset, zwp_bio_list_size); +}int queue_zone_wplugs_show (void *data,struct seq_file *m) {struct request_queue *q = data;struct gendisk *disk = q->disk;struct blk_zone_wplug *zwplug; -unsigned int zwp_wp_offset, zwp_flags; -unsigned int zwp_zone_no, zwp_ref; -unsigned int zwp_bio_list_size, i; -unsigned long flags; +unsigned int i;if (!disk->zone_wplugs_hash)return 0 ;rcu_read_lock (); -for (i =0 ; i <disk_zone_wplugs_hash_size (disk); i++) { -hlist_for_each_entry_rcu (zwplug, - &disk->zone_wplugs_hash[i], node) { -spin_lock_irqsave (&zwplug->lock, flags); - zwp_zone_no = zwplug->zone_no; - zwp_flags = zwplug->flags; - zwp_ref =refcount_read (&zwplug->ref); - zwp_wp_offset = zwplug->wp_offset; - zwp_bio_list_size =bio_list_size (&zwplug->bio_list); -spin_unlock_irqrestore (&zwplug->lock, flags); - -seq_printf (m,"%u 0x%x %u %u %u\n" , - zwp_zone_no, zwp_flags, zwp_ref, - zwp_wp_offset, zwp_bio_list_size); - } - } +for (i =0 ; i <disk_zone_wplugs_hash_size (disk); i++) +hlist_for_each_entry_rcu (zwplug, &disk->zone_wplugs_hash[i], + node) +queue_zone_wplug_show (zwplug, m);rcu_read_unlock ();return 0 ;
Quoted 2 lines · Bart Van Assche
This patch series includes several minor improvements for the zoned block storage code. None of these patches changes the behavior of that code.
(replying to my own email)
Hi Jens,
Can you please take a look at this patch series and also at the patch series "[PATCH v3 0/2] Two blk_mq_submit_bio() patches"? All patches in both patch series received one or two positive reviews and no negative feedback.
Thanks,
Bart.
Quoted 8 lines · Bart Van Assche
This patch series includes several minor improvements for the zoned block storage code. None of these patches changes the behavior of that code.
Please consider these patches for the next merge window.
Thanks,
[...]
Applied, thanks!
[1/4] blk-zoned: Minimize #include directives
commit: 812047bc7e7754dc9d9a9f42685a006f064cd16a
[2/4] blk-zoned: Document locking assumptions
commit: 27eb21b36c60a3986cfc7d374f066fbdebb8b3ed
[3/4] blk-zoned: Improve the queue reference count strategy documentation
commit: e3d334adc3aea20e3caf16d408c1f5b04a59eed0
[4/4] blk-zoned: Split queue_zone_wplugs_show()
commit: 736a8772092fa8e3a87bf8768e47d6bc1fcbc149Best regards,
Signature · 1 line
Jens Axboe