Linux-Fsdevel Archive on lore.kernel.org
help / color / mirror / Atom feed
* remove revalidate_disk()
@ 2020-09-01 15:57 Christoph Hellwig
  2020-09-01 15:57 ` [PATCH 1/9] Documentation/filesystems/locking.rst: remove an incorrect sentence Christoph Hellwig
                   ` (10 more replies)
  0 siblings, 11 replies; 21+ messages in thread
From: Christoph Hellwig @ 2020-09-01 15:57 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Josef Bacik, Dan Williams, dm-devel, Martin K. Petersen,
	linux-kernel, linux-block, nbd, ceph-devel, virtualization,
	linux-raid, linux-nvdimm, linux-nvme, linux-scsi, linux-fsdevel

Hi Jens,

this series removes the revalidate_disk() function, which has been a
really odd duck in the last years.  The prime reason why most people
use it is because it propagates a size change from the gendisk to
the block_device structure.  But it also calls into the rather ill
defined ->revalidate_disk method which is rather useless for the
callers.  So this adds a new helper to just propagate the size, and
cleans up all kinds of mess around this area.  Follow on patches
will eventuall kill of ->revalidate_disk entirely, but ther are a lot
more patches needed for that.

Diffstat:
 Documentation/filesystems/locking.rst |    3 --
 block/genhd.c                         |    9 ++----
 drivers/block/nbd.c                   |    8 ++---
 drivers/block/rbd.c                   |    2 -
 drivers/block/rnbd/rnbd-clt.c         |   10 +------
 drivers/block/virtio_blk.c            |    2 -
 drivers/block/zram/zram_drv.c         |    4 +-
 drivers/md/dm-raid.c                  |    2 -
 drivers/md/md-cluster.c               |    6 ++--
 drivers/md/md-linear.c                |    2 -
 drivers/md/md.c                       |   10 +++----
 drivers/md/md.h                       |    2 -
 drivers/nvdimm/blk.c                  |    3 --
 drivers/nvdimm/btt.c                  |    3 --
 drivers/nvdimm/bus.c                  |    9 ++----
 drivers/nvdimm/nd.h                   |    2 -
 drivers/nvdimm/pmem.c                 |    3 --
 drivers/nvme/host/core.c              |   16 +++++++----
 drivers/scsi/sd.c                     |    6 ++--
 fs/block_dev.c                        |   46 ++++++++++++++++------------------
 include/linux/blk_types.h             |    4 ++
 include/linux/genhd.h                 |    6 ++--
 22 files changed, 74 insertions(+), 84 deletions(-)

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH 1/9] Documentation/filesystems/locking.rst: remove an incorrect sentence
  2020-09-01 15:57 remove revalidate_disk() Christoph Hellwig
@ 2020-09-01 15:57 ` Christoph Hellwig
  2020-09-02  7:22   ` Johannes Thumshirn
  2020-09-01 15:57 ` [PATCH 2/9] block: don't clear bd_invalidated in check_disk_size_change Christoph Hellwig
                   ` (9 subsequent siblings)
  10 siblings, 1 reply; 21+ messages in thread
From: Christoph Hellwig @ 2020-09-01 15:57 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Josef Bacik, Dan Williams, dm-devel, Martin K. Petersen,
	linux-kernel, linux-block, nbd, ceph-devel, virtualization,
	linux-raid, linux-nvdimm, linux-nvme, linux-scsi, linux-fsdevel

unlock_native_capacity is never called from check_disk_change(), and
while revalidate_disk can be called from it, it can also be called
from two other places at the moment.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 Documentation/filesystems/locking.rst | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/Documentation/filesystems/locking.rst b/Documentation/filesystems/locking.rst
index 64f94a18d97e75..c0f2c7586531b0 100644
--- a/Documentation/filesystems/locking.rst
+++ b/Documentation/filesystems/locking.rst
@@ -488,9 +488,6 @@ getgeo:			no
 swap_slot_free_notify:	no	(see below)
 ======================= ===================
 
-unlock_native_capacity and revalidate_disk are called only from
-check_disk_change().
-
 swap_slot_free_notify is called with swap_lock and sometimes the page lock
 held.
 
