Linux-Block Archive on lore.kernel.org
 help / color / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: axboe@kernel.dk
Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 7/7] block: remove the all_bdevs list
Date: Fri, 26 Jun 2020 10:01:58 +0200
Message-ID: <20200626080158.1998621-8-hch@lst.de> (raw)
In-Reply-To: <20200626080158.1998621-1-hch@lst.de>

Instead just iterate over the inodes for the block device superblock.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/block_dev.c            | 22 +++++++---------------
 include/linux/blk_types.h |  1 -
 2 files changed, 7 insertions(+), 16 deletions(-)

diff --git a/fs/block_dev.c b/fs/block_dev.c
index 68cb08bc1b7a65..2d2fcb50e78eac 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -773,7 +773,6 @@ static void init_once(void *foo)
 
 	memset(bdev, 0, sizeof(*bdev));
 	mutex_init(&bdev->bd_mutex);
-	INIT_LIST_HEAD(&bdev->bd_list);
 #ifdef CONFIG_SYSFS
 	INIT_LIST_HEAD(&bdev->bd_holder_disks);
 #endif
@@ -789,9 +788,6 @@ static void bdev_evict_inode(struct inode *inode)
 	truncate_inode_pages_final(&inode->i_data);
 	invalidate_inode_buffers(inode); /* is it needed here? */
 	clear_inode(inode);
-	spin_lock(&bdev_lock);
-	list_del_init(&bdev->bd_list);
-	spin_unlock(&bdev_lock);
 	/* Detach inode from wb early as bdi_put() may free bdi->wb */
 	inode_detach_wb(inode);
 	if (bdev->bd_bdi != &noop_backing_dev_info) {
@@ -866,8 +862,6 @@ static int bdev_set(struct inode *inode, void *data)
 	return 0;
 }
 
-static LIST_HEAD(all_bdevs);
-
 struct block_device *bdget(dev_t dev)
 {
 	struct block_device *bdev;
@@ -892,9 +886,6 @@ struct block_device *bdget(dev_t dev)
 		inode->i_bdev = bdev;
 		inode->i_data.a_ops = &def_blk_aops;
 		mapping_set_gfp_mask(&inode->i_data, GFP_USER);
-		spin_lock(&bdev_lock);
-		list_add(&bdev->bd_list, &all_bdevs);
-		spin_unlock(&bdev_lock);
 		unlock_new_inode(inode);
 	}
 	return bdev;
@@ -915,13 +906,14 @@ EXPORT_SYMBOL(bdgrab);
 
 long nr_blockdev_pages(void)
 {
-	struct block_device *bdev;
+	struct inode *inode;
 	long ret = 0;
-	spin_lock(&bdev_lock);
-	list_for_each_entry(bdev, &all_bdevs, bd_list) {
-		ret += bdev->bd_inode->i_mapping->nrpages;
-	}
-	spin_unlock(&bdev_lock);
+
+	spin_lock(&blockdev_superblock->s_inode_list_lock);
+	list_for_each_entry(inode, &blockdev_superblock->s_inodes, i_sb_list)
+		ret += inode->i_mapping->nrpages;
+	spin_unlock(&blockdev_superblock->s_inode_list_lock);
+
 	return ret;
 }
 
diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h
index b5f7105806e492..07facaf62b727d 100644
--- a/include/linux/blk_types.h
+++ b/include/linux/blk_types.h
@@ -40,7 +40,6 @@ struct block_device {
 	int			bd_invalidated;
 	struct gendisk *	bd_disk;
 	struct backing_dev_info *bd_bdi;
-	struct list_head	bd_list;
 
 	/* The counter of freeze processes */
 	int			bd_fsfreeze_count;
-- 
2.26.2


  parent reply index

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-26  8:01 remove not needed fields from struct block_device Christoph Hellwig
2020-06-26  8:01 ` [PATCH 1/7] floppy: use block_size Christoph Hellwig
2020-06-26 15:48   ` Johannes Thumshirn
2020-06-26 15:50     ` Johannes Thumshirn
2020-06-26  8:01 ` [PATCH 2/7] dcssblk: don't set bd_block_size in ->open Christoph Hellwig
2020-06-26 15:54   ` Johannes Thumshirn
2020-06-26  8:01 ` [PATCH 3/7] block: simplify set_init_blocksize Christoph Hellwig
2020-06-26  8:01 ` [PATCH 4/7] block: remove the bd_block_size field from struct block_device Christoph Hellwig
2020-07-01  7:29   ` Johannes Thumshirn
2020-06-26  8:01 ` [PATCH 5/7] block: remove the bd_queue " Christoph Hellwig
2020-07-01  7:30   ` Johannes Thumshirn
2020-06-26  8:01 ` [PATCH 6/7] block: remove the unused bd_private " Christoph Hellwig
2020-07-01  7:31   ` Johannes Thumshirn
2020-06-26  8:01 ` Christoph Hellwig [this message]
2020-07-01  7:33   ` [PATCH 7/7] block: remove the all_bdevs list Johannes Thumshirn
2020-07-01  7:11 ` remove not needed fields from struct block_device Christoph Hellwig
2020-07-01 15:03 ` 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=20200626080158.1998621-8-hch@lst.de \
    --to=hch@lst.de \
    --cc=axboe@kernel.dk \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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

Linux-Block Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-block/0 linux-block/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-block linux-block/ https://lore.kernel.org/linux-block \
		linux-block@vger.kernel.org
	public-inbox-index linux-block

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-block


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git