[PATCH 2/3] blk-zoned: Move locking into disk_zone_wplug_abort()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Instead of holding zwplug->lock around disk_zone_wplug_abort() calls, make
disk_zone_wplug_abort() obtain zwplug->lock. Prepare for reducing the amount
of code protected by zwplug->lock. No functionality has been changed.

Signed-off-by: Bart Van Assche <bvanassche@xxxxxxx>
---
 block/blk-zoned.c | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/block/blk-zoned.c b/block/blk-zoned.c
index 75b01068b877..ce5604c92fea 100644
--- a/block/blk-zoned.c
+++ b/block/blk-zoned.c
@@ -607,13 +607,20 @@ static void disk_zone_wplug_abort(struct blk_zone_wplug *zwplug)
 {
 	struct bio *bio;
 
-	if (bio_list_empty(&zwplug->bio_list))
-		return;
+	scoped_guard(spinlock_irqsave, &zwplug->lock)
+		if (bio_list_empty(&zwplug->bio_list))
+			return;
 
 	pr_warn_ratelimited("%s: zone %u: Aborting plugged BIOs\n",
 			    zwplug->disk->disk_name, zwplug->zone_no);
-	while ((bio = bio_list_pop(&zwplug->bio_list)))
-		blk_zone_wplug_bio_io_error(zwplug, bio);
+	for (;;) {
+		scoped_guard(spinlock_irqsave, &zwplug->lock) {
+			bio = bio_list_pop(&zwplug->bio_list);
+			if (!bio)
+				break;
+			blk_zone_wplug_bio_io_error(zwplug, bio);
+		}
+	}
 }
 
 /*
@@ -635,9 +642,10 @@ static void disk_zone_wplug_set_wp_offset(struct gendisk *disk,
 		/* Update the zone write pointer and abort all plugged BIOs. */
 		zwplug->flags &= ~BLK_ZONE_WPLUG_NEED_WP_UPDATE;
 		zwplug->wp_offset = wp_offset;
-		disk_zone_wplug_abort(zwplug);
 	}
 
+	disk_zone_wplug_abort(zwplug);
+
 	/*
 	 * The zone write plug now has no BIO plugged: remove it from the
 	 * hash table so that it cannot be seen. The plug will be freed
@@ -1086,7 +1094,9 @@ static void blk_zone_wplug_handle_native_zone_append(struct bio *bio)
 	if (!bio_list_empty(&zwplug->bio_list)) {
 		pr_warn_ratelimited("%s: zone %u: Invalid mix of zone append and regular writes\n",
 				    disk->disk_name, zwplug->zone_no);
+		spin_unlock_irqrestore(&zwplug->lock, flags);
 		disk_zone_wplug_abort(zwplug);
+		spin_lock_irqsave(&zwplug->lock, flags);
 	}
 	disk_remove_zone_wplug(disk, zwplug);
 	spin_unlock_irqrestore(&zwplug->lock, flags);




[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux