afs: Fix afs_invalidatepage to adjust the dirty region
authorDavid Howells <dhowells@redhat.com>
Thu, 22 Oct 2020 13:08:23 +0000 (14:08 +0100)
committerDavid Howells <dhowells@redhat.com>
Thu, 29 Oct 2020 13:53:04 +0000 (13:53 +0000)
commitf86726a69dec5df6ba051baf9265584419478b64
tree0f4a04caa4a282b0a44b4d63b0fca1126dc33868
parent65dd2d6072d393a3aa14ded8afa9a12f27d9c8ad
afs: Fix afs_invalidatepage to adjust the dirty region

Fix afs_invalidatepage() to adjust the dirty region recorded in
page->private when truncating a page.  If the dirty region is entirely
removed, then the private data is cleared and the page dirty state is
cleared.

Without this, if the page is truncated and then expanded again by truncate,
zeros from the expanded, but no-longer dirty region may get written back to
the server if the page gets laundered due to a conflicting 3rd-party write.

It mustn't, however, shorten the dirty region of the page if that page is
still mmapped and has been marked dirty by afs_page_mkwrite(), so a flag is
stored in page->private to record this.

Fixes: 4343d00872e1 ("afs: Get rid of the afs_writeback record")
Signed-off-by: David Howells <dhowells@redhat.com>
fs/afs/file.c
fs/afs/internal.h
fs/afs/write.c
include/trace/events/afs.h