-- 
2.28.0


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH 2/9] block: don't clear bd_invalidated in check_disk_size_change
  2020-09-01 15:57 remove revalidate_disk() Christoph Hellwig
  2020-09-01 15:57 ` [PATCH 1/9] Documentation/filesystems/locking.rst: remove an incorrect sentence Christoph Hellwig
@ 2020-09-01 15:57 ` Christoph Hellwig
  2020-09-01 15:57 ` [PATCH 3/9] block: rename bd_invalidated Christoph Hellwig
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 21+ messages in thread
From: Christoph Hellwig @ 2020-09-01 15:57 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Josef Bacik, Dan Williams, dm-devel, Martin K. Petersen,
	linux-kernel, linux-block, nbd, ceph-devel, virtualization,
	linux-raid, linux-nvdimm, linux-nvme, linux-scsi, linux-fsdevel

bd_invalidated is set by check_disk_change or in add_disk to initiate a
partition scan.  Move it from check_disk_size_change which is called
from both revalidate_disk() and bdev_disk_changed() to only the latter,
as that is what is called from the block device open code (and nbd) to
deal with the bd_invalidated event.  revalidate_disk() on the other hand
is mostly used to propagate a size update from the gendisk to the block
device, which is entirely unrelated.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/block_dev.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/block_dev.c b/fs/block_dev.c
index 08158bb2e76c85..2760292045c082 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -1302,7 +1302,6 @@ static void check_disk_size_change(struct gendisk *disk,
 		}
 		i_size_write(bdev->bd_inode, disk_size);
 	}
-	bdev->bd_invalidated = 0;
 	spin_unlock(&bdev->bd_size_lock);
 
 	if (bdev_size > disk_size) {
@@ -1391,6 +1390,8 @@ int bdev_disk_changed(struct block_device *bdev, bool invalidate)
 
 	lockdep_assert_held(&bdev->bd_mutex);
 
+	bdev->bd_invalidated = 0;
+
 rescan:
 	ret = blk_drop_partitions(bdev);
 	if (ret)
-- 
2.28.0


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH 3/9] block: rename bd_invalidated
  2020-09-01 15:57 remove revalidate_disk() Christoph Hellwig
  2020-09-01 15:57 ` [PATCH 1/9] Documentation/filesystems/locking.rst: remove an incorrect sentence Christoph Hellwig
  2020-09-01 15:57 ` [PATCH 2/9] block: don't clear bd_invalidated in check_disk_size_change Christoph Hellwig
@ 2020-09-01 15:57 ` Christoph Hellwig
  2020-09-02  7:23   ` Johannes Thumshirn
  2020-09-01 15:57 ` [PATCH 4/9] block: add a new revalidate_disk_size helper Christoph Hellwig
                   ` (7 subsequent siblings)
  10 siblings, 1 reply; 21+ messages in thread
From: Christoph Hellwig @ 2020-09-01 15:57 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Josef Bacik, Dan Williams, dm-devel, Martin K. Petersen,
	linux-kernel, linux-block, nbd, ceph-devel, virtualization,
	linux-raid, linux-nvdimm, linux-nvme, linux-scsi, linux-fsdevel

Replace bd_invalidate with a new BDEV_NEED_PART_SCAN flag in a bd_flags
variable to better describe the condition.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 block/genhd.c             |  2 +-
 drivers/block/nbd.c       |  8 ++++----
 fs/block_dev.c            | 10 +++++-----
 include/linux/blk_types.h |  4 +++-
 4 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/block/genhd.c b/block/genhd.c
index 99c64641c3148c..a2c0ec694918e5 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -734,7 +734,7 @@ static void register_disk(struct device *parent, struct gendisk *disk,
 	if (!bdev)
 		goto exit;
 
-	bdev->bd_invalidated = 1;
+	set_bit(BDEV_NEED_PART_SCAN, &bdev->bd_flags);
 	err = blkdev_get(bdev, FMODE_READ, NULL);
 	if (err < 0)
 		goto exit;
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index a54f2d155a31a5..15eed210feeff4 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
-			bdev->bd_invalidated = 1;
+			set_bit(BDEV_NEED_PART_SCAN, &bdev->bd_flags);
 		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)
-		bdev->bd_invalidated = 1;
+		set_bit(BDEV_NEED_PART_SCAN, &bdev->bd_flags);
 	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);
-		bdev->bd_invalidated = 1;
+		set_bit(BDEV_NEED_PART_SCAN, &bdev->bd_flags);
 	} else if (nbd_disconnected(nbd->config)) {
-		bdev->bd_invalidated = 1;
+		set_bit(BDEV_NEED_PART_SCAN, &bdev->bd_flags);
 	}
 out:
 	mutex_unlock(&nbd_index_mutex);
diff --git a/fs/block_dev.c b/fs/block_dev.c
index 2760292045c082..0207623769715d 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -881,7 +881,7 @@ struct block_device *bdget(dev_t dev)
 		bdev->bd_super = NULL;
 		bdev->bd_inode = inode;
 		bdev->bd_part_count = 0;
-		bdev->bd_invalidated = 0;
+		bdev->bd_flags = 0;
 		inode->i_mode = S_IFBLK;
 		inode->i_rdev = dev;
 		inode->i_bdev = bdev;
@@ -1365,7 +1365,7 @@ int check_disk_change(struct block_device *bdev)
 	if (__invalidate_device(bdev, true))
 		pr_warn("VFS: busy inodes on changed media %s\n",
 			disk->disk_name);
-	bdev->bd_invalidated = 1;
+	set_bit(BDEV_NEED_PART_SCAN, &bdev->bd_flags);
 	if (bdops->revalidate_disk)
 		bdops->revalidate_disk(bdev->bd_disk);
 	return 1;
@@ -1390,7 +1390,7 @@ int bdev_disk_changed(struct block_device *bdev, bool invalidate)
 
 	lockdep_assert_held(&bdev->bd_mutex);
 
-	bdev->bd_invalidated = 0;
+	clear_bit(BDEV_NEED_PART_SCAN, &bdev->bd_flags);
 
 rescan:
 	ret = blk_drop_partitions(bdev);
@@ -1528,7 +1528,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 (bdev->bd_invalidated &&
+			if (test_bit(BDEV_NEED_PART_SCAN, &bdev->bd_flags) &&
 			    (!ret || ret == -ENOMEDIUM))
 				bdev_disk_changed(bdev, ret == -ENOMEDIUM);
 
@@ -1558,7 +1558,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 (bdev->bd_invalidated &&
+			if (test_bit(BDEV_NEED_PART_SCAN, &bdev->bd_flags) &&
 			    (!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 63a39e47fc6047..c21eff7efda237 100644
--- a/include/linux/blk_types.h
+++ b/include/linux/blk_types.h
@@ -19,6 +19,8 @@ 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;  /* not a kdev_t - it's a search key */
 	int			bd_openers;
@@ -37,7 +39,7 @@ struct block_device {
 	struct hd_struct *	bd_part;
 	/* number of times partitions within this device have been opened. */
 	unsigned		bd_part_count;
-	int			bd_invalidated;
+	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;
-- 
2.28.0


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH 4/9] block: add a new revalidate_disk_size helper
  2020-09-01 15:57 remove revalidate_disk() Christoph Hellwig
                   ` (2 preceding siblings ...)
  2020-09-01 15:57 ` [PATCH 3/9] block: rename bd_invalidated Christoph Hellwig
@ 2020-09-01 15:57 ` Christoph Hellwig
  2020-09-02  6:06   ` Song Liu
  2020-09-02  7:23   ` Johannes Thumshirn
  2020-09-01 15:57 ` [PATCH 5/9] block: use revalidate_disk_size in set_capacity_revalidate_and_notify Christoph Hellwig
                   ` (6 subsequent siblings)
  10 siblings, 2 replies; 21+ messages in thread
From: Christoph Hellwig @ 2020-09-01 15:57 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Josef Bacik, Dan Williams, dm-devel, Martin K. Petersen,
	linux-kernel, linux-block, nbd, ceph-devel, virtualization,
	linux-raid, linux-nvdimm, linux-nvme, linux-scsi, linux-fsdevel

revalidate_disk is a relative awkward helper for driver use, as it first
calls an optional driver method and then updates the block device size,
while most callers either don't need the method call at all, or want to
keep state between the caller and the called method.

Add a revalidate_disk_size helper that just performs the update of the
block device size from the gendisk one, and switch all drivers that do
not implement ->revalidate_disk to use the new helper instead of
revalidate_disk()

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/block/rbd.c           |  2 +-
 drivers/block/rnbd/rnbd-clt.c | 10 ++-------
 drivers/block/virtio_blk.c    |  2 +-
 drivers/block/zram/zram_drv.c |  4 ++--
 drivers/md/dm-raid.c          |  2 +-
 drivers/md/md-cluster.c       |  6 ++---
 drivers/md/md-linear.c        |  2 +-
 drivers/md/md.c               | 10 ++++-----
 fs/block_dev.c                | 42 ++++++++++++++++++++++++-----------
 include/linux/genhd.h         |  1 +
 10 files changed, 46 insertions(+), 35 deletions(-)

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 01153903969321..5d3923c0997ce0 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -4921,7 +4921,7 @@ static void rbd_dev_update_size(struct rbd_device *rbd_dev)
 		size = (sector_t)rbd_dev->mapping.size / SECTOR_SIZE;
 		dout("setting size to %llu sectors", (unsigned long long)size);
 		set_capacity(rbd_dev->disk, size);
-		revalidate_disk(rbd_dev->disk);
+		revalidate_disk_size(rbd_dev->disk, true);
 	}
 }
 
