linux-block.vger.kernel.org archive mirror
 help / color / mirror / 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 4/7] block: remove the bd_block_size field from struct block_device
Date: Fri, 26 Jun 2020 10:01:55 +0200	[thread overview]
Message-ID: <20200626080158.1998621-5-hch@lst.de> (raw)
In-Reply-To: <20200626080158.1998621-1-hch@lst.de>

We can trivially calculate the block size from the inodes i_blkbits
variable.  Use that instead of keeping two redundant copies of the
information in slightly different formats.

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

diff --git a/fs/block_dev.c b/fs/block_dev.c
index 8b7a9c76d33edf..06d31e459048ad 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -105,10 +105,7 @@ EXPORT_SYMBOL(invalidate_bdev);
 
 static void set_init_blocksize(struct block_device *bdev)
 {
-	unsigned bsize = bdev_logical_block_size(bdev);
-
-	bdev->bd_block_size = bsize;
-	bdev->bd_inode->i_blkbits = blksize_bits(bsize);
+	bdev->bd_inode->i_blkbits = blksize_bits(bdev_logical_block_size(bdev));
 }
 
 int set_blocksize(struct block_device *bdev, int size)
@@ -122,9 +119,8 @@ int set_blocksize(struct block_device *bdev, int size)
 		return -EINVAL;
 
 	/* Don't change the size if it is same as current */
-	if (bdev->bd_block_size != size) {
+	if (bdev->bd_inode->i_blkbits != blksize_bits(size)) {
 		sync_blockdev(bdev);
-		bdev->bd_block_size = size;
 		bdev->bd_inode->i_blkbits = blksize_bits(size);
 		kill_bdev(bdev);
 	}
@@ -889,7 +885,6 @@ struct block_device *bdget(dev_t dev)
 		bdev->bd_contains = NULL;
 		bdev->bd_super = NULL;
 		bdev->bd_inode = inode;
-		bdev->bd_block_size = i_blocksize(inode);
 		bdev->bd_part_count = 0;
 		bdev->bd_invalidated = 0;
 		inode->i_mode = S_IFBLK;
diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h
index a602132cbe32c2..b01cd19bbe8a6e 100644
--- a/include/linux/blk_types.h
+++ b/include/linux/blk_types.h
@@ -33,7 +33,6 @@ struct block_device {
 	struct list_head	bd_holder_disks;
 #endif
 	struct block_device *	bd_contains;
-	unsigned		bd_block_size;
 	u8			bd_partno;
 	struct hd_struct *	bd_part;
 	/* number of times partitions within this device have been opened. */
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 15497782c17656..752a4b771e2f2f 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -1548,7 +1548,7 @@ static inline unsigned int blksize_bits(unsigned int size)
 
 static inline unsigned int block_size(struct block_device *bdev)
 {
-	return bdev->bd_block_size;
+	return 1 << bdev->bd_inode->i_blkbits;
 }
 
 int kblockd_schedule_work(struct work_struct *work);
-- 
2.26.2


  parent reply	other threads:[~2020-06-26  8:02 UTC|newest]

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 ` Christoph Hellwig [this message]
2020-07-01  7:29   ` [PATCH 4/7] block: remove the bd_block_size field from struct block_device 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 ` [PATCH 7/7] block: remove the all_bdevs list Christoph Hellwig
2020-07-01  7:33   ` 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-5-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
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).