public inbox for linux-s390@vger.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Jens Axboe <axboe@kernel.dk>
Cc: Stefan Haberland <sth@linux.ibm.com>,
	Jan Hoeppner <hoeppner@linux.ibm.com>,
	linux-block@vger.kernel.org, linux-s390@vger.kernel.org,
	Johannes Thumshirn <johannes.thumshirn@wdc.com>
Subject: [PATCH 10/10] block: fold bdev_unhash_inode into invalidate_partition
Date: Tue, 14 Apr 2020 09:29:02 +0200	[thread overview]
Message-ID: <20200414072902.324936-11-hch@lst.de> (raw)
In-Reply-To: <20200414072902.324936-1-hch@lst.de>

invalidate_partition and bdev_unhash_inode are always paired, and
invalidate_partition already does an icache lookup for the block device
inode.  Piggy back on that to remove the inode from the hash.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
 block/genhd.c      |  8 ++++++--
 fs/block_dev.c     | 15 ---------------
 include/linux/fs.h |  1 -
 3 files changed, 6 insertions(+), 18 deletions(-)

diff --git a/block/genhd.c b/block/genhd.c
index 980a4609d4a5..c05d509877fa 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -888,6 +888,12 @@ static void invalidate_partition(struct gendisk *disk, int partno)
 
 	fsync_bdev(bdev);
 	__invalidate_device(bdev, true);
+
+	/*
+	 * Unhash the bdev inode for this device so that it gets evicted as soon
+	 * as last inode reference is dropped.
+	 */
+	remove_inode_hash(bdev->bd_inode);
 	bdput(bdev);
 }
 
@@ -909,13 +915,11 @@ void del_gendisk(struct gendisk *disk)
 			     DISK_PITER_INCL_EMPTY | DISK_PITER_REVERSE);
 	while ((part = disk_part_iter_next(&piter))) {
 		invalidate_partition(disk, part->partno);
-		bdev_unhash_inode(part_devt(part));
 		delete_partition(disk, part);
 	}
 	disk_part_iter_exit(&piter);
 
 	invalidate_partition(disk, 0);
-	bdev_unhash_inode(disk_devt(disk));
 	set_capacity(disk, 0);
 	disk->flags &= ~GENHD_FL_UP;
 	up_write(&disk->lookup_sem);
diff --git a/fs/block_dev.c b/fs/block_dev.c
index 9c8de54fa0c9..998820174d3e 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -883,21 +883,6 @@ static int bdev_set(struct inode *inode, void *data)
 
 static LIST_HEAD(all_bdevs);
 
-/*
- * If there is a bdev inode for this device, unhash it so that it gets evicted
- * as soon as last inode reference is dropped.
- */
-void bdev_unhash_inode(dev_t dev)
-{
-	struct inode *inode;
-
-	inode = ilookup5(blockdev_superblock, hash(dev), bdev_test, &dev);
-	if (inode) {
-		remove_inode_hash(inode);
-		iput(inode);
-	}
-}
-
 struct block_device *bdget(dev_t dev)
 {
 	struct block_device *bdev;
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 2b4e9f86b151..1a95e5158811 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2581,7 +2581,6 @@ extern struct kmem_cache *names_cachep;
 #ifdef CONFIG_BLOCK
 extern int register_blkdev(unsigned int, const char *);
 extern void unregister_blkdev(unsigned int, const char *);
-extern void bdev_unhash_inode(dev_t dev);
 extern struct block_device *bdget(dev_t);
 extern struct block_device *bdgrab(struct block_device *bdev);
 extern void bd_set_size(struct block_device *, loff_t size);
-- 
2.25.1

  parent reply	other threads:[~2020-04-14  7:29 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-14  7:28 more partition handling cleanups v2 Christoph Hellwig
2020-04-14  7:28 ` [PATCH 01/10] block: refactor blkpg_ioctl Christoph Hellwig
2020-04-14  8:09   ` Johannes Thumshirn
2020-04-14  7:28 ` [PATCH 02/10] block: pass a hd_struct to delete_partition Christoph Hellwig
2020-04-14  7:28 ` [PATCH 03/10] block: cleanup hd_struct freeing Christoph Hellwig
2020-04-14  7:28 ` [PATCH 04/10] block: remove hd_struct_kill Christoph Hellwig
2020-04-14  7:28 ` [PATCH 05/10] block: remove the disk argument from blk_drop_partitions Christoph Hellwig
2020-04-14  7:28 ` [PATCH 06/10] dasd: use blk_drop_partitions instead of badly reimplementing it Christoph Hellwig
2020-04-14  7:28 ` [PATCH 07/10] block: don't call invalidate_partition from blk_drop_partitions Christoph Hellwig
2020-04-14  8:12   ` Johannes Thumshirn
2020-04-14  7:29 ` [PATCH 08/10] block: simplify block device syncing in bdev_del_partition Christoph Hellwig
2020-04-14  7:29 ` [PATCH 09/10] block: mark invalidate_partition static Christoph Hellwig
2020-04-14  7:29 ` Christoph Hellwig [this message]
2020-04-20 17:26 ` more partition handling cleanups v2 Christoph Hellwig
2020-04-20 17:35 ` Jens Axboe
  -- strict thread matches above, loose matches on Subject: below --
2020-04-08 19:44 Christoph Hellwig
2020-04-08 19:44 ` [PATCH 10/10] block: fold bdev_unhash_inode into invalidate_partition Christoph Hellwig
2020-04-09 12:06   ` Johannes Thumshirn

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=20200414072902.324936-11-hch@lst.de \
    --to=hch@lst.de \
    --cc=axboe@kernel.dk \
    --cc=hoeppner@linux.ibm.com \
    --cc=johannes.thumshirn@wdc.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --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