diff --git a/drivers/block/rnbd/rnbd-clt.c b/drivers/block/rnbd/rnbd-clt.c
index cc6a4e2587aec2..157538fc8be515 100644
--- a/drivers/block/rnbd/rnbd-clt.c
+++ b/drivers/block/rnbd/rnbd-clt.c
@@ -102,18 +102,12 @@ static int rnbd_clt_set_dev_attr(struct rnbd_clt_dev *dev,
 static int rnbd_clt_change_capacity(struct rnbd_clt_dev *dev,
 				    size_t new_nsectors)
 {
-	int err = 0;
-
 	rnbd_clt_info(dev, "Device size changed from %zu to %zu sectors\n",
 		       dev->nsectors, new_nsectors);
 	dev->nsectors = new_nsectors;
 	set_capacity(dev->gd, dev->nsectors);
-	err = revalidate_disk(dev->gd);
-	if (err)
-		rnbd_clt_err(dev,
-			      "Failed to change device size from %zu to %zu, err: %d\n",
-			      dev->nsectors, new_nsectors, err);
-	return err;
+	revalidate_disk_size(dev->gd, true);
+	return 0;
 }
 
 static int process_msg_open_rsp(struct rnbd_clt_dev *dev,
diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
index ca63a41059d68e..a314b9382442b6 100644
--- a/drivers/block/virtio_blk.c
+++ b/drivers/block/virtio_blk.c
@@ -598,7 +598,7 @@ static void virtblk_update_cache_mode(struct virtio_device *vdev)
 	struct virtio_blk *vblk = vdev->priv;
 
 	blk_queue_write_cache(vblk->disk->queue, writeback, false);
-	revalidate_disk(vblk->disk);
+	revalidate_disk_size(vblk->disk, true);
 }
 
 static const char *const virtblk_cache_types[] = {
diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index 9100ac36670afc..a356275605b104 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -1739,7 +1739,7 @@ static ssize_t disksize_store(struct device *dev,
 	zram->disksize = disksize;
 	set_capacity(zram->disk, zram->disksize >> SECTOR_SHIFT);
 
-	revalidate_disk(zram->disk);
+	revalidate_disk_size(zram->disk, true);
 	up_write(&zram->init_lock);
 
 	return len;
@@ -1786,7 +1786,7 @@ static ssize_t reset_store(struct device *dev,
 	/* Make sure all the pending I/O are finished */
 	fsync_bdev(bdev);
 	zram_reset_device(zram);
-	revalidate_disk(zram->disk);
+	revalidate_disk_size(zram->disk, true);
 	bdput(bdev);
 
 	mutex_lock(&bdev->bd_mutex);
diff --git a/drivers/md/dm-raid.c b/drivers/md/dm-raid.c
index 8d2b835d7a108c..56b723d012ac15 100644
--- a/drivers/md/dm-raid.c
+++ b/drivers/md/dm-raid.c
@@ -701,7 +701,7 @@ static void rs_set_capacity(struct raid_set *rs)
 	struct gendisk *gendisk = dm_disk(dm_table_get_md(rs->ti->table));
 
 	set_capacity(gendisk, rs->md.array_sectors);
-	revalidate_disk(gendisk);
+	revalidate_disk_size(gendisk, true);
 }
 
 /*
diff --git a/drivers/md/md-cluster.c b/drivers/md/md-cluster.c
index d50737ec403946..0580b51a156a1c 100644
--- a/drivers/md/md-cluster.c
+++ b/drivers/md/md-cluster.c
@@ -582,7 +582,7 @@ static int process_recvd_msg(struct mddev *mddev, struct cluster_msg *msg)
 		break;
 	case CHANGE_CAPACITY:
 		set_capacity(mddev->gendisk, mddev->array_sectors);
-		revalidate_disk(mddev->gendisk);
+		revalidate_disk_size(mddev->gendisk, true);
 		break;
 	case RESYNCING:
 		set_bit(MD_RESYNCING_REMOTE, &mddev->recovery);
@@ -1296,12 +1296,12 @@ static void update_size(struct mddev *mddev, sector_t old_dev_sectors)
 			pr_err("%s:%d: failed to send CHANGE_CAPACITY msg\n",
 			       __func__, __LINE__);
 		set_capacity(mddev->gendisk, mddev->array_sectors);
-		revalidate_disk(mddev->gendisk);
+		revalidate_disk_size(mddev->gendisk, true);
 	} else {
 		/* revert to previous sectors */
 		ret = mddev->pers->resize(mddev, old_dev_sectors);
 		if (!ret)
-			revalidate_disk(mddev->gendisk);
+			revalidate_disk_size(mddev->gendisk, true);
 		ret = __sendmsg(cinfo, &cmsg);
 		if (ret)
 			pr_err("%s:%d: failed to send METADATA_UPDATED msg\n",
diff --git a/drivers/md/md-linear.c b/drivers/md/md-linear.c
index c2ae9125c4c381..5ab22069b5be9c 100644
--- a/drivers/md/md-linear.c
+++ b/drivers/md/md-linear.c
@@ -202,7 +202,7 @@ static int linear_add(struct mddev *mddev, struct md_rdev *rdev)
 	md_set_array_sectors(mddev, linear_size(mddev, 0, 0));
 	set_capacity(mddev->gendisk, mddev->array_sectors);
 	mddev_resume(mddev);
-	revalidate_disk(mddev->gendisk);
+	revalidate_disk_size(mddev->gendisk, true);
 	kfree_rcu(oldconf, rcu);
 	return 0;
 }
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 60727820702300..9562ef598ae1f4 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -5358,7 +5358,7 @@ array_size_store(struct mddev *mddev, const char *buf, size_t len)
 		mddev->array_sectors = sectors;
 		if (mddev->pers) {
 			set_capacity(mddev->gendisk, mddev->array_sectors);
-			revalidate_disk(mddev->gendisk);
+			revalidate_disk_size(mddev->gendisk, true);
 		}
 	}
 	mddev_unlock(mddev);
@@ -6109,7 +6109,7 @@ int do_md_run(struct mddev *mddev)
 	md_wakeup_thread(mddev->sync_thread); /* possibly kick off a reshape */
 
 	set_capacity(mddev->gendisk, mddev->array_sectors);
-	revalidate_disk(mddev->gendisk);
+	revalidate_disk_size(mddev->gendisk, true);
 	clear_bit(MD_NOT_READY, &mddev->flags);
 	mddev->changed = 1;
 	kobject_uevent(&disk_to_dev(mddev->gendisk)->kobj, KOBJ_CHANGE);
@@ -6427,7 +6427,7 @@ static int do_md_stop(struct mddev *mddev, int mode,
 		set_capacity(disk, 0);
 		mutex_unlock(&mddev->open_mutex);
 		mddev->changed = 1;
-		revalidate_disk(disk);
+		revalidate_disk_size(disk, true);
 
 		if (mddev->ro)
 			mddev->ro = 0;
@@ -7259,7 +7259,7 @@ static int update_size(struct mddev *mddev, sector_t num_sectors)
 			md_cluster_ops->update_size(mddev, old_dev_sectors);
 		else if (mddev->queue) {
 			set_capacity(mddev->gendisk, mddev->array_sectors);
-			revalidate_disk(mddev->gendisk);
+			revalidate_disk_size(mddev->gendisk, true);
 		}
 	}
 	return rv;
@@ -9018,7 +9018,7 @@ void md_do_sync(struct md_thread *thread)
 		mddev_unlock(mddev);
 		if (!mddev_is_clustered(mddev)) {
 			set_capacity(mddev->gendisk, mddev->array_sectors);
-			revalidate_disk(mddev->gendisk);
+			revalidate_disk_size(mddev->gendisk, true);
 		}
 	}
 
diff --git a/fs/block_dev.c b/fs/block_dev.c
index 0207623769715d..85f013315d48b3 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -1311,6 +1311,34 @@ static void check_disk_size_change(struct gendisk *disk,
 	}
 }
 
