> + partial_end = ((lend + 1) % PAGE_SIZE) > 0; The > 0 reads a little odd as we can never get a negative value here. > + shmem_get_folio(inode, lstart >> PAGE_SHIFT, &folio, SGP_READ); > + if (folio) { > + bool same_page; > + > + same_page = lend < folio_pos(folio) + folio_size(folio); > + if (same_page) > + partial_end = false; > + folio_mark_dirty(folio); > + if (!truncate_inode_partial_folio(folio, lstart, lend)) { > + start = folio->index + folio_nr_pages(folio); > + if (same_page) > + end = folio->index; > } > + folio_unlock(folio); > + folio_put(folio); > + folio = NULL; The entire logic after the shmem_get_folio call is duplicated in truncate_inode_pages_range. Shouldn't we ty to combine that by moving it into a helper? If we can't merge it I think same_page shoud be renamed to same_folio as in truncate_inode_pages_range. > pgoff_t start; /* inclusive */ > pgoff_t end; /* exclusive */ > - unsigned int partial_start; /* inclusive */ > - unsigned int partial_end; /* exclusive */ > struct folio_batch fbatch; > pgoff_t indices[PAGEVEC_SIZE]; > pgoff_t index; > int i; > + struct folio * folio; Weird indentation after the star. > + bool partial_end; And the style here in general does not seem to match the existing code.