From: Jan Kara <jack@suse.cz>
To: Christoph Hellwig <hch@lst.de>
Cc: Jens Axboe <axboe@kernel.dk>, Josef Bacik <josef@toxicpanda.com>,
Minchan Kim <minchan@kernel.org>,
Stefan Haberland <sth@linux.ibm.com>,
Jan Hoeppner <hoeppner@linux.ibm.com>,
Joseph Qi <joseph.qi@linux.alibaba.com>,
"Rafael J. Wysocki" <rjw@rjwysocki.net>,
Pavel Machek <pavel@ucw.cz>, Len Brown <len.brown@intel.com>,
Andrew Morton <akpm@linux-foundation.org>,
linux-kernel@vger.kernel.org, nbd@other.debian.org,
linux-ide@vger.kernel.org, linux-s390@vger.kernel.org,
linux-fsdevel@vger.kernel.org, ocfs2-devel@oss.oracle.com,
linux-pm@vger.kernel.org, linux-mm@kvack.org,
linux-block@vger.kernel.org
Subject: Re: [PATCH 01/14] block: move the NEED_PART_SCAN flag to struct gendisk
Date: Thu, 24 Sep 2020 10:56:33 +0200 [thread overview]
Message-ID: <20200924085633.GD27019@quack2.suse.cz> (raw)
In-Reply-To: <20200917165720.3285256-2-hch@lst.de>
On Thu 17-09-20 18:57:07, Christoph Hellwig wrote:
> We can only scan for partitions on the whole disk, so move the flag
> from struct block_device to struct gendisk.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
Makes sense. You can add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> block/genhd.c | 4 ++--
> drivers/block/nbd.c | 8 ++++----
> drivers/ide/ide-gd.c | 2 +-
> fs/block_dev.c | 7 +++----
> include/linux/blk_types.h | 4 +---
> include/linux/genhd.h | 2 ++
> 6 files changed, 13 insertions(+), 14 deletions(-)
>
> diff --git a/block/genhd.c b/block/genhd.c
> index 9d060e79eb31d8..7b56203c90a303 100644
> --- a/block/genhd.c
> +++ b/block/genhd.c
> @@ -731,7 +731,7 @@ static void register_disk(struct device *parent, struct gendisk *disk,
> if (!bdev)
> goto exit;
>
> - set_bit(BDEV_NEED_PART_SCAN, &bdev->bd_flags);
> + set_bit(GD_NEED_PART_SCAN, &disk->state);
> err = blkdev_get(bdev, FMODE_READ, NULL);
> if (err < 0)
> goto exit;
> @@ -2112,7 +2112,7 @@ bool bdev_check_media_change(struct block_device *bdev)
> if (__invalidate_device(bdev, true))
> pr_warn("VFS: busy inodes on changed media %s\n",
> bdev->bd_disk->disk_name);
> - set_bit(BDEV_NEED_PART_SCAN, &bdev->bd_flags);
> + set_bit(GD_NEED_PART_SCAN, &bdev->bd_disk->state);
> return true;
> }
> EXPORT_SYMBOL(bdev_check_media_change);
> diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
> index 15eed210feeff4..2dca0aab0a9a25 100644
> --- a/drivers/block/nbd.c
> +++ b/drivers/block/nbd.c
> @@ -315,7 +315,7 @@ static void nbd_size_update(struct nbd_device *nbd)
> bd_set_nr_sectors(bdev, nr_sectors);
> set_blocksize(bdev, config->blksize);
> } else
> - set_bit(BDEV_NEED_PART_SCAN, &bdev->bd_flags);
> + set_bit(GD_NEED_PART_SCAN, &nbd->disk->state);
> bdput(bdev);
> }
> kobject_uevent(&nbd_to_dev(nbd)->kobj, KOBJ_CHANGE);
> @@ -1322,7 +1322,7 @@ static int nbd_start_device_ioctl(struct nbd_device *nbd, struct block_device *b
> return ret;
>
> if (max_part)
> - set_bit(BDEV_NEED_PART_SCAN, &bdev->bd_flags);
> + set_bit(GD_NEED_PART_SCAN, &nbd->disk->state);
> mutex_unlock(&nbd->config_lock);
> ret = wait_event_interruptible(config->recv_wq,
> atomic_read(&config->recv_threads) == 0);
> @@ -1500,9 +1500,9 @@ static int nbd_open(struct block_device *bdev, fmode_t mode)
> refcount_set(&nbd->config_refs, 1);
> refcount_inc(&nbd->refs);
> mutex_unlock(&nbd->config_lock);
> - set_bit(BDEV_NEED_PART_SCAN, &bdev->bd_flags);
> + set_bit(GD_NEED_PART_SCAN, &bdev->bd_disk->state);
> } else if (nbd_disconnected(nbd->config)) {
> - set_bit(BDEV_NEED_PART_SCAN, &bdev->bd_flags);
> + set_bit(GD_NEED_PART_SCAN, &bdev->bd_disk->state);
> }
> out:
> mutex_unlock(&nbd_index_mutex);
> diff --git a/drivers/ide/ide-gd.c b/drivers/ide/ide-gd.c
> index 661e2aa9c96784..e2b6c82586ce8b 100644
> --- a/drivers/ide/ide-gd.c
> +++ b/drivers/ide/ide-gd.c
> @@ -230,7 +230,7 @@ static int ide_gd_open(struct block_device *bdev, fmode_t mode)
> bdev->bd_disk->disk_name);
> drive->disk_ops->get_capacity(drive);
> set_capacity(disk, ide_gd_capacity(drive));
> - set_bit(BDEV_NEED_PART_SCAN, &bdev->bd_flags);
> + set_bit(GD_NEED_PART_SCAN, &disk->state);
> } else if (drive->dev_flags & IDE_DFLAG_FORMAT_IN_PROGRESS) {
> ret = -EBUSY;
> goto out_put_idkp;
> diff --git a/fs/block_dev.c b/fs/block_dev.c
> index 0b34955b9e360f..1a9325f4315769 100644
> --- a/fs/block_dev.c
> +++ b/fs/block_dev.c
> @@ -910,7 +910,6 @@ struct block_device *bdget(dev_t dev)
> bdev->bd_super = NULL;
> bdev->bd_inode = inode;
> bdev->bd_part_count = 0;
> - bdev->bd_flags = 0;
> inode->i_mode = S_IFBLK;
> inode->i_rdev = dev;
> inode->i_bdev = bdev;
> @@ -1385,7 +1384,7 @@ int bdev_disk_changed(struct block_device *bdev, bool invalidate)
>
> lockdep_assert_held(&bdev->bd_mutex);
>
> - clear_bit(BDEV_NEED_PART_SCAN, &bdev->bd_flags);
> + clear_bit(GD_NEED_PART_SCAN, &bdev->bd_disk->state);
>
> rescan:
> ret = blk_drop_partitions(bdev);
> @@ -1509,7 +1508,7 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, void *holder,
> * The latter is necessary to prevent ghost
> * partitions on a removed medium.
> */
> - if (test_bit(BDEV_NEED_PART_SCAN, &bdev->bd_flags) &&
> + if (test_bit(GD_NEED_PART_SCAN, &disk->state) &&
> (!ret || ret == -ENOMEDIUM))
> bdev_disk_changed(bdev, ret == -ENOMEDIUM);
>
> @@ -1539,7 +1538,7 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, void *holder,
> if (bdev->bd_disk->fops->open)
> ret = bdev->bd_disk->fops->open(bdev, mode);
> /* the same as first opener case, read comment there */
> - if (test_bit(BDEV_NEED_PART_SCAN, &bdev->bd_flags) &&
> + if (test_bit(GD_NEED_PART_SCAN, &disk->state) &&
> (!ret || ret == -ENOMEDIUM))
> bdev_disk_changed(bdev, ret == -ENOMEDIUM);
> if (ret)
> diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h
> index 6ffa783e16335e..eb20e28184ab19 100644
> --- a/include/linux/blk_types.h
> +++ b/include/linux/blk_types.h
> @@ -19,8 +19,6 @@ struct cgroup_subsys_state;
> typedef void (bio_end_io_t) (struct bio *);
> struct bio_crypt_ctx;
>
> -#define BDEV_NEED_PART_SCAN 0
> -
> struct block_device {
> dev_t bd_dev;
> int bd_openers;
> @@ -39,7 +37,7 @@ struct block_device {
> struct hd_struct * bd_part;
> /* number of times partitions within this device have been opened. */
> unsigned bd_part_count;
> - unsigned long bd_flags;
> +
> spinlock_t bd_size_lock; /* for bd_inode->i_size updates */
> struct gendisk * bd_disk;
> struct backing_dev_info *bd_bdi;
> diff --git a/include/linux/genhd.h b/include/linux/genhd.h
> index 1c97cf84f011a7..38f23d75701379 100644
> --- a/include/linux/genhd.h
> +++ b/include/linux/genhd.h
> @@ -191,6 +191,8 @@ struct gendisk {
> void *private_data;
>
> int flags;
> + unsigned long state;
> +#define GD_NEED_PART_SCAN 0
> struct rw_semaphore lookup_sem;
> struct kobject *slave_dir;
>
> --
> 2.28.0
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
next prev parent reply other threads:[~2020-09-24 13:40 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-17 16:57 remove blkdev_get as a public API Christoph Hellwig
2020-09-17 16:57 ` [PATCH 01/14] block: move the NEED_PART_SCAN flag to struct gendisk Christoph Hellwig
2020-09-24 8:56 ` Jan Kara [this message]
2020-09-17 16:57 ` [PATCH 02/14] block: switch register_disk to use blkdev_get_by_dev Christoph Hellwig
2020-09-18 8:52 ` Sergei Shtylyov
2020-09-19 5:15 ` Christoph Hellwig
2020-09-17 16:57 ` [PATCH 03/14] block: cleanup blkdev_bszset Christoph Hellwig
2020-09-17 16:57 ` [PATCH 04/14] pktcdvd: remove the if 0'ed pkt_start_recovery function Christoph Hellwig
2020-09-17 16:57 ` [PATCH 05/14] pktcdvd: use blkdev_get_by_dev instead of open coding it Christoph Hellwig
2020-09-17 16:57 ` [PATCH 06/14] zram: cleanup backing_dev_store Christoph Hellwig
2020-09-17 16:57 ` [PATCH 07/14] raw: don't keep unopened block device around Christoph Hellwig
2020-09-17 16:57 ` [PATCH 08/14] dasd: cleanup dasd_scan_partitions Christoph Hellwig
2020-09-17 16:57 ` [PATCH 09/14] ocfs2: cleanup o2hb_region_dev_store Christoph Hellwig
2020-09-18 2:11 ` Joseph Qi
2020-09-17 16:57 ` [PATCH 10/14] mm: cleanup claim_swapfile Christoph Hellwig
2020-09-17 16:57 ` [PATCH 11/14] PM: rewrite is_hibernate_resume_dev to not require an inode Christoph Hellwig
2020-09-17 17:26 ` Rafael J. Wysocki
2020-09-19 9:06 ` Pavel Machek
2020-09-17 16:57 ` [PATCH 12/14] mm: split swap_type_of Christoph Hellwig
2020-09-17 16:57 ` [PATCH 13/14] PM: mm: cleanup swsusp_swap_check Christoph Hellwig
2020-09-18 16:01 ` Rafael J. Wysocki
2020-09-19 9:06 ` Pavel Machek
2020-09-17 16:57 ` [PATCH 14/14] block: mark blkdev_get static Christoph Hellwig
2020-09-21 7:19 remove blkdev_get as a public API v2 Christoph Hellwig
2020-09-21 7:19 ` [PATCH 01/14] block: move the NEED_PART_SCAN flag to struct gendisk Christoph Hellwig
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=20200924085633.GD27019@quack2.suse.cz \
--to=jack@suse.cz \
--cc=akpm@linux-foundation.org \
--cc=axboe@kernel.dk \
--cc=hch@lst.de \
--cc=hoeppner@linux.ibm.com \
--cc=josef@toxicpanda.com \
--cc=joseph.qi@linux.alibaba.com \
--cc=len.brown@intel.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-ide@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=minchan@kernel.org \
--cc=nbd@other.debian.org \
--cc=ocfs2-devel@oss.oracle.com \
--cc=pavel@ucw.cz \
--cc=rjw@rjwysocki.net \
--cc=sth@linux.ibm.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 NNTP newsgroup(s).