Re: [PATCH 2/2] xfs: don't update mtime on COW faults
From: Linus Torvalds
Date: Sat Sep 05 2020 - 12:55:53 EST
On Sat, Sep 5, 2020 at 5:13 AM Mikulas Patocka <mpatocka@xxxxxxxxxx> wrote:
>
> When running in a dax mode, if the user maps a page with MAP_PRIVATE and
> PROT_WRITE, the xfs filesystem would incorrectly update ctime and mtime
> when the user hits a COW fault.
So your patch is obviously correct, but at the same time I look at
the (buggy) ext2/xfs code you fixed, and I go "well, that was a really
natural mistake to make".
So I get the feeling that "yes, this was an ext2 and xfs bug, but we
kind of set those filesystems up to fail".
Could this possibly have been avoided by having nicer interfaces?
Grepping around, and doing a bit of "git blame", I note that ext4 used
to have this exact same bug too, but it was fixed three years ago in
commit fd96b8da68d3 ("ext4: fix fault handling when mounted with -o
dax,ro") and nobody at the time clearly realized it might be a
pattern.
And honestly, it's possible that the pattern came from cut-and-paste
errors, but it's equally likely that the pattern was there simply
because it was such a natural pattern and such an easy and natural
mistake to make.
Maybe it's inevitable. Some people do want (and need) the information
whether it was a write just because they care about the page table
issues (ie marking the pte dirty etc). To that kind of situation,
whether it's shared or not might not matter all that much. But to a
filesystem, a private write vs a shared write are quite different
things.
So I don't really have any suggestions, and maybe it's just what it
is, but maybe somebody has an idea for how to make it slightly less
natural to make this mistake..
But maybe just a test-case is all it takes, like Darrick suggests.
Linus