scsi: sd: Call sd_revalidate_disk() for ioctl(BLKRRPART)

While the disk state has nothing to do with partitions, BLKRRPART is used
to force a full revalidate after things like a disk format for historical
reasons. Restore that behavior.

Link: https://lore.kernel.org/r/20210617115504.1732350-1-hch@lst.de
Fixes: 471bd0af544b ("sd: use bdev_check_media_change")
Reported-by: Xiang Chen <chenxiang66@hisilicon.com>
Tested-by: Xiang Chen <chenxiang66@hisilicon.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by Christoph Hellwig and committed by Martin K. Petersen d1b7f920 7dd753ca

Changed files
+18 -4
drivers
scsi
+18 -4
drivers/scsi/sd.c
··· 1387 1387 } 1388 1388 } 1389 1389 1390 + static bool sd_need_revalidate(struct block_device *bdev, 1391 + struct scsi_disk *sdkp) 1392 + { 1393 + if (sdkp->device->removable || sdkp->write_prot) { 1394 + if (bdev_check_media_change(bdev)) 1395 + return true; 1396 + } 1397 + 1398 + /* 1399 + * Force a full rescan after ioctl(BLKRRPART). While the disk state has 1400 + * nothing to do with partitions, BLKRRPART is used to force a full 1401 + * revalidate after things like a format for historical reasons. 1402 + */ 1403 + return test_bit(GD_NEED_PART_SCAN, &bdev->bd_disk->state); 1404 + } 1405 + 1390 1406 /** 1391 1407 * sd_open - open a scsi disk device 1392 1408 * @bdev: Block device of the scsi disk to open ··· 1439 1423 if (!scsi_block_when_processing_errors(sdev)) 1440 1424 goto error_out; 1441 1425 1442 - if (sdev->removable || sdkp->write_prot) { 1443 - if (bdev_check_media_change(bdev)) 1444 - sd_revalidate_disk(bdev->bd_disk); 1445 - } 1426 + if (sd_need_revalidate(bdev, sdkp)) 1427 + sd_revalidate_disk(bdev->bd_disk); 1446 1428 1447 1429 /* 1448 1430 * If the drive is empty, just let the open fail.