From: Jan Kara <jack@suse.cz>
To: Yu Kuai <yukuai1@huaweicloud.com>
Cc: jack@suse.cz, hare@suse.de, hch@infradead.org, axboe@kernel.dk,
linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
yukuai3@huawei.com, yi.zhang@huawei.com, yangerkun@huawei.com
Subject: Re: [PATCH -next 1/2] block: Revert "block: Do not reread partition table on exclusively open device"
Date: Fri, 17 Feb 2023 12:01:02 +0100 [thread overview]
Message-ID: <20230217110102.la3w7c6pck4pfilo@quack3> (raw)
In-Reply-To: <20230217022200.3092987-2-yukuai1@huaweicloud.com>
On Fri 17-02-23 10:21:59, Yu Kuai wrote:
> From: Yu Kuai <yukuai3@huawei.com>
>
> This reverts commit 36369f46e91785688a5f39d7a5590e3f07981316.
>
> This patch can't fix the problem in a corner case that device can be
> opened exclusively after the checking and before blkdev_get_by_dev().
> We'll use a new solution to fix the problem in the next patch, and
> the new solution doesn't need to change apis.
>
> Signed-off-by: Yu Kuai <yukuai3@huawei.com>
Sure. Feel free to add:
Acked-by: Jan Kara <jack@suse.cz>
or Reviewed-by... whatever for the revert :)
Honza
> ---
> block/blk.h | 2 +-
> block/genhd.c | 7 ++-----
> block/ioctl.c | 13 ++++++-------
> 3 files changed, 9 insertions(+), 13 deletions(-)
>
> diff --git a/block/blk.h b/block/blk.h
> index f02381405311..4a166f847ffd 100644
> --- a/block/blk.h
> +++ b/block/blk.h
> @@ -439,7 +439,7 @@ static inline void bio_release_page(struct bio *bio, struct page *page)
>
> struct request_queue *blk_alloc_queue(int node_id);
>
> -int disk_scan_partitions(struct gendisk *disk, fmode_t mode, void *owner);
> +int disk_scan_partitions(struct gendisk *disk, fmode_t mode);
>
> int disk_alloc_events(struct gendisk *disk);
> void disk_add_events(struct gendisk *disk);
> diff --git a/block/genhd.c b/block/genhd.c
> index d09d775c222a..b30d5538710c 100644
> --- a/block/genhd.c
> +++ b/block/genhd.c
> @@ -356,7 +356,7 @@ void disk_uevent(struct gendisk *disk, enum kobject_action action)
> }
> EXPORT_SYMBOL_GPL(disk_uevent);
>
> -int disk_scan_partitions(struct gendisk *disk, fmode_t mode, void *owner)
> +int disk_scan_partitions(struct gendisk *disk, fmode_t mode)
> {
> struct block_device *bdev;
>
> @@ -366,9 +366,6 @@ int disk_scan_partitions(struct gendisk *disk, fmode_t mode, void *owner)
> return -EINVAL;
> if (disk->open_partitions)
> return -EBUSY;
> - /* Someone else has bdev exclusively open? */
> - if (disk->part0->bd_holder && disk->part0->bd_holder != owner)
> - return -EBUSY;
>
> set_bit(GD_NEED_PART_SCAN, &disk->state);
> bdev = blkdev_get_by_dev(disk_devt(disk), mode, NULL);
> @@ -499,7 +496,7 @@ int __must_check device_add_disk(struct device *parent, struct gendisk *disk,
>
> bdev_add(disk->part0, ddev->devt);
> if (get_capacity(disk))
> - disk_scan_partitions(disk, FMODE_READ, NULL);
> + disk_scan_partitions(disk, FMODE_READ);
>
> /*
> * Announce the disk and partitions after all partitions are
> diff --git a/block/ioctl.c b/block/ioctl.c
> index 96617512982e..6dd49d877584 100644
> --- a/block/ioctl.c
> +++ b/block/ioctl.c
> @@ -467,10 +467,10 @@ static int blkdev_bszset(struct block_device *bdev, fmode_t mode,
> * user space. Note the separate arg/argp parameters that are needed
> * to deal with the compat_ptr() conversion.
> */
> -static int blkdev_common_ioctl(struct file *file, fmode_t mode, unsigned cmd,
> - unsigned long arg, void __user *argp)
> +static int blkdev_common_ioctl(struct block_device *bdev, fmode_t mode,
> + unsigned int cmd, unsigned long arg,
> + void __user *argp)
> {
> - struct block_device *bdev = I_BDEV(file->f_mapping->host);
> unsigned int max_sectors;
>
> switch (cmd) {
> @@ -528,8 +528,7 @@ static int blkdev_common_ioctl(struct file *file, fmode_t mode, unsigned cmd,
> return -EACCES;
> if (bdev_is_partition(bdev))
> return -EINVAL;
> - return disk_scan_partitions(bdev->bd_disk, mode & ~FMODE_EXCL,
> - file);
> + return disk_scan_partitions(bdev->bd_disk, mode & ~FMODE_EXCL);
> case BLKTRACESTART:
> case BLKTRACESTOP:
> case BLKTRACETEARDOWN:
> @@ -607,7 +606,7 @@ long blkdev_ioctl(struct file *file, unsigned cmd, unsigned long arg)
> break;
> }
>
> - ret = blkdev_common_ioctl(file, mode, cmd, arg, argp);
> + ret = blkdev_common_ioctl(bdev, mode, cmd, arg, argp);
> if (ret != -ENOIOCTLCMD)
> return ret;
>
> @@ -676,7 +675,7 @@ long compat_blkdev_ioctl(struct file *file, unsigned cmd, unsigned long arg)
> break;
> }
>
> - ret = blkdev_common_ioctl(file, mode, cmd, arg, argp);
> + ret = blkdev_common_ioctl(bdev, mode, cmd, arg, argp);
> if (ret == -ENOIOCTLCMD && disk->fops->compat_ioctl)
> ret = disk->fops->compat_ioctl(bdev, mode, cmd, arg);
>
> --
> 2.31.1
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
next prev parent reply other threads:[~2023-02-17 11:01 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-17 2:21 [PATCH -next 0/2] block: fix scan partition for exclusively open device again Yu Kuai
2023-02-17 2:21 ` [PATCH -next 1/2] block: Revert "block: Do not reread partition table on exclusively open device" Yu Kuai
2023-02-17 11:01 ` Jan Kara [this message]
2023-02-17 2:22 ` [PATCH -next 2/2] block: fix scan partition for exclusively open device again Yu Kuai
2023-02-17 7:29 ` Christoph Hellwig
2023-02-17 11:05 ` Jan Kara
2023-02-17 13:16 ` [PATCH -next 0/2] " Jens Axboe
2023-03-21 11:43 ` Ming Lei
2023-03-22 1:26 ` Yu Kuai
2023-03-22 1:34 ` Ming Lei
2023-03-22 2:02 ` Yu Kuai
2023-03-22 2:15 ` Yu Kuai
2023-03-22 3:38 ` Ming Lei
2023-03-22 4:00 ` Yu Kuai
2023-03-22 3:59 ` [PATCH] block: don't set GD_NEED_PART_SCAN if scan partition failed Yu Kuai
2023-03-22 7:58 ` Ming Lei
2023-03-22 9:12 ` Yu Kuai
2023-03-22 9:47 ` Jan Kara
2023-03-22 11:34 ` Ming Lei
2023-03-22 13:07 ` Jan Kara
2023-03-22 16:08 ` Ming Lei
2023-03-23 10:51 ` Jan Kara
2023-03-23 12:03 ` Ming Lei
2023-03-22 9:52 ` Jan Kara
2023-03-23 23:59 ` Ming Lei
2023-04-06 3:42 ` Yu Kuai
2023-04-06 22:29 ` Jens Axboe
2023-04-07 2:01 ` Ming Lei
2023-04-07 2:42 ` Jens Axboe
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=20230217110102.la3w7c6pck4pfilo@quack3 \
--to=jack@suse.cz \
--cc=axboe@kernel.dk \
--cc=hare@suse.de \
--cc=hch@infradead.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=yangerkun@huawei.com \
--cc=yi.zhang@huawei.com \
--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