+/**
+ * revalidate_disk_size - checks for disk size change and adjusts bdev size.
+ * @disk: struct gendisk to check
+ * @verbose: if %true log a message about a size change if there is any
+ *
+ * This routine checks to see if the bdev size does not match the disk size
+ * and adjusts it if it differs. When shrinking the bdev size, its all caches
+ * are freed.
+ */
+void revalidate_disk_size(struct gendisk *disk, bool verbose)
+{
+	struct block_device *bdev;
+
+	/*
+	 * Hidden disks don't have associated bdev so there's no point in
+	 * revalidating them.
+	 */
+	if (disk->flags & GENHD_FL_HIDDEN)
+		return;
+
+	bdev = bdget_disk(disk, 0);
+	if (bdev) {
+		check_disk_size_change(disk, bdev, verbose);
+		bdput(bdev);
+	}
+}
+EXPORT_SYMBOL(revalidate_disk_size);
+
 /**
  * revalidate_disk - wrapper for lower-level driver's revalidate_disk call-back
  * @disk: struct gendisk to be revalidated
@@ -1325,19 +1353,7 @@ int revalidate_disk(struct gendisk *disk)
 
 	if (disk->fops->revalidate_disk)
 		ret = disk->fops->revalidate_disk(disk);
-
-	/*
-	 * Hidden disks don't have associated bdev so there's no point in
-	 * revalidating it.
-	 */
-	if (!(disk->flags & GENHD_FL_HIDDEN)) {
-		struct block_device *bdev = bdget_disk(disk, 0);
-
-		if (bdev) {
-			check_disk_size_change(disk, bdev, ret == 0);
-			bdput(bdev);
-		}
-	}
+	revalidate_disk_size(disk, ret == 0);
 	return ret;
 }
 EXPORT_SYMBOL(revalidate_disk);
diff --git a/include/linux/genhd.h b/include/linux/genhd.h
index 39025dc0397c04..8e9c9d3a493fae 100644
--- a/include/linux/genhd.h
+++ b/include/linux/genhd.h
@@ -373,6 +373,7 @@ int register_blkdev(unsigned int major, const char *name);
 void unregister_blkdev(unsigned int major, const char *name);
 
 int revalidate_disk(struct gendisk *disk);
+void revalidate_disk_size(struct gendisk *disk, bool verbose);
 int check_disk_change(struct block_device *bdev);
 int __invalidate_device(struct block_device *bdev, bool kill_dirty);
 void bd_set_nr_sectors(struct block_device *bdev, sector_t sectors);
-- 
2.28.0


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH 5/9] block: use revalidate_disk_size in set_capacity_revalidate_and_notify
  2020-09-01 15:57 remove revalidate_disk() Christoph Hellwig
                   ` (3 preceding siblings ...)
  2020-09-01 15:57 ` [PATCH 4/9] block: add a new revalidate_disk_size helper Christoph Hellwig
@ 2020-09-01 15:57 ` Christoph Hellwig
  2020-09-02  7:23   ` Johannes Thumshirn
  2020-09-01 15:57 ` [PATCH 6/9] nvme: opencode revalidate_disk in nvme_validate_ns Christoph Hellwig
                   ` (5 subsequent siblings)
  10 siblings, 1 reply; 21+ messages in thread
From: Christoph Hellwig @ 2020-09-01 15:57 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Josef Bacik, Dan Williams, dm-devel, Martin K. Petersen,
	linux-kernel, linux-block, nbd, ceph-devel, virtualization,
	linux-raid, linux-nvdimm, linux-nvme, linux-scsi, linux-fsdevel

