linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "chenxiang (M)" <chenxiang66@hisilicon.com>
To: Christoph Hellwig <hch@lst.de>
Cc: Jens Axboe <axboe@kernel.dk>, Tim Waugh <tim@cyberelk.net>,
	<martin.petersen@oracle.com>, <linux-block@vger.kernel.org>,
	<linux-scsi@vger.kernel.org>,
	"linuxarm@huawei.com" <linuxarm@huawei.com>
Subject: Re: remove ->revalidate_disk (resend)
Date: Thu, 17 Jun 2021 19:50:52 +0800	[thread overview]
Message-ID: <0317ad8f-58e6-012f-e206-fdb5a2503c42@hisilicon.com> (raw)
In-Reply-To: <20210617102936.GA12756@lst.de>

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 <chenxiang66@hisilicon.com>

>
> 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.
>
> .
>



      reply	other threads:[~2021-06-17 11:50 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-08  7:45 remove ->revalidate_disk (resend) Christoph Hellwig
2021-03-08  7:45 ` [PATCH 1/3] paride/pd: remove ->revalidate_disk Christoph Hellwig
2021-03-08  7:45 ` [PATCH 2/3] umem: " Christoph Hellwig
2021-03-08  7:45 ` [PATCH 3/3] block: remove the revalidate_disk method Christoph Hellwig
2021-03-29  5:55 ` remove ->revalidate_disk (resend) Christoph Hellwig
2021-03-29 13:01   ` Jens Axboe
2021-03-30  5:28     ` Christoph Hellwig
2021-06-16  9:41 ` chenxiang (M)
2021-06-16 13:50   ` Christoph Hellwig
2021-06-17  3:43     ` chenxiang (M)
2021-06-17 10:29       ` Christoph Hellwig
2021-06-17 11:50         ` chenxiang (M) [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0317ad8f-58e6-012f-e206-fdb5a2503c42@hisilicon.com \
    --to=chenxiang66@hisilicon.com \
    --cc=axboe@kernel.dk \
    --cc=hch@lst.de \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=linuxarm@huawei.com \
    --cc=martin.petersen@oracle.com \
    --cc=tim@cyberelk.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).