[PATCH V7 8/8] scsi: sd_zbc: Fix zone information initialization

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

 



Make sure that the device request queue zone information (number of
zones and zone bitmaps) are reinitialized if the number of zones
changes (e.g. on a drive capacity change on revalidate).

Signed-off-by: Damien Le Moal <damien.lemoal@xxxxxxx>
---
 drivers/scsi/sd_zbc.c | 36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/drivers/scsi/sd_zbc.c b/drivers/scsi/sd_zbc.c
index d2121e7738d7..6c348a211ebb 100644
--- a/drivers/scsi/sd_zbc.c
+++ b/drivers/scsi/sd_zbc.c
@@ -632,29 +632,29 @@ static int sd_zbc_setup(struct scsi_disk *sdkp)
 		round_up(sdkp->capacity, sdkp->zone_blocks) >> sdkp->zone_shift;
 
 	/*
-	 * Wait for the disk capacity to stabilize before
-	 * initializing zone related information.
+	 * Initialize the device request queue information if the number
+	 * of zones changed.
 	 */
-	if (sdkp->first_scan)
-		return 0;
+	if (sdkp->nr_zones != q->nr_zones) {
 
-	if (!q->seq_zones_wlock) {
-		q->seq_zones_wlock = sd_zbc_alloc_zone_bitmap(sdkp);
-		if (!q->seq_zones_wlock) {
-			ret = -ENOMEM;
-			goto err;
-		}
-	}
+		sd_zbc_cleanup(sdkp);
 
-	if (!q->seq_zones_bitmap) {
-		ret = sd_zbc_setup_seq_zones_bitmap(sdkp);
-		if (ret) {
-			sd_zbc_cleanup(sdkp);
-			goto err;
+		q->nr_zones = sdkp->nr_zones;
+		if (sdkp->nr_zones) {
+			q->seq_zones_wlock = sd_zbc_alloc_zone_bitmap(sdkp);
+			if (!q->seq_zones_wlock) {
+				ret = -ENOMEM;
+				goto err;
+			}
+
+			ret = sd_zbc_setup_seq_zones_bitmap(sdkp);
+			if (ret) {
+				sd_zbc_cleanup(sdkp);
+				goto err;
+			}
 		}
-	}
 
-	q->nr_zones = sdkp->nr_zones;
+	}
 
 	return 0;
 
-- 
2.13.6




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]

  Powered by Linux