xfs: handle dquot buffer readahead in log recovery correctly
authorDave Chinner <dchinner@redhat.com>
Mon, 11 Jan 2016 20:04:01 +0000 (07:04 +1100)
committerSasha Levin <sasha.levin@oracle.com>
Wed, 3 Feb 2016 19:01:46 +0000 (14:01 -0500)
commite52b0623ee970dfa58d4af089329e193e59be918
tree64ad5f1d39154290bddd21faf0dd208b2625a214
parent848235ac48d900d7c5e9c6cfb190d290cdb87a62
xfs: handle dquot buffer readahead in log recovery correctly

[ Upstream commit 7d6a13f023567d573ac362502bb702eda716e654 ]

When we do dquot readahead in log recovery, we do not use a verifier
as the underlying buffer may not have dquots in it. e.g. the
allocation operation hasn't yet been replayed. Hence we do not want
to fail recovery because we detect an operation to be replayed has
not been run yet. This problem was addressed for inodes in commit
d891400 ("xfs: inode buffers may not be valid during recovery
readahead") but the problem was not recognised to exist for dquots
and their buffers as the dquot readahead did not have a verifier.

The result of not using a verifier is that when the buffer is then
next read to replay a dquot modification, the dquot buffer verifier
will only be attached to the buffer if *readahead is not complete*.
Hence we can read the buffer, replay the dquot changes and then add
it to the delwri submission list without it having a verifier
attached to it. This then generates warnings in xfs_buf_ioapply(),
which catches and warns about this case.

Fix this and make it handle the same readahead verifier error cases
as for inode buffers by adding a new readahead verifier that has a
write operation as well as a read operation that marks the buffer as
not done if any corruption is detected.  Also make sure we don't run
readahead if the dquot buffer has been marked as cancelled by
recovery.

This will result in readahead either succeeding and the buffer
having a valid write verifier, or readahead failing and the buffer
state requiring the subsequent read to resubmit the IO with the new
verifier.  In either case, this will result in the buffer always
ending up with a valid write verifier on it.

Note: we also need to fix the inode buffer readahead error handling
to mark the buffer with EIO. Brian noticed the code I copied from
there wrong during review, so fix it at the same time. Add comments
linking the two functions that handle readahead verifier errors
together so we don't forget this behavioural link in future.

cc: <stable@vger.kernel.org> # 3.12 - current
Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
fs/xfs/libxfs/xfs_dquot_buf.c
fs/xfs/libxfs/xfs_inode_buf.c
fs/xfs/libxfs/xfs_quota_defs.h
fs/xfs/libxfs/xfs_shared.h
fs/xfs/xfs_log_recover.c