Re: [PATCH 2/9] fs: Introduce i_blocks_per_page

From: Dave Chinner
Date: Tue Aug 25 2020 - 18:21:17 EST


On Tue, Aug 25, 2020 at 01:49:22PM -0700, Darrick J. Wong wrote:
> On Mon, Aug 24, 2020 at 03:55:03PM +0100, Matthew Wilcox (Oracle) wrote:
> > This helper is useful for both THPs and for supporting block size larger
> > than page size. Convert all users that I could find (we have a few
> > different ways of writing this idiom, and I may have missed some).
> >
> > Signed-off-by: Matthew Wilcox (Oracle) <willy@xxxxxxxxxxxxx>
> > Reviewed-by: Christoph Hellwig <hch@xxxxxx>
>
> /me wonders what will happen when someone tries to make blocksz >
> pagesize work,

I abstract the page/block size stuff into "chunks". i.e. we work on
the smallest contiguous chunk of data the current combination of
page and inode define. In the context of this patch, it is simply
just:

s/i_blocks_per_page/iomap_chunks_per_page/g

i.e. The helper functions end up looking like this:

static inline unsigned
iomap_chunk_size(struct inode *inode, struct page *page)
{
return min_t(unsigned, page_size(page), i_blocksize(inode));
}

static inline unsigned
iomap_chunk_bits(struct inode *inode, struct page *page)
{
return min_t(unsigned, page_shift(page), inode->i_blkbits);
}

static inline unsigned
iomap_chunks_per_page(struct inode *inode, struct page *page)
{
return page_size(page) >> inode->i_blkbits;
}

and the latter is actually the same as what i_block_per_page() is
currently implemented as....

Cheers,

Dave.
--
Dave Chinner
david@xxxxxxxxxxxxx