From: David Sterba <dsterba@suse.cz>
To: Anand Jain <anand.jain@oracle.com>
Cc: David Sterba <dsterba@suse.com>, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH] btrfs: use helper to zero end of last page
Date: Tue, 17 Dec 2019 18:49:32 +0100 [thread overview]
Message-ID: <20191217174932.GI3929@twin.jikos.cz> (raw)
In-Reply-To: <4ca3c941-c3c0-2128-e206-01a9eb96953e@oracle.com>
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.
prev parent reply other threads:[~2019-12-17 17:49 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-16 18:50 [PATCH] btrfs: use helper to zero end of last page David Sterba
2019-12-17 9:31 ` Anand Jain
2019-12-17 17:49 ` David Sterba [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191217174932.GI3929@twin.jikos.cz \
--to=dsterba@suse.cz \
--cc=anand.jain@oracle.com \
--cc=dsterba@suse.com \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox