gfs2.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Yu Kuai <yukuai1@huaweicloud.com>
To: Greg KH <gregkh@linuxfoundation.org>, Yu Kuai <yukuai1@huaweicloud.com>
Cc: hch@infradead.org, ming.lei@redhat.com, axboe@kernel.dk,
	roger.pau@citrix.com, colyli@suse.de, kent.overstreet@gmail.com,
	joern@lazybastard.org, miquel.raynal@bootlin.com, richard@nod.at,
	vigneshr@ti.com, sth@linux.ibm.com, hoeppner@linux.ibm.com,
	hca@linux.ibm.com, gor@linux.ibm.com, agordeev@linux.ibm.com,
	jejb@linux.ibm.com, martin.petersen@oracle.com, clm@fb.com,
	josef@toxicpanda.com, dsterba@suse.com, viro@zeniv.linux.org.uk,
	brauner@kernel.org, nico@fluxnic.net, xiang@kernel.org,
	chao@kernel.org, tytso@mit.edu, adilger.kernel@dilger.ca,
	agruenba@redhat.com, jack@suse.com, konishi.ryusuke@gmail.com,
	dchinner@redhat.com, linux@weissschuh.net, min15.li@samsung.com,
	dlemoal@kernel.org, willy@infradead.org,
	akpm@linux-foundation.org, p.raghav@samsung.com, hare@suse.de,
	linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
	xen-devel@lists.xenproject.org, linux-bcache@vger.kernel.org,
	linux-mtd@lists.infradead.org, linux-s390@vger.kernel.org,
	linux-scsi@vger.kernel.org, linux-bcachefs@vger.kernel.org,
	linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	linux-erofs@lists.ozlabs.org, linux-ext4@vger.kernel.org,
	gfs2@lists.linux.dev, linux-nilfs@vger.kernel.org,
	yi.zhang@huawei.com, yangerkun@huawei.com,
	"yukuai (C)" <yukuai3@huawei.com>
Subject: Re: [PATCH -next] block: remove field 'bd_inode' from block_device
Date: Mon, 27 Nov 2023 09:13:39 +0800	[thread overview]
Message-ID: <6ef798a6-8c0c-16b0-9991-b461258eb7d4@huaweicloud.com> (raw)
In-Reply-To: <2023112544-subpanel-national-58e5@gregkh>

Hi,

在 2023/11/25 22:32, Greg KH 写道:
> On Sat, Nov 25, 2023 at 05:39:12PM +0800, Yu Kuai wrote:
>> From: Yu Kuai <yukuai3@huawei.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. Also prepare to
>> add a new field 'bd_flags' in the first cacheline(64 bytes).
>>
>> Signed-off-by: Yu Kuai <yukuai3@huawei.com>
>> ---
>>   block/bdev.c                       | 39 +++++++++++++++++-------------
>>   block/blk-zoned.c                  |  4 +--
>>   block/fops.c                       |  4 +--
>>   block/genhd.c                      |  8 +++---
>>   block/ioctl.c                      |  8 +++---
>>   block/partitions/core.c            |  9 ++++---
>>   drivers/block/xen-blkback/xenbus.c |  2 +-
>>   drivers/md/bcache/super.c          |  2 +-
>>   drivers/mtd/devices/block2mtd.c    | 12 ++++-----
>>   drivers/s390/block/dasd_ioctl.c    |  2 +-
>>   drivers/scsi/scsicam.c             |  2 +-
>>   fs/bcachefs/util.h                 |  2 +-
>>   fs/btrfs/disk-io.c                 |  6 ++---
>>   fs/btrfs/volumes.c                 |  4 +--
>>   fs/btrfs/zoned.c                   |  2 +-
>>   fs/buffer.c                        |  8 +++---
>>   fs/cramfs/inode.c                  |  2 +-
>>   fs/erofs/data.c                    |  2 +-
>>   fs/ext4/dir.c                      |  2 +-
>>   fs/ext4/ext4_jbd2.c                |  2 +-
>>   fs/ext4/super.c                    |  8 +++---
>>   fs/gfs2/glock.c                    |  2 +-
>>   fs/gfs2/ops_fstype.c               |  2 +-
>>   fs/jbd2/journal.c                  |  3 ++-
>>   fs/jbd2/recovery.c                 |  2 +-
>>   fs/nilfs2/segment.c                |  2 +-
>>   include/linux/blk_types.h          | 10 ++++++--
>>   include/linux/blkdev.h             |  4 +--
>>   include/linux/buffer_head.h        |  4 +--
>>   29 files changed, 86 insertions(+), 73 deletions(-)
> 
> You should do this as a patch series, add the helper function that does
> nothing, convert all the different portions of the kernel as different
> patches, and _then_ change the implementation of the block layer to
> handle the change in the structure.
> 
> Otherwise this is going to be hard to get accepted.

