]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commit
xfs: fix log recovery corruption error due to tail overwrite
authorBrian Foster <bfoster@redhat.com>
Sun, 17 Sep 2017 21:06:13 +0000 (14:06 -0700)
committerSeth Forshee <seth.forshee@canonical.com>
Wed, 20 Sep 2017 12:31:56 +0000 (07:31 -0500)
commit15ed9887b89e7a7a75109df6eb4bf41559a390f0
tree14169e3e77b5de94197c6dd422b2b54eae47d464
parentaf84a3f1f9719c3223f5cbe70a5baddcdce5ea57
xfs: fix log recovery corruption error due to tail overwrite

BugLink: http://bugs.launchpad.net/bugs/1718412
commit 4a4f66eac4681378996a1837ad1ffec3a2e2981f upstream.

If we consider the case where the tail (T) of the log is pinned long
enough for the head (H) to push and block behind the tail, we can
end up blocked in the following state without enough free space (f)
in the log to satisfy a transaction reservation:

0 phys. log N
[-------HffT---H'--T'---]

The last good record in the log (before H) refers to T. The tail
eventually pushes forward (T') leaving more free space in the log
for writes to H. At this point, suppose space frees up in the log
for the maximum of 8 in-core log buffers to start flushing out to
the log. If this pushes the head from H to H', these next writes
overwrite the previous tail T. This is safe because the items logged
from T to T' have been written back and removed from the AIL.

If the next log writes (H -> H') happen to fail and result in
partial records in the log, the filesystem shuts down having
overwritten T with invalid data. Log recovery correctly locates H on
the subsequent mount, but H still refers to the now corrupted tail
T. This results in log corruption errors and recovery failure.

Since the tail overwrite results from otherwise correct runtime
behavior, it is up to log recovery to try and deal with this
situation. Update log recovery tail verification to run a CRC pass
from the first record past the tail to the head. This facilitates
error detection at T and moves the recovery tail to the first good
record past H' (similar to truncating the head on torn write
detection). If corruption is detected beyond the range possibly
affected by the max number of iclogs, the log is legitimately
corrupted and log recovery failure is expected.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
fs/xfs/xfs_log_recover.c