From: Saranya Muruganandam <saranyamohan@google.com>
To: Christoph Hellwig <hch@lst.de>
Cc: Yu Kuai <yukuai1@huaweicloud.com>,
linux-block@vger.kernel.org, Jens Axboe <axboe@kernel.dk>,
sashal@kernel.org, Ming Lei <ming.lei@redhat.com>,
"yukuai (C)" <yukuai3@huawei.com>
Subject: Re: regression on BLKRRPART ioctl for EIO
Date: Thu, 4 Apr 2024 19:04:26 -0700 [thread overview]
Message-ID: <CAP9s-SrXqgWv4rF3EGRahtuwKU7yJFaoOcSROgrbFkhaWLEVsg@mail.gmail.com> (raw)
In-Reply-To: <20240320015134.GA14267@lst.de>
Hi Christoph,
Apologies for the delay.
Thanks a ton for your patch! Your patch solution works for me.
I sent https://lore.kernel.org/all/20240405014253.748627-1-saranyamohan@google.com/
for the block layer patch
and https://lore.kernel.org/all/20240405015657.751659-1-saranyamohan@google.com/
for the blktest added.
Once I get confirmation that they look good, I have the changes for
the older LTS which I can share.
This patch doesn't cleanly apply but your idea of flagging and using
that to return errors, fixes the regression
for stable kernels like 5.10.
Thanks again.
-Saranya
On Tue, Mar 19, 2024 at 6:51 PM Christoph Hellwig <hch@lst.de> wrote:
>
> Please try the patch below:
>
> I would also relly help to have a blktsts test case to show your
> issue and verify that it is fixed.
>
> diff --git a/block/bdev.c b/block/bdev.c
> index e7adaaf1c21927..51071d371863e0 100644
> --- a/block/bdev.c
> +++ b/block/bdev.c
> @@ -645,6 +645,14 @@ static void blkdev_flush_mapping(struct block_device *bdev)
> bdev_write_inode(bdev);
> }
>
> +static void blkdev_put_whole(struct block_device *bdev)
> +{
> + if (atomic_dec_and_test(&bdev->bd_openers))
> + blkdev_flush_mapping(bdev);
> + if (bdev->bd_disk->fops->release)
> + bdev->bd_disk->fops->release(bdev->bd_disk);
> +}
> +
> static int blkdev_get_whole(struct block_device *bdev, blk_mode_t mode)
> {
> struct gendisk *disk = bdev->bd_disk;
> @@ -663,20 +671,21 @@ static int blkdev_get_whole(struct block_device *bdev, blk_mode_t mode)
>
> if (!atomic_read(&bdev->bd_openers))
> set_init_blocksize(bdev);
> - if (test_bit(GD_NEED_PART_SCAN, &disk->state))
> - bdev_disk_changed(disk, false);
> atomic_inc(&bdev->bd_openers);
> + if (test_bit(GD_NEED_PART_SCAN, &disk->state)) {
> + /*
> + * Only return scanning errors if we are called from conexts
> + * that explicitly want them, e.g. the BLKRRPART ioctl.
> + */
> + ret = bdev_disk_changed(disk, false);
> + if (ret && (mode & BLK_OPEN_STRICT_SCAN)) {
> + blkdev_put_whole(bdev);
> + return ret;
> + }
> + }
> return 0;
> }
>
> -static void blkdev_put_whole(struct block_device *bdev)
> -{
> - if (atomic_dec_and_test(&bdev->bd_openers))
> - blkdev_flush_mapping(bdev);
> - if (bdev->bd_disk->fops->release)
> - bdev->bd_disk->fops->release(bdev->bd_disk);
> -}
> -
> static int blkdev_get_part(struct block_device *part, blk_mode_t mode)
> {
> struct gendisk *disk = part->bd_disk;
> diff --git a/block/ioctl.c b/block/ioctl.c
> index 0c76137adcaaa5..128f503828cee7 100644
> --- a/block/ioctl.c
> +++ b/block/ioctl.c
> @@ -562,7 +562,8 @@ static int blkdev_common_ioctl(struct block_device *bdev, blk_mode_t mode,
> return -EACCES;
> if (bdev_is_partition(bdev))
> return -EINVAL;
> - return disk_scan_partitions(bdev->bd_disk, mode);
> + return disk_scan_partitions(bdev->bd_disk,
> + mode | BLK_OPEN_STRICT_SCAN);
> case BLKTRACESTART:
> case BLKTRACESTOP:
> case BLKTRACETEARDOWN:
> diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
> index f9b87c39cab047..272ce42f297cfe 100644
> --- a/include/linux/blkdev.h
> +++ b/include/linux/blkdev.h
> @@ -128,6 +128,8 @@ typedef unsigned int __bitwise blk_mode_t;
> #define BLK_OPEN_WRITE_IOCTL ((__force blk_mode_t)(1 << 4))
> /* open is exclusive wrt all other BLK_OPEN_WRITE opens to the device */
> #define BLK_OPEN_RESTRICT_WRITES ((__force blk_mode_t)(1 << 5))
> +/* return partition scanning errors */
> +#define BLK_OPEN_STRICT_SCAN ((__force blk_mode_t)(1 << 5))
>
> struct gendisk {
> /*
prev parent reply other threads:[~2024-04-05 2:04 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-07 4:28 regression on BLKRRPART ioctl for EIO Saranya Muruganandam
2024-02-12 15:44 ` Christoph Hellwig
[not found] ` <CAP9s-Sr3_GVYBv-XObPRC9L27jJoQqX40d8g3gysEmy6VdQS1Q@mail.gmail.com>
2024-02-13 4:01 ` Saranya Muruganandam
2024-02-27 2:38 ` Saranya Muruganandam
2024-02-27 3:13 ` Yu Kuai
2024-03-07 18:14 ` Saranya Muruganandam
2024-03-08 16:32 ` Christoph Hellwig
2024-03-20 0:20 ` Saranya Muruganandam
2024-03-20 1:51 ` Christoph Hellwig
2024-04-05 2:04 ` Saranya Muruganandam [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=CAP9s-SrXqgWv4rF3EGRahtuwKU7yJFaoOcSROgrbFkhaWLEVsg@mail.gmail.com \
--to=saranyamohan@google.com \
--cc=axboe@kernel.dk \
--cc=hch@lst.de \
--cc=linux-block@vger.kernel.org \
--cc=ming.lei@redhat.com \
--cc=sashal@kernel.org \
--cc=yukuai1@huaweicloud.com \
--cc=yukuai3@huawei.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 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 read-only IMAP folder(s) and NNTP newsgroup(s).