Only virtio_blk and xen-blkfront set the revalidate argument to true,
and both do not implement the ->revalidate_disk method.  So switch
to the helper that just updates the size instead.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 block/genhd.c         | 7 +++----
 include/linux/genhd.h | 4 ++--
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/block/genhd.c b/block/genhd.c
index a2c0ec694918e5..431d4081b50ec7 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -50,14 +50,13 @@ static void disk_release_events(struct gendisk *disk);
  * zero and will not be set to zero
  */
 void set_capacity_revalidate_and_notify(struct gendisk *disk, sector_t size,
-					bool revalidate)
+					bool update_bdev)
 {
 	sector_t capacity = get_capacity(disk);
 
 	set_capacity(disk, size);
-
-	if (revalidate)
-		revalidate_disk(disk);
+	if (update_bdev)
+		revalidate_disk_size(disk, true);
 
 	if (capacity != size && capacity != 0 && size != 0) {
 		char *envp[] = { "RESIZE=1", NULL };
diff --git a/include/linux/genhd.h b/include/linux/genhd.h
index 8e9c9d3a493fae..c340b392452ce6 100644
--- a/include/linux/genhd.h
+++ b/include/linux/genhd.h
@@ -315,8 +315,8 @@ static inline int get_disk_ro(struct gendisk *disk)
 extern void disk_block_events(struct gendisk *disk);
 extern void disk_unblock_events(struct gendisk *disk);
 extern void disk_flush_events(struct gendisk *disk, unsigned int mask);
-extern void set_capacity_revalidate_and_notify(struct gendisk *disk,
-			sector_t size, bool revalidate);
+void set_capacity_revalidate_and_notify(struct gendisk *disk, sector_t size,
+		bool update_bdev);
 extern unsigned int disk_clear_events(struct gendisk *disk, unsigned int mask);
 
 /* drivers/char/random.c */
-- 
2.28.0


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH 6/9] nvme: opencode revalidate_disk in nvme_validate_ns
  2020-09-01 15:57 remove revalidate_disk() Christoph Hellwig
                   ` (4 preceding siblings ...)
  2020-09-01 15:57 ` [PATCH 5/9] block: use revalidate_disk_size in set_capacity_revalidate_and_notify Christoph Hellwig
@ 2020-09-01 15:57 ` Christoph Hellwig
  2020-09-02  7:23   ` Johannes Thumshirn
  2020-09-01 15:57 ` [PATCH 7/9] sd: open code revalidate_disk Christoph Hellwig
                   ` (4 subsequent siblings)
  10 siblings, 1 reply; 21+ messages in thread
From: Christoph Hellwig @ 2020-09-01 15:57 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Josef Bacik, Dan Williams, dm-devel, Martin K. Petersen,
	linux-kernel, linux-block, nbd, ceph-devel, virtualization,
	linux-raid, linux-nvdimm, linux-nvme, linux-scsi, linux-fsdevel

Keep control in the NVMe driver instead of going through an indirect
call back into ->revalidate_disk.  Also reorder the function a bit to be
easier to follow with the additional code.

And now that we have removed all callers of revalidate_disk() in the nvme
code, ->revalidate_disk is only called from the open code when first
opening the device.  Which is of course totally pointless as we have
a valid size since the initial scan, and will get an updated view
through the asynchronous notifiation everytime the size changes.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/nvme/host/core.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index bc18523774b4be..9428e7deb68b09 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -2323,7 +2323,6 @@ static const struct block_device_operations nvme_fops = {
 	.open		= nvme_open,
 	.release	= nvme_release,
 	.getgeo		= nvme_getgeo,
-	.revalidate_disk= nvme_revalidate_disk,
 	.report_zones	= nvme_report_zones,
 	.pr_ops		= &nvme_pr_ops,
 };
@@ -4020,14 +4019,19 @@ static void nvme_ns_remove_by_nsid(struct nvme_ctrl *ctrl, u32 nsid)
 static void nvme_validate_ns(struct nvme_ctrl *ctrl, unsigned nsid)
 {
 	struct nvme_ns *ns;
+	int ret;
 
 	ns = nvme_find_get_ns(ctrl, nsid);
-	if (ns) {
-		if (revalidate_disk(ns->disk))
-			nvme_ns_remove(ns);
-		nvme_put_ns(ns);
-	} else
+	if (!ns) {
 		nvme_alloc_ns(ctrl, nsid);
+		return;
+	}
+
+	ret = nvme_revalidate_disk(ns->disk);
+	revalidate_disk_size(ns->disk, ret == 0);
+	if (ret)
+		nvme_ns_remove(ns);
+	nvme_put_ns(ns);
 }
 
 static void nvme_remove_invalid_namespaces(struct nvme_ctrl *ctrl,
-- 
2.28.0


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH 7/9] sd: open code revalidate_disk
  2020-09-01 15:57 remove revalidate_disk() Christoph Hellwig
                   ` (5 preceding siblings ...)
  2020-09-01 15:57 ` [PATCH 6/9] nvme: opencode revalidate_disk in nvme_validate_ns Christoph Hellwig
@ 2020-09-01 15:57 ` Christoph Hellwig
  2020-09-02  7:24   ` Johannes Thumshirn
  2020-09-01 15:57 ` [PATCH 8/9] nvdimm: simplify revalidate_disk handling Christoph Hellwig
                   ` (3 subsequent siblings)
  10 siblings, 1 reply; 21+ messages in thread
From: Christoph Hellwig @ 2020-09-01 15:57 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Josef Bacik, Dan Williams, dm-devel, Martin K. Petersen,
	linux-kernel, linux-block, nbd, ceph-devel, virtualization,
	linux-raid, linux-nvdimm, linux-nvme, linux-scsi, linux-fsdevel

Instead of calling revalidate_disk just do the work directly by
calling sd_revalidate_disk, and revalidate_disk_size where needed.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/scsi/sd.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 95018e650f2d0c..2bec8cd526164d 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -217,7 +217,7 @@ cache_type_store(struct device *dev, struct device_attribute *attr,
 			sd_print_sense_hdr(sdkp, &sshdr);
 		return -EINVAL;
 	}
-	revalidate_disk(sdkp->disk);
+	sd_revalidate_disk(sdkp->disk);
 	return count;
 }
 
@@ -1706,8 +1706,10 @@ static int sd_sync_cache(struct scsi_disk *sdkp, struct scsi_sense_hdr *sshdr)
 static void sd_rescan(struct device *dev)
 {
 	struct scsi_disk *sdkp = dev_get_drvdata(dev);
+	int ret;
 
-	revalidate_disk(sdkp->disk);
+	ret = sd_revalidate_disk(sdkp->disk);
+	revalidate_disk_size(sdkp->disk, ret == 0);
 }
 
 static int sd_ioctl(struct block_device *bdev, fmode_t mode,
-- 
2.28.0


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH 8/9] nvdimm: simplify revalidate_disk handling
  2020-09-01 15:57 remove revalidate_disk() Christoph Hellwig
                   ` (6 preceding siblings ...)
  2020-09-01 15:57 ` [PATCH 7/9] sd: open code revalidate_disk Christoph Hellwig
@ 2020-09-01 15:57 ` Christoph Hellwig
  2020-09-01 15:57 ` [PATCH 9/9] block: remove revalidate_disk() Christoph Hellwig
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 21+ messages in thread
From: Christoph Hellwig @ 2020-09-01 15:57 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Josef Bacik, Dan Williams, dm-devel, Martin K. Petersen,
	linux-kernel, linux-block, nbd, ceph-devel, virtualization,
	linux-raid, linux-nvdimm, linux-nvme, linux-scsi, linux-fsdevel

The nvdimm block driver abuse revalidate_disk in a strange way, and
totally unrelated to what other drivers do.  Simplify this by just
calling nvdimm_revalidate_disk (which seems rather misnamed) from the
probe routines, as the additional bdev size revalidation is pointless
at this point, and remove the revalidate_disk methods given that
it can only be triggered from add_disk, which is right before the
manual calls.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/nvdimm/blk.c  | 3 +--
 drivers/nvdimm/btt.c  | 3 +--
 drivers/nvdimm/bus.c  | 9 +++------
 drivers/nvdimm/nd.h   | 2 +-
 drivers/nvdimm/pmem.c | 3 +--
 5 files changed, 7 insertions(+), 13 deletions(-)

diff --git a/drivers/nvdimm/blk.c b/drivers/nvdimm/blk.c
index 1f718381a04553..22e5617b2cea14 100644
--- a/drivers/nvdimm/blk.c
+++ b/drivers/nvdimm/blk.c
@@ -226,7 +226,6 @@ static int nsblk_rw_bytes(struct nd_namespace_common *ndns,
 static const struct block_device_operations nd_blk_fops = {
 	.owner = THIS_MODULE,
 	.submit_bio =  nd_blk_submit_bio,
-	.revalidate_disk = nvdimm_revalidate_disk,
 };
 
 static void nd_blk_release_queue(void *q)
@@ -284,7 +283,7 @@ static int nsblk_attach_disk(struct nd_namespace_blk *nsblk)
 
 	set_capacity(disk, available_disk_size >> SECTOR_SHIFT);
 	device_add_disk(dev, disk, NULL);
-	revalidate_disk(disk);
+	nvdimm_check_and_set_ro(disk);
 	return 0;
 }
 
diff --git a/drivers/nvdimm/btt.c b/drivers/nvdimm/btt.c
index 0ff610e728ff6f..0d710140bf93be 100644
--- a/drivers/nvdimm/btt.c
+++ b/drivers/nvdimm/btt.c
@@ -1513,7 +1513,6 @@ static const struct block_device_operations btt_fops = {
 	.submit_bio =		btt_submit_bio,
 	.rw_page =		btt_rw_page,
 	.getgeo =		btt_getgeo,
-	.revalidate_disk =	nvdimm_revalidate_disk,
 };
 
 static int btt_blk_init(struct btt *btt)
@@ -1558,7 +1557,7 @@ static int btt_blk_init(struct btt *btt)
 	set_capacity(btt->btt_disk, btt->nlba * btt->sector_size >> 9);
 	device_add_disk(&btt->nd_btt->dev, btt->btt_disk, NULL);
 	btt->nd_btt->size = btt->nlba * (u64)btt->sector_size;
-	revalidate_disk(btt->btt_disk);
+	nvdimm_check_and_set_ro(btt->btt_disk);
 
 	return 0;
 }
diff --git a/drivers/nvdimm/bus.c b/drivers/nvdimm/bus.c
index 955265656b96c7..2304c6183822e9 100644
--- a/drivers/nvdimm/bus.c
+++ b/drivers/nvdimm/bus.c
@@ -628,7 +628,7 @@ int __nd_driver_register(struct nd_device_driver *nd_drv, struct module *owner,
 }
 EXPORT_SYMBOL(__nd_driver_register);
 
-int nvdimm_revalidate_disk(struct gendisk *disk)
+void nvdimm_check_and_set_ro(struct gendisk *disk)
 {
 	struct device *dev = disk_to_dev(disk)->parent;
 	struct nd_region *nd_region = to_nd_region(dev->parent);
@@ -639,16 +639,13 @@ int nvdimm_revalidate_disk(struct gendisk *disk)
 	 * read-only if the disk is already read-only.
 	 */
 	if (disk_ro || nd_region->ro == disk_ro)
-		return 0;
+		return;
 
 	dev_info(dev, "%s read-only, marking %s read-only\n",
 			dev_name(&nd_region->dev), disk->disk_name);
 	set_disk_ro(disk, 1);
-
-	return 0;
-
 }
-EXPORT_SYMBOL(nvdimm_revalidate_disk);
+EXPORT_SYMBOL(nvdimm_check_and_set_ro);
 
 static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
 		char *buf)
diff --git a/drivers/nvdimm/nd.h b/drivers/nvdimm/nd.h
index 85c1ae813ea318..72740108ba4206 100644
--- a/drivers/nvdimm/nd.h
+++ b/drivers/nvdimm/nd.h
@@ -361,7 +361,7 @@ u64 nd_region_interleave_set_altcookie(struct nd_region *nd_region);
 void nvdimm_bus_lock(struct device *dev);
 void nvdimm_bus_unlock(struct device *dev);
 bool is_nvdimm_bus_locked(struct device *dev);
-int nvdimm_revalidate_disk(struct gendisk *disk);
+void nvdimm_check_and_set_ro(struct gendisk *disk);
 void nvdimm_drvdata_release(struct kref *kref);
 void put_ndd(struct nvdimm_drvdata *ndd);
 int nd_label_reserve_dpa(struct nvdimm_drvdata *ndd);
diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c
index fab29b514372d0..140cf3b9000c60 100644
--- a/drivers/nvdimm/pmem.c
+++ b/drivers/nvdimm/pmem.c
@@ -281,7 +281,6 @@ static const struct block_device_operations pmem_fops = {
 	.owner =		THIS_MODULE,
 	.submit_bio =		pmem_submit_bio,
 	.rw_page =		pmem_rw_page,
-	.revalidate_disk =	nvdimm_revalidate_disk,
 };
 
 static int pmem_dax_zero_page_range(struct dax_device *dax_dev, pgoff_t pgoff,
@@ -501,7 +500,7 @@ static int pmem_attach_disk(struct device *dev,
 	if (devm_add_action_or_reset(dev, pmem_release_disk, pmem))
 		return -ENOMEM;
 
-	revalidate_disk(disk);
+	nvdimm_check_and_set_ro(disk);
 
 	pmem->bb_state = sysfs_get_dirent(disk_to_dev(disk)->kobj.sd,
 					  "badblocks");
-- 
2.28.0


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH 9/9] block: remove revalidate_disk()
  2020-09-01 15:57 remove revalidate_disk() Christoph Hellwig
                   ` (7 preceding siblings ...)
  2020-09-01 15:57 ` [PATCH 8/9] nvdimm: simplify revalidate_disk handling Christoph Hellwig
@ 2020-09-01 15:57 ` Christoph Hellwig
  2020-09-02  5:59   ` Song Liu
  2020-09-02  7:25   ` Johannes Thumshirn
  2020-09-01 17:45 ` Josef Bacik
  2020-09-02 14:02 ` Jens Axboe
  10 siblings, 2 replies; 21+ messages in thread
From: Christoph Hellwig @ 2020-09-01 15:57 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Josef Bacik, Dan Williams, dm-devel, Martin K. Petersen,
	linux-kernel, linux-block, nbd, ceph-devel, virtualization,
	linux-raid, linux-nvdimm, linux-nvme, linux-scsi, linux-fsdevel

Remove the now unused helper.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/md/md.h       |  2 +-
 fs/block_dev.c        | 19 -------------------
 include/linux/genhd.h |  1 -
 3 files changed, 1 insertion(+), 21 deletions(-)

diff --git a/drivers/md/md.h b/drivers/md/md.h
index d9c4e6b7e9398d..f9e2ccdd22c478 100644
--- a/drivers/md/md.h
+++ b/drivers/md/md.h
@@ -397,7 +397,7 @@ struct mddev {
 	 * These locks are separate due to conflicting interactions
 	 * with bdev->bd_mutex.
 	 * Lock ordering is:
-	 *  reconfig_mutex -> bd_mutex : e.g. do_md_run -> revalidate_disk
+	 *  reconfig_mutex -> bd_mutex
 	 *  bd_mutex -> open_mutex:  e.g. __blkdev_get -> md_open
 	 */
 	struct mutex			open_mutex;
diff --git a/fs/block_dev.c b/fs/block_dev.c
index 85f013315d48b3..0771836d0220bd 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -1339,25 +1339,6 @@ void revalidate_disk_size(struct gendisk *disk, bool verbose)
 }
 EXPORT_SYMBOL(revalidate_disk_size);
 
-/**
- * revalidate_disk - wrapper for lower-level driver's revalidate_disk call-back
- * @disk: struct gendisk to be revalidated
- *
- * This routine is a wrapper for lower-level driver's revalidate_disk
- * call-backs.  It is used to do common pre and post operations needed
- * for all revalidate_disk operations.
- */
-int revalidate_disk(struct gendisk *disk)
-{
-	int ret = 0;
-
-	if (disk->fops->revalidate_disk)
-		ret = disk->fops->revalidate_disk(disk);
-	revalidate_disk_size(disk, ret == 0);
-	return ret;
-}
-EXPORT_SYMBOL(revalidate_disk);
-
 /*
  * This routine checks whether a removable media has been changed,
  * and invalidates all buffer-cache-entries in that case. This
diff --git a/include/linux/genhd.h b/include/linux/genhd.h
index c340b392452ce6..2cdc41a3fb6a57 100644
--- a/include/linux/genhd.h
+++ b/include/linux/genhd.h
@@ -372,7 +372,6 @@ extern void blk_unregister_region(dev_t devt, unsigned long range);
 int register_blkdev(unsigned int major, const char *name);
 void unregister_blkdev(unsigned int major, const char *name);
 
-int revalidate_disk(struct gendisk *disk);
 void revalidate_disk_size(struct gendisk *disk, bool verbose);
 int check_disk_change(struct block_device *bdev);
 int __invalidate_device(struct block_device *bdev, bool kill_dirty);
-- 
2.28.0


^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: remove revalidate_disk()
  2020-09-01 15:57 remove revalidate_disk() Christoph Hellwig
                   ` (8 preceding siblings ...)
  2020-09-01 15:57 ` [PATCH 9/9] block: remove revalidate_disk() Christoph Hellwig
@ 2020-09-01 17:45 ` Josef Bacik
  2020-09-02 14:02 ` Jens Axboe
  10 siblings, 0 replies; 21+ messages in thread
From: Josef Bacik @ 2020-09-01 17:45 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe
  Cc: Dan Williams, dm-devel, Martin K. Petersen, linux-kernel,
	linux-block, nbd, ceph-devel, virtualization, linux-raid,
	linux-nvdimm, linux-nvme, linux-scsi, linux-fsdevel

On 9/1/20 11:57 AM, Christoph Hellwig wrote:
> Hi Jens,
> 
> this series removes the revalidate_disk() function, which has been a
> really odd duck in the last years.  The prime reason why most people
> use it is because it propagates a size change from the gendisk to
> the block_device structure.  But it also calls into the rather ill
> defined ->revalidate_disk method which is rather useless for the
> callers.  So this adds a new helper to just propagate the size, and
> cleans up all kinds of mess around this area.  Follow on patches
> will eventuall kill of ->revalidate_disk entirely, but ther are a lot
> more patches needed for that.
> 

I applied and built everything on Jens's for-next, patch #2 was fuzzy but it 
applied.

I checked through everything, the only thing that was strange to me is not 
calling revalidate_disk_size() in nvdimm, but since it's during attach you point 
out it doesn't matter.  You can add

Reviewed-by: Josef Bacik <josef@toxicpanda.com>

To the series, thanks,

Josef

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 9/9] block: remove revalidate_disk()
  2020-09-01 15:57 ` [PATCH 9/9] block: remove revalidate_disk() Christoph Hellwig
@ 2020-09-02  5:59   ` Song Liu
  2020-09-02  7:25   ` Johannes Thumshirn
  1 sibling, 0 replies; 21+ messages in thread
From: Song Liu @ 2020-09-02  5:59 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Jens Axboe, Josef Bacik, Dan Williams, dm-devel,
	Martin K. Petersen, open list, linux-block, nbd, ceph-devel,
	virtualization, linux-raid, linux-nvdimm, linux-nvme, linux-scsi,
	Linux-Fsdevel

On Tue, Sep 1, 2020 at 9:00 AM Christoph Hellwig <hch@lst.de> wrote:
>
> Remove the now unused helper.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Acked-by: Song Liu <song@kernel.org>

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 4/9] block: add a new revalidate_disk_size helper
  2020-09-01 15:57 ` [PATCH 4/9] block: add a new revalidate_disk_size helper Christoph Hellwig
@ 2020-09-02  6:06   ` Song Liu
  2020-09-02  7:23   ` Johannes Thumshirn
  1 sibling, 0 replies; 21+ messages in thread
From: Song Liu @ 2020-09-02  6:06 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Jens Axboe, Josef Bacik, Dan Williams, dm-devel,
	Martin K. Petersen, open list, linux-block, nbd, ceph-devel,
	virtualization, linux-raid, linux-nvdimm, linux-nvme, linux-scsi,
	Linux-Fsdevel

On Tue, Sep 1, 2020 at 9:00 AM Christoph Hellwig <hch@lst.de> wrote:
>
[...]

>  drivers/md/md-cluster.c       |  6 ++---
>  drivers/md/md-linear.c        |  2 +-
>  drivers/md/md.c               | 10 ++++-----

For md bits:
Acked-by: Song Liu <song@kernel.org>

[...]
>
> +/**
> + * revalidate_disk_size - checks for disk size change and adjusts bdev size.
> + * @disk: struct gendisk to check
> + * @verbose: if %true log a message about a size change if there is any
> + *
> + * This routine checks to see if the bdev size does not match the disk size
> + * and adjusts it if it differs. When shrinking the bdev size, its all caches
> + * are freed.
> + */
> +void revalidate_disk_size(struct gendisk *disk, bool verbose)
> +{
> +       struct block_device *bdev;
> +
> +       /*
> +        * Hidden disks don't have associated bdev so there's no point in
> +        * revalidating them.
> +        */
> +       if (disk->flags & GENHD_FL_HIDDEN)
> +               return;
> +
> +       bdev = bdget_disk(disk, 0);
> +       if (bdev) {
> +               check_disk_size_change(disk, bdev, verbose);
> +               bdput(bdev);
> +       }
> +}
> +EXPORT_SYMBOL(revalidate_disk_size);

Shall we use EXPORT_SYMBOL_GPL() here?

[...]

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 1/9] Documentation/filesystems/locking.rst: remove an incorrect sentence
  2020-09-01 15:57 ` [PATCH 1/9] Documentation/filesystems/locking.rst: remove an incorrect sentence Christoph Hellwig
@ 2020-09-02  7:22   ` Johannes Thumshirn
  0 siblings, 0 replies; 21+ messages in thread
From: Johannes Thumshirn @ 2020-09-02  7:22 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe
  Cc: Josef Bacik, Dan Williams, dm-devel, Martin K. Petersen,
	linux-kernel, linux-block, nbd, ceph-devel, virtualization,
	linux-raid, linux-nvdimm, linux-nvme, linux-scsi, linux-fsdevel

Looks good,
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 3/9] block: rename bd_invalidated
  2020-09-01 15:57 ` [PATCH 3/9] block: rename bd_invalidated Christoph Hellwig
