Re: [PATCH 03/15] mm: Add file_offset_of_ helpers
From: Matthew Wilcox
Date: Fri Oct 04 2019 - 15:39:14 EST
On Thu, Sep 26, 2019 at 05:02:11PM +0300, Kirill A. Shutemov wrote:
> On Tue, Sep 24, 2019 at 05:52:02PM -0700, Matthew Wilcox wrote:
> > From: "Matthew Wilcox (Oracle)" <willy@xxxxxxxxxxxxx>
> >
> > The page_offset function is badly named for people reading the functions
> > which call it. The natural meaning of a function with this name would
> > be 'offset within a page', not 'page offset in bytes within a file'.
> > Dave Chinner suggests file_offset_of_page() as a replacement function
> > name and I'm also adding file_offset_of_next_page() as a helper for the
> > large page work. Also add kernel-doc for these functions so they show
> > up in the kernel API book.
> >
> > page_offset() is retained as a compatibility define for now.
>
> This should be trivial for coccinelle, right?
Yes, should be. I'd prefer not to do conversions for now to minimise
conflicts when rebasing.
> > +static inline loff_t file_offset_of_next_page(struct page *page)
> > +{
> > + return ((loff_t)page->index + compound_nr(page)) << PAGE_SHIFT;
>
> Wouldn't it be more readable as
>
> return file_offset_of_page(page) + page_size(page);
>
> ?
Good idea. I'll fix that up.