From: Hugh Dickins <hughd@google.com>
To: hev <r@hev.cc>, Matthew Wilcox <willy@infradead.org>
Cc: Guoqi <chenguoqic@163.com>, Huacai Chen <chenhuacai@loongson.cn>,
Rui Wang <kernel@hev.cc>, Hugh Dickins <hughd@google.com>,
linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: Re: [RFC PATCH] mm/shmem: Fix undo range for failed fallocate
Date: Tue, 22 Nov 2022 20:02:36 -0800 (PST) [thread overview]
Message-ID: <9984f58e-826-74c6-1cd4-65366cc01549@google.com> (raw)
In-Reply-To: <CAHirt9h2CrLhYML3XW=Vj4=BD5eVDoRAbULVGgNbEdYnAzwCzA@mail.gmail.com>
On Thu, 3 Nov 2022, hev wrote:
> On Wed, Nov 2, 2022 at 10:41 PM Matthew Wilcox <willy@infradead.org> wrote:
> > On Tue, Nov 01, 2022 at 11:22:48AM +0800, Rui Wang wrote:
> > > This patch fixes data loss caused by the fallocate system
> > > call interrupted by a signal.
> > >
> > > Bug: https://lore.kernel.org/linux-mm/33b85d82.7764.1842e9ab207.Coremail.chenguoqic@163.com/
> > > Fixes: b9a8a4195c7d ("truncate,shmem: Handle truncates that split large folios")
> >
> > How does that commit introduce this bug?
>
> In the test case[1], we created a file that contains non-zero data
> from offset 0 to A-1. and a process try to expand this file by
> fallocate(fd, 0, 0, B), B > A.
> Concurrently, another process try to interrupt this fallocate syscall
> by a signal. I think the expected results are:
>
> 1. The file is not expanded and file size is A, and the data from
> offset 0 to A-1 is not changed.
> 2. The file is expanded and the data from offset 0 to A-1 is not
> changed, and from A to B-1 contains zeros.
>
> Now, the unexpected result is that the file is not expanded and the
> data that from offset 0 to A-1 is changed by
> truncate_inode_partial_folio that called
> from shmem_undo_range with unfalloc = true.
>
> This issue is only reproduced when file on tmpfs, and begin from this
> commit: b9a8a4195c7d ("truncate,shmem: Handle truncates that split
> large folios")
Like Matthew, I was sceptical at first.
But I currently think that you have discovered something important, and
that your patch is the correct fix to it; but I'm still rather confused,
and want to do some more thinking and testing: this mail is mainly to
signal to Matthew that I'm on it, so he doesn't have to rush to look
at it when he's back.
I was able to reproduce it with the test case, once I multiplied both
of the usleep intervals by 10 - before that, it was too difficult for
it to complete a fallocate: guess the timing is different on my x86 box.
Hugh
next prev parent reply other threads:[~2022-11-23 4:02 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-01 3:22 [RFC PATCH] mm/shmem: Fix undo range for failed fallocate Rui Wang
2022-11-02 14:41 ` Matthew Wilcox
2022-11-03 7:52 ` hev
2022-11-19 14:45 ` hev
2022-11-19 20:20 ` Matthew Wilcox
2022-11-23 4:02 ` Hugh Dickins [this message]
2022-12-05 0:45 ` Hugh Dickins
2022-12-05 0:51 ` [PATCH] tmpfs: fix data loss from " Hugh Dickins
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=9984f58e-826-74c6-1cd4-65366cc01549@google.com \
--to=hughd@google.com \
--cc=chenguoqic@163.com \
--cc=chenhuacai@loongson.cn \
--cc=kernel@hev.cc \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=r@hev.cc \
--cc=willy@infradead.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;
as well as URLs for NNTP newsgroup(s).