All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@infradead.org>
To: Damien Le Moal <damien.lemoal@wdc.com>
Cc: linux-scsi@vger.kernel.org,
	"Martin K . Petersen" <martin.petersen@oracle.com>
Subject: Re: [PATCH] scsi: sd_sbc: Fix sd_zbc_report_zones()
Date: Wed, 19 Feb 2020 08:24:57 -0800	[thread overview]
Message-ID: <20200219162457.GA5614@infradead.org> (raw)
In-Reply-To: <20200219063800.880834-1-damien.lemoal@wdc.com>

On Wed, Feb 19, 2020 at 03:38:00PM +0900, Damien Le Moal wrote:
> The block layer generic blk_revalidate_disk_zones() checks the validity
> of zone descriptors reported by a disk using the
> blk_revalidate_zone_cb() callback function executed for each zone
> descriptor. If a ZBC disk reports invalid zone descriptors,
> blk_revalidate_disk_zones() returns an error and sd_zbc_read_zones()
> changes the disk capacity to 0, which in turn results in the gendisk
> structure capacity to be set to 0. This all works well for the first
> revalidate pass on a disk and the block layer detects the capactiy
> change.
> 
> On the second revalidate pass, blk_revalidate_disk_zones() is called
> again and sd_zbc_report_zones() executed to check the zones a second
> time. However, for this second pass, the gendisk capacity is now 0,
> which results in sd_zbc_report_zones() to do nothing and to report
> success and no zones. blk_revalidate_disk_zones() in turn returns
> success and sets the disk queue chunk_sectors limit with zero as
> no zones were checked, causing a oops to trigger on the
> BUG_ON(!is_power_of_2(chunk_sectors)) in blk_queue_chunk_sectors().
> 
> Fix this by using the sdkp capacity field rather than the gendisk
> capacity for the report zones loop in sd_zbc_report_zones(). Also add a
> check to return immediately an error if the sdkp capacity is 0.
> With this fix, invalid/buggy ZBC disk scan does not trigger a oops and
> are exposed with a 0 capacity. This change also preserve the chance for
> the disk to be correctly revalidated on the second revalidate pass as
> the scsi disk structure capacity field is always set to the disk
> reported value when sd_zbc_report_zones() is called.
> 
> Fixes: d41003513e61 ("block: rework zone reporting")
> Cc: Cc: <stable@vger.kernel.org> # v5.5
> Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

  reply	other threads:[~2020-02-19 16:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-19  6:38 [PATCH] scsi: sd_sbc: Fix sd_zbc_report_zones() Damien Le Moal
2020-02-19 16:24 ` Christoph Hellwig [this message]
2020-02-21 15:33 ` Johannes Thumshirn
2020-02-24 17:46 ` Martin K. Petersen

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=20200219162457.GA5614@infradead.org \
    --to=hch@infradead.org \
    --cc=damien.lemoal@wdc.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.