[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20231127062116.2355129-2-yukuai1@huaweicloud.com>
Date: Mon, 27 Nov 2023 14:21:01 +0800
From: Yu Kuai <yukuai1@...weicloud.com>
To: hch@...radead.org, ming.lei@...hat.com, axboe@...nel.dk,
roger.pau@...rix.com, colyli@...e.de, kent.overstreet@...il.com,
joern@...ybastard.org, miquel.raynal@...tlin.com, richard@....at,
vigneshr@...com, sth@...ux.ibm.com, hoeppner@...ux.ibm.com,
hca@...ux.ibm.com, gor@...ux.ibm.com, agordeev@...ux.ibm.com,
jejb@...ux.ibm.com, martin.petersen@...cle.com, clm@...com,
josef@...icpanda.com, dsterba@...e.com, viro@...iv.linux.org.uk,
brauner@...nel.org, nico@...xnic.net, xiang@...nel.org,
chao@...nel.org, tytso@....edu, adilger.kernel@...ger.ca,
agruenba@...hat.com, jack@...e.com, konishi.ryusuke@...il.com,
dchinner@...hat.com, linux@...ssschuh.net, min15.li@...sung.com,
yukuai3@...wei.com, dlemoal@...nel.org, willy@...radead.org,
akpm@...ux-foundation.org, hare@...e.de, p.raghav@...sung.com
Cc: linux-block@...r.kernel.org, linux-kernel@...r.kernel.org,
xen-devel@...ts.xenproject.org, linux-bcache@...r.kernel.org,
linux-mtd@...ts.infradead.org, linux-s390@...r.kernel.org,
linux-scsi@...r.kernel.org, linux-bcachefs@...r.kernel.org,
linux-btrfs@...r.kernel.org, linux-fsdevel@...r.kernel.org,
linux-erofs@...ts.ozlabs.org, linux-ext4@...r.kernel.org,
gfs2@...ts.linux.dev, linux-nilfs@...r.kernel.org,
yukuai1@...weicloud.com, yi.zhang@...wei.com, yangerkun@...wei.com
Subject: [PATCH block/for-next v2 01/16] block: add a new helper to get inode from block_device
From: Yu Kuai <yukuai3@...wei.com>
block_devcie is allocated from bdev_alloc() by bdev_alloc_inode(), and
currently block_device contains a pointer that point to the address of
inode, while such inode is allocated together:
bdev_alloc
inode = new_inode()
// inode is &bdev_inode->vfs_inode
bdev = I_BDEV(inode)
// bdev is &bdev_inode->bdev
bdev->inode = inode
Add a new helper to get address of inode from bdev by add operation
instead of memory access, which is more efficiency.
Signed-off-by: Yu Kuai <yukuai3@...wei.com>
---
block/bdev.c | 5 -----
include/linux/blk_types.h | 12 ++++++++++++
2 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/block/bdev.c b/block/bdev.c
index e4cfb7adb645..7509389095b7 100644
--- a/block/bdev.c
+++ b/block/bdev.c
@@ -30,11 +30,6 @@
#include "../fs/internal.h"
#include "blk.h"
-struct bdev_inode {
- struct block_device bdev;
- struct inode vfs_inode;
-};
-
static inline struct bdev_inode *BDEV_I(struct inode *inode)
{
return container_of(inode, struct bdev_inode, vfs_inode);
diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h
index d5c5e59ddbd2..06de8393dcd1 100644
--- a/include/linux/blk_types.h
+++ b/include/linux/blk_types.h
@@ -85,6 +85,18 @@ struct block_device {
#define bdev_kobj(_bdev) \
(&((_bdev)->bd_device.kobj))
+struct bdev_inode {
+ struct block_device bdev;
+ struct inode vfs_inode;
+};
+
+static inline struct inode *bdev_inode(struct block_device *bdev)
+{
+ struct bdev_inode *bi = container_of(bdev, struct bdev_inode, bdev);
+
+ return &bi->vfs_inode;
+}
+
/*
* Block error status values. See block/blk-core:blk_errors for the details.
* Alpha cannot write a byte atomically, so we need to use 32-bit value.
--
2.39.2
Powered by blists - more mailing lists