Re: [PATCH] btrfs: remove btrfs_writepage_cow_fixup

From: Qu Wenruo
Date: Fri Jun 24 2022 - 09:13:09 EST




On 2022/6/24 20:49, David Sterba wrote:
On Fri, Jun 24, 2022 at 02:23:34PM +0200, Christoph Hellwig wrote:
Since the page_mkwrite address space operation was added, starting with
commit 9637a5efd4fb ("[PATCH] add page_mkwrite() vm_operations method")
in 2006, the kernel does not just dirty random pages without telling
the file system.

It does and there's a history behind the fixup worker. tl;dr it can't be
removed, though every now and then somebody comes and tries to.

On s390 the page status is tracked in two places, hw and in memory and
this needs to be synchronized manually.

On x86_64 it's not a simple reason but it happens as well in some edge
case where the mappings get removed and dirty page is set deep in the
arch mm code. We've been chasing it long time ago, I don't recall exact
details and it's been a painful experience.

If there's been any change on the s390 side or in arch/x86/mm code I
don't know but to be on the safe side, I strongly assume the fixup code
is needed unless proven otherwise.

I'd say, if this can be a problem to btrfs, then all fs supporting COW
should also be affected, and should have similar workaround.


Furthermore, this means we can get a page dirtied without us knowing.

This is a super big surprise to any fs, and should be properly
documented, not just leaving some seemly dead and special code in some
random fs.

Furthermore, I'm not sure even if handling this in a fs level is correct.
This looks like more a MM problem to me then.


I totally understand it's a pain to debug such lowlevel bug, but
shouldn't we have a proper regression for it then?

Instead of just keeping what we know works, I really want to handle this
old case/bug in a more modern way.

Thanks,
Qu