Re: [PATCH v1] mm/truncate: fix the zeroing end of pagecache_isize_extended()

From: Nickolai Zeldovich

Date: Fri Oct 23 2026 - 23:30:48 EST


On Tue, Oct 20, 2026 at 6:51 AM Brian Foster <bfoster@xxxxxxxxxx> wrote:
> On Mon, Oct 19, 2026 at 03:54:14PM -0400, Nickolai Zeldovich wrote:
> > On Mon, Oct 19, 2026 at 3:35 PM Brian Foster <bfoster@xxxxxxxxxx> wrote:
> > > > --- a/mm/truncate.c
> > > > +++ b/mm/truncate.c
> > > > @@ -878,8 +878,7 @@ void pagecache_isize_extended(struct inode *inode, loff_t from, loff_t to)
> > > > unsigned int offset, end;
> > > >
> > > > offset = from - folio_pos(folio);
> > > > - end = min_t(unsigned int, to - folio_pos(folio),
> > > > - folio_size(folio));
> > > > + end = min_t(loff_t, to - folio_pos(folio), folio_size(folio));
> > >
> > > Good catch...
> > >
> > > folio_size() returns size_t and folio_zero_segment() expects size_t for
> > > the offset params. Perhaps we should that instead of loff_t?
> >
> > size_t is (unsigned int) on 32-bit machines, like i386, which has the
> > same issue (reproducer from the patch).
> >
>
> Ah, Ok. So loff_t makes sense for the min_t(). I do still wonder if it
> makes sense to switch offset and end to size_t while we're here though.

I believe they're always pretty small (bounded by folio_size, which is
bounded by 2^MAX_PAGECACHE_ORDER), so size_t isn't going to make a
difference here.

Nickolai.