@ 2020-09-02  7:23   ` Johannes Thumshirn
  0 siblings, 0 replies; 21+ messages in thread
From: Johannes Thumshirn @ 2020-09-02  7:23 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe
  Cc: Josef Bacik, Dan Williams, dm-devel, Martin K. Petersen,
	linux-kernel, linux-block, nbd, ceph-devel, virtualization,
	linux-raid, linux-nvdimm, linux-nvme, linux-scsi, linux-fsdevel

Looks good,
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 4/9] block: add a new revalidate_disk_size helper
  2020-09-01 15:57 ` [PATCH 4/9] block: add a new revalidate_disk_size helper Christoph Hellwig
  2020-09-02  6:06   ` Song Liu
@ 2020-09-02  7:23   ` Johannes Thumshirn
  1 sibling, 0 replies; 21+ messages in thread
From: Johannes Thumshirn @ 2020-09-02  7:23 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe
  Cc: Josef Bacik, Dan Williams, dm-devel, Martin K. Petersen,
	linux-kernel, linux-block, nbd, ceph-devel, virtualization,
	linux-raid, linux-nvdimm, linux-nvme, linux-scsi, linux-fsdevel

Looks good,
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 5/9] block: use revalidate_disk_size in set_capacity_revalidate_and_notify
  2020-09-01 15:57 ` [PATCH 5/9] block: use revalidate_disk_size in set_capacity_revalidate_and_notify Christoph Hellwig
@ 2020-09-02  7:23   ` Johannes Thumshirn
  0 siblings, 0 replies; 21+ messages in thread
From: Johannes Thumshirn @ 2020-09-02  7:23 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe
  Cc: Josef Bacik, Dan Williams, dm-devel, Martin K. Petersen,
	linux-kernel, linux-block, nbd, ceph-devel, virtualization,
	linux-raid, linux-nvdimm, linux-nvme, linux-scsi, linux-fsdevel

Looks good,
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 6/9] nvme: opencode revalidate_disk in nvme_validate_ns
  2020-09-01 15:57 ` [PATCH 6/9] nvme: opencode revalidate_disk in nvme_validate_ns Christoph Hellwig
@ 2020-09-02  7:23   ` Johannes Thumshirn
  0 siblings, 0 replies; 21+ messages in thread
From: Johannes Thumshirn @ 2020-09-02  7:23 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe
  Cc: Josef Bacik, Dan Williams, dm-devel, Martin K. Petersen,
	linux-kernel, linux-block, nbd, ceph-devel, virtualization,
	linux-raid, linux-nvdimm, linux-nvme, linux-scsi, linux-fsdevel

Looks good,
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 7/9] sd: open code revalidate_disk
  2020-09-01 15:57 ` [PATCH 7/9] sd: open code revalidate_disk Christoph Hellwig
@ 2020-09-02  7:24   ` Johannes Thumshirn
  0 siblings, 0 replies; 21+ messages in thread
From: Johannes Thumshirn @ 2020-09-02  7:24 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe
  Cc: Josef Bacik, Dan Williams, dm-devel, Martin K. Petersen,
	linux-kernel, linux-block, nbd, ceph-devel, virtualization,
	linux-raid, linux-nvdimm, linux-nvme, linux-scsi, linux-fsdevel

Looks good,
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 9/9] block: remove revalidate_disk()
  2020-09-01 15:57 ` [PATCH 9/9] block: remove revalidate_disk() Christoph Hellwig
  2020-09-02  5:59   ` Song Liu
@ 2020-09-02  7:25   ` Johannes Thumshirn
  1 sibling, 0 replies; 21+ messages in thread
From: Johannes Thumshirn @ 2020-09-02  7:25 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe
  Cc: Josef Bacik, Dan Williams, dm-devel, Martin K. Petersen,
	linux-kernel, linux-block, nbd, ceph-devel, virtualization,
	linux-raid, linux-nvdimm, linux-nvme, linux-scsi, linux-fsdevel

Looks good,
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: remove revalidate_disk()
  2020-09-01 15:57 remove revalidate_disk() Christoph Hellwig
                   ` (9 preceding siblings ...)
  2020-09-01 17:45 ` Josef Bacik
@ 2020-09-02 14:02 ` Jens Axboe
  10 siblings, 0 replies; 21+ messages in thread
From: Jens Axboe @ 2020-09-02 14:02 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Josef Bacik, Dan Williams, dm-devel, Martin K. Petersen,
	linux-kernel, linux-block, nbd, ceph-devel, virtualization,
	linux-raid, linux-nvdimm, linux-nvme, linux-scsi, linux-fsdevel

On 9/1/20 9:57 AM, Christoph Hellwig wrote:
> Hi Jens,
> 
> this series removes the revalidate_disk() function, which has been a
> really odd duck in the last years.  The prime reason why most people
> use it is because it propagates a size change from the gendisk to
> the block_device structure.  But it also calls into the rather ill
> defined ->revalidate_disk method which is rather useless for the
> callers.  So this adds a new helper to just propagate the size, and
> cleans up all kinds of mess around this area.  Follow on patches
> will eventuall kill of ->revalidate_disk entirely, but ther are a lot
> more patches needed for that.

Applied, thanks.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2020-09-02 14:04 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-01 15:57 remove revalidate_disk() Christoph Hellwig
2020-09-01 15:57 ` [PATCH 1/9] Documentation/filesystems/locking.rst: remove an incorrect sentence Christoph Hellwig
2020-09-02  7:22   ` Johannes Thumshirn
2020-09-01 15:57 ` [PATCH 2/9] block: don't clear bd_invalidated in check_disk_size_change Christoph Hellwig
2020-09-01 15:57 ` [PATCH 3/9] block: rename bd_invalidated Christoph Hellwig
2020-09-02  7:23   ` Johannes Thumshirn
2020-09-01 15:57 ` [PATCH 4/9] block: add a new revalidate_disk_size helper Christoph Hellwig
2020-09-02  6:06   ` Song Liu
2020-09-02  7:23   ` Johannes Thumshirn
2020-09-01 15:57 ` [PATCH 5/9] block: use revalidate_disk_size in set_capacity_revalidate_and_notify Christoph Hellwig
2020-09-02  7:23   ` Johannes Thumshirn
2020-09-01 15:57 ` [PATCH 6/9] nvme: opencode revalidate_disk in nvme_validate_ns Christoph Hellwig
2020-09-02  7:23   ` Johannes Thumshirn
2020-09-01 15:57 ` [PATCH 7/9] sd: open code revalidate_disk Christoph Hellwig
2020-09-02  7:24   ` Johannes Thumshirn
2020-09-01 15:57 ` [PATCH 8/9] nvdimm: simplify revalidate_disk handling Christoph Hellwig
2020-09-01 15:57 ` [PATCH 9/9] block: remove revalidate_disk() Christoph Hellwig
2020-09-02  5:59   ` Song Liu
2020-09-02  7:25   ` Johannes Thumshirn
2020-09-01 17:45 ` Josef Bacik
2020-09-02 14:02 ` Jens Axboe

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