On Mon, Jun 12, 2023 at 07:33:29PM +0530, Ritesh Harjani wrote: > >> + *punch_start_byte = min_t(loff_t, end_byte, > >> + folio_next_index(folio) << PAGE_SHIFT); > > > > *punch_start_byte = min(end_byte, folio_pos(folio) + folio_size(folio)); > > Current code was also correct only. But I guess this just avoids > min_t/loff_t thing. No other reason right? Actually, it's buggy on 32-bit platforms. folio_next_index returns an unsigned long (32 bit), which is shifted by PAGE_SHIFT, losing the top bits, then cast to an loff_t. folio_pos() does this correctly.