On Tue, Dec 17, 2019 at 05:31:14PM +0800, Anand Jain wrote:
> > - if (page->index == end_index) {
> > - char *userpage;
> > - size_t zero_offset = offset_in_page(isize);
> > -
> > - if (zero_offset) {
> > - int zeros;
> > - zeros = PAGE_SIZE - zero_offset;
> > - userpage = kmap_atomic(page);
> > - memset(userpage + zero_offset, 0, zeros);
> > - flush_dcache_page(page);
> > - kunmap_atomic(userpage);
> > - }
> > - }
> > + if (page->index == end_index)
> > + zero_user_segment(page, offset_in_page(isize), PAGE_SIZE);
>
> Before we zero-ed only when the page offset is not starting at 0.
> Can you confirm and update the change log if that is ok.
If the page offset is 0 then this would mean the whole page will be
zeroed, but we can have entire page within i_size so that would
mistakenly clear the last page. So the check is still needed.
While reading the code around the index calculations for the last page I
also found some oddities and potential bugs so I'll drop this patch for
now so I can look at the bugs first.