afs: Fixes
Hi Linus,
Can you pull these fixes for the AFS filesystem? They include:
(1) Make AFS file locking work again.
(2) Don't write to a page that's being written out, but wait for it to complete.
(3) Do d_drop() and d_add() in the right places.
(4) Put keys on error paths.
(5) Remove some redundant code.
Thanks,
David
---
The following changes since commit cf9b0772f2e410645fece13b749bd56505b998b8:
Merge tag 'armsoc-drivers' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc (2017-11-16 16:05:01 -0800)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git tags/afs-fixes-20171124
for you to fetch changes up to 43dd388b21c722616413781bd434522376e117cc:
afs: remove redundant assignment of dvnode to itself (2017-11-24 13:55:46 +0000)
----------------------------------------------------------------
AFS fixes
----------------------------------------------------------------
Colin Ian King (1):
afs: remove redundant assignment of dvnode to itself
David Howells (4):
afs: Fix file locking
afs: Make afs_write_begin() avoid writing to a page that's being stored
afs: Fix some dentry handling in dir ops and missing key_puts
afs: Fix signal handling in some file ops
Gustavo A. R. Silva (1):
afs: cell: Remove unnecessary code in afs_lookup_cell
fs/afs/cell.c | 7 +- fs/afs/dir.c | 25 +-- fs/afs/flock.c | 548 +++++++++++++++++++++++++++++---------------------- fs/afs/internal.h | 23 ++- fs/afs/rotate.c | 70 +++++-- fs/afs/security.c | 4 +- fs/afs/server_list.c | 2 +- fs/afs/write.c | 5 + 8 files changed, 405 insertions(+), 279 deletions(-)
Quoted 3 lines · David Howells
(2) Don't write to a page that's being written out, but wait for it to complete.
So I see in the commit message why afs needs to do this, but it's worth pointing out that it's
(a) impossible to avoid the "inconsistent data" case for writable mmap'ed pages
(b) can cause some really nasty latency issues
So the "page->private" issue does mean that write-vs-writeback clearly needs that serialization (and that's not an issue for the mapped page being changed at the same time), but in general filesystem people should be aware that data under writeback may still be further dirtied while the writeback is active (and the page marked dirty again). It can obviously screw with things like checksums etc, and make for temporarily inconsistent state if the filesystem does those kinds of things.
Linus
Quoted 5 lines · Linus Torvalds
So I see in the commit message why afs needs to do this, but it's worth pointing out that it's
(a) impossible to avoid the "inconsistent data" case for writable mmap'ed pages
Doesn't clear_page_dirty_for_io() write-protect the PTE for the page to be written out, in which case ->page_mkwrite() will get called again before the page is redirtied?
Quoted 1 line
(b) can cause some really nasty latency issues
True, but I think the most common case is a file being opened, written start to finish and then closed. Actually, the worst-handled thing I've seen is a shell script appending a bunch of things to a file because ->flush() syncs the file each time it is closed:-/
What would you recommend instead? I'm currently trying and keep track of what needs to be written so that I only write what's changed to the server, rather than writing only whole pages.
David
Quoted 11 lines · David Howells
Quoted 5 lines · Linus Torvalds
So I see in the commit message why afs needs to do this, but it's worth pointing out that it's
(a) impossible to avoid the "inconsistent data" case for writable mmap'ed pages
Doesn't
clear_page_dirty_for_io()write-protect the PTE for the page to be written out, in which case ->page_mkwrite() will get called again before the page is redirtied?
Yes, but page_mkwrite will only block on writeback in progress is if the backing device says it needs stable pages. See wait_for_stable_page(). e.g. stable pages are required if RAID is in use, otherwise modification during IO can result in broken on-disk parity/mirroring....
Cheers,
Dave.
Signature · 2 lines
Dave Chinner [email protected]
Quoted 4 lines · David Howells
Doesn't
clear_page_dirty_for_io()write-protect the PTE for the page to be written out, in which case ->page_mkwrite() will get called again before the page is redirtied?
No, it literally just sets the dirty bit (and does accounting).
But I think you may be right that we always write-protect he page when we move the dirty bit from the page tables to the 'struct page' (page_mkclean_one()).
However, even when you do that, the page can be writable in other mappings. At least fork(), for example, only clears the dirty bit, doesn't mark it write-protected.
So there is some rate-limiting of dirty pages, but I do not believe that we've ever really *serialized* writes.
Quoted 10 lines
Quoted 1 line
(b) can cause some really nasty latency issues
True, but I think the most common case is a file being opened, written start to finish and then closed. Actually, the worst-handled thing I've seen is a shell script appending a bunch of things to a file because ->flush() syncs the file each time it is closed:-/
What would you recommend instead? I'm currently trying and keep track of what needs to be written so that I only write what's changed to the server, rather than writing only whole pages.
I don't think that what you are doing is necessarily wrong, I'm just pointing out that you may still see mmap'ed pages being modified concurrently with the actual IO, and that this will potentially mean (for example) that things like checksums won't be reliably unless you do the checksum as you copy the data to a network packet or something.
Of course, if that kind of inconsistency happens, a later write-back will also happen, and eventually fix it. So the server may see temporarily 'wrong' data, but it won't be final.
I just hope that the inconsistency isn't fatal to the afs client or server code. For example, if you retry writes forever when a checksum were to not match the data, that would be bad.
And yes, this can be
(a) really hard to trigger in practice
(b) very hard to debug due to a combination of very specific timing
and behavior.
so I just wanted to bring this up as a potential issue, not necessarily as a big problem.
Linus
Quoted 3 lines · Linus Torvalds
However, even when you do that, the page can be writable in other mappings. At least
fork(), for example, only clears the dirty bit, doesn't mark it write-protected.
I assumed the rmap walk done by page_mkclean() would take care of that but I'm not really clear on what the code does.
Quoted 3 lines
I just hope that the inconsistency isn't fatal to the afs client or server code. For example, if you retry writes forever when a checksum were to not match the data, that would be bad.
Shouldn't be a problem for the the in-Linux client. Data is copied into sk_bufs preparatory to doing further things to it like checksumming, encryption or transmission (actually, in future, I would like to use the encryption process to save on the copy, but this shouldn't bother that either).
AFAIK, the servers are all userspace jobs that don't let anyone else touch their storage so that they can maintain correctness on the data version number of each vnode.
Quoted 2 lines
so I just wanted to bring this up as a potential issue, not necessarily as a big problem.
Thanks.
David