afs: Fix potential thrashing in afs writeback
In afs_writepages_region(), if the dirty page we find is undergoing
writeback or write to cache, but the sync_mode is WB_SYNC_NONE, we go
round the loop trying the same page again and again with no pausing or
waiting unless and until another thread manages to clear the writeback
and fscache flags.
Fix this with three measures:
(1) Advance start to after the page we found.
(2) Break out of the loop and return if rescheduling is requested.
(3) Arbitrarily give up after a maximum of 5 skips.
Fixes: 31143d5d515e ("AFS: implement basic file write support")
Reported-by: Marc Dionne <email@example.com>
Signed-off-by: David Howells <firstname.lastname@example.org>
Tested-by: Marc Dionne <email@example.com>
Acked-by: Marc Dionne <firstname.lastname@example.org>
Link: https://email@example.com/ # v1
Signed-off-by: Linus Torvalds <firstname.lastname@example.org>
1 file changed