[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <d195aba8-7b89-698f-b7a0-06b87ae01c21@huaweicloud.com>
Date: Thu, 7 Dec 2023 10:45:13 +0800
From: Yu Kuai <yukuai1@...weicloud.com>
To: Matthew Wilcox <willy@...radead.org>,
Yu Kuai <yukuai1@...weicloud.com>
Cc: 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, 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,
akpm@...ux-foundation.org, hare@...e.de, p.raghav@...sung.com,
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-erofs@...ts.ozlabs.org,
linux-ext4@...r.kernel.org, gfs2@...ts.linux.dev,
linux-nilfs@...r.kernel.org, yi.zhang@...wei.com,
yangerkun@...wei.com, "yukuai (C)" <yukuai3@...wei.com>
Subject: Re: [PATCH -next RFC 01/14] block: add some bdev apis
Hi,
在 2023/12/06 22:58, Matthew Wilcox 写道:
> On Tue, Dec 05, 2023 at 08:37:15PM +0800, Yu Kuai wrote:
>> +struct folio *bdev_read_folio(struct block_device *bdev, pgoff_t index)
>> +{
>> + return read_mapping_folio(bdev->bd_inode->i_mapping, index, NULL);
>> +}
>> +EXPORT_SYMBOL_GPL(bdev_read_folio);
>
> I'm coming to the opinion that 'index' is the wrong parameter here.
> Looking through all the callers of bdev_read_folio() in this patchset,
> they all have a position in bytes, and they all convert it to
> index for this call. The API should probably be:
>
> struct folio *bdev_read_folio(struct block_device *bdev, loff_t pos)
> {
> return read_mapping_folio(bdev->bd_inode->i_mapping,
> pos / PAGE_SIZE, NULL);
> }
Thanks for reviewing this patchset! Okay, I'll convert to pass in "pos"
in v2.
>
> ... and at some point, we'll get round to converting read_mapping_folio()
> to take its argument in loff_t.
>
> Similiarly for these two APIs:
>
>> +struct folio *bdev_read_folio_gfp(struct block_device *bdev, pgoff_t index,
>> + gfp_t gfp)
>> +struct folio *bdev_get_folio(struct block_device *bdev, pgoff_t index)
>
>> +struct folio *bdev_find_or_create_folio(struct block_device *bdev,
>> + pgoff_t index, gfp_t gfp)
>> +{
>> + return __filemap_get_folio(bdev->bd_inode->i_mapping, index,
>> + FGP_LOCK | FGP_ACCESSED | FGP_CREAT, gfp);
>> +}
>> +EXPORT_SYMBOL_GPL(bdev_find_or_create_folio);
>
> This one probably shouldn't exist. I've been converting callers of
> find_or_create_page() to call __filemap_get_folio; I suspect we
> should expose a __bdev_get_folio and have the callers use the FGP
> arguments directly, but I'm open to other opinions here.
If nobody against this, I will expose single __bdev_get_folio() to use
in v2.
>
>> +void bdev_sync_readahead(struct block_device *bdev, struct file_ra_state *ra,
>> + struct file *file, pgoff_t index,
>> + unsigned long req_count)
>> +{
>> + struct file_ra_state tmp_ra = {};
>> +
>> + if (!ra) {
>> + ra = &tmp_ra;
>> + file_ra_state_init(ra, bdev->bd_inode->i_mapping);
>> + }
>> + page_cache_sync_readahead(bdev->bd_inode->i_mapping, ra, file, index,
>> + req_count);
>> +}
>
> I think the caller should always be passing in a valid file_ra_state.
> It's only cramfs that doesn't have one, and it really should!
> Not entirely sure about the arguments here; part of me says "bytes",
> but this is weird enough to maybe take arguments in pages.
In fact, bdev_sync_readahead() is only called for cramfs and ext4.
For ext4 it's used in ext4_readdir() so there is valid file_ra_state.
Hoever, for cramfs it's used in cramfs_read(), and cramfs_read() is used
for:
1) cramfs_read_folio
2) cramfs_readdir
3) cramfs_lookup
4) cramfs_read_super
Looks like it's easy to pass in valid file_ra_state() for 1) and 2),
however, I don't see an easy way to do this for 3) and 4).
Thanks,
Kuai
>
> .
>
Powered by blists - more mailing lists