Okay, thanks for the adivce, I'll do that in v2.

By the way, I was thinking that this patch is quite simple, and doesn't
worth spliting into 10+ patches,
> 
> Also, one note:
> 
>> @@ -85,6 +84,13 @@ struct block_device {
>>   #define bdev_kobj(_bdev) \
>>   	(&((_bdev)->bd_device.kobj))
>>   
>> +static inline struct inode *bdev_inode(struct block_device *bdev)
>> +{
>> +	void *inode = bdev + 1;
> 
> That's crazy, if something changes, this will keep working yet the
> kernel will break and no one will know why.
> 
> Please use container_of(), that's what it is there for, this exact type
> of thing.  Or if not, are you just assuming that the memory location
> right after bdev is the inode?  That's a tough assumption, how are you
> going to assure it really stays there?

Struct bdev_inode never changes since commit 8fbd544cbca5 ("[PATCH]
bdev: add I_BDEV()") from 2004, and I think it won't change unless
there is a different way to manage lifetime of block_device.

And the 'bdev + 1' is copied from blk_mq_rq_to_pdu(), however, I aggre
that use container_of() is better and I will use it in v2.

Thanks,
Kuai

> 
> thanks,
> 
> greg k-h
> .
> 


      reply	other threads:[~2023-11-27  1:13 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-25  9:39 [PATCH -next] block: remove field 'bd_inode' from block_device Yu Kuai
2023-11-25 14:32 ` Greg KH
2023-11-27  1:13   ` Yu Kuai [this message]

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=6ef798a6-8c0c-16b0-9991-b461258eb7d4@huaweicloud.com \
    --to=yukuai1@huaweicloud.com \
    --cc=adilger.kernel@dilger.ca \
    --cc=agordeev@linux.ibm.com \
    --cc=agruenba@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=axboe@kernel.dk \
    --cc=brauner@kernel.org \
    --cc=chao@kernel.org \
    --cc=clm@fb.com \
    --cc=colyli@suse.de \
    --cc=dchinner@redhat.com \
    --cc=dlemoal@kernel.org \
    --cc=dsterba@suse.com \
    --cc=gfs2@lists.linux.dev \
    --cc=gor@linux.ibm.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hare@suse.de \
    --cc=hca@linux.ibm.com \
    --cc=hch@infradead.org \
    --cc=hoeppner@linux.ibm.com \
    --cc=jack@suse.com \
    --cc=jejb@linux.ibm.com \
    --cc=joern@lazybastard.org \
    --cc=josef@toxicpanda.com \
    --cc=kent.overstreet@gmail.com \
    --cc=konishi.ryusuke@gmail.com \
    --cc=linux-bcache@vger.kernel.org \
    --cc=linux-bcachefs@vger.kernel.org \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-erofs@lists.ozlabs.org \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=linux-nilfs@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=linux@weissschuh.net \
    --cc=martin.petersen@oracle.com \
    --cc=min15.li@samsung.com \
    --cc=ming.lei@redhat.com \
    --cc=miquel.raynal@bootlin.com \
    --cc=nico@fluxnic.net \
    --cc=p.raghav@samsung.com \
    --cc=richard@nod.at \
    --cc=roger.pau@citrix.com \
    --cc=sth@linux.ibm.com \
    --cc=tytso@mit.edu \
    --cc=vigneshr@ti.com \
    --cc=viro@zeniv.linux.org.uk \
    --cc=willy@infradead.org \
    --cc=xen-devel@lists.xenproject.org \
    --cc=xiang@kernel.org \
    --cc=yangerkun@huawei.com \
    --cc=yi.zhang@huawei.com \
    --cc=yukuai3@huawei.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).