Thread (12 messages) 12 messages, 3 authors, 2021-06-17

Re: remove ->revalidate_disk (resend)

From: chenxiang (M) <hidden>
Date: 2021-06-17 11:50:58
Also in: linux-scsi

Hi Christoph,


在 2021/6/17 18:29, Christoph Hellwig 写道:
Can you try the patch below?
I have tested the patch, and it fixes the issue i reported, and so 
please feel free to add:
Tested-by: Xiang Chen <redacted>
quoted hunk ↗ jump to hunk
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 5c8b5c5356a3..6d2d63629a90 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -1387,6 +1387,22 @@ static void sd_uninit_command(struct scsi_cmnd *SCpnt)
  	}
  }
  
+static bool sd_need_revalidate(struct block_device *bdev,
+		struct scsi_disk *sdkp)
+{
+	if (sdkp->device->removable || sdkp->write_prot) {
+		if (bdev_check_media_change(bdev))
+			return true;
+	}
+
+	/*
+	 * Force a full rescan after ioctl(BLKRRPART).  While the disk state has
+	 * nothing to do with partitions, BLKRRPART is used to force a full
+	 * revalidate after things like a format for historical reasons.
+	 */
+	return test_bit(GD_NEED_PART_SCAN, &bdev->bd_disk->state);
+}
+
  /**
   *	sd_open - open a scsi disk device
   *	@bdev: Block device of the scsi disk to open
@@ -1423,10 +1439,8 @@ static int sd_open(struct block_device *bdev, fmode_t mode)
  	if (!scsi_block_when_processing_errors(sdev))
  		goto error_out;
  
-	if (sdev->removable || sdkp->write_prot) {
-		if (bdev_check_media_change(bdev))
-			sd_revalidate_disk(bdev->bd_disk);
-	}
+	if (sd_need_revalidate(bdev, sdkp))
+		sd_revalidate_disk(bdev->bd_disk);
  
  	/*
  	 * If the drive is empty, just let the open fail.
.
  
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help