]> git.michaelhowe.org Git - packages/o/openafs.git/commit
dafs: prevent corruption in large fsstate.dat files
authorMark Vitale <mvitale@sinenomine.net>
Wed, 13 Mar 2013 02:13:20 +0000 (22:13 -0400)
committerStephan Wiesand <stephan.wiesand@desy.de>
Fri, 30 Aug 2013 15:09:08 +0000 (08:09 -0700)
commit49a1ef5edfcbfcb411889081d89bc5c112e9033c
treeb9ff4bdbe79813d864b252da9ac02f87b76fde82
parentbad0b13a17183c93c926c694270dc18964ff443c
dafs: prevent corruption in large fsstate.dat files

If while writing to the fsstate.dat file, it exceeds the current
size of the file (multiples of FS_STATE_INIT_FILESIZE (8MiB)),
we call fs_stateResizeFile.  This un-mmaps, truncates, and
re-mmaps the file.  Unfortunately, fs_stateMapFile() resets the
state->mmap.offset and .cursor, so any writes in flight over
the resize will overwrite the first bytes of the file (and leave
zeros in the file where the data should have been written).

Upon return from the write that caused a file resize, the offset
is eventually corrected and the state dump continues with a
silent failure.  Eventually the state dump completes and the
file header is rewritten; this may conceal some or all of
the overwrite damage at offset 0.  However, any zeros near the 8MiB
offset (and its multiples) remain as corruption.

Add a flag to fs_stateMapFile() to allow the caller to specify if
the offset and cursor should be preserved.  Modify fs_stateResizeFile()
to use this capability.

testing note: temporarily reduced FS_STATE_INIT_FILESIZE to 256 bytes
during testing in order to make the problem easier to reproduce.
This problem would normally occur only on relatively large/active
DAFS fileservers.

Reviewed-on: http://gerrit.openafs.org/9599
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
(cherry picked from commit 42351db75e04e46012208d38f80dc17be7ab776d)

Change-Id: I05a01ebce15e26534361863ed0f8d3161c3f8240
Reviewed-on: http://gerrit.openafs.org/9683
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
src/tviced/serialize_state.c