Commit Graph

6 Commits

Author SHA1 Message Date
Andrew Deason
4498bd8179 volser: Don't NUL-pad failed pread()s in dumps
Currently, the volserver SAFSVolDump RPC and the 'voldump' utility
handle short reads from pread() for vnode payloads by padding the
missing data with NUL bytes. That is, if we request 4k of data for our
pread() call, and we only get back 1k of data, we'll write 1k of data
to the volume dump stream followed by 3k of NUL bytes, and log
messages like this:

    1 Volser: DumpFile: Error reading inode 1234 for vnode 5678
    1 Volser: DumpFile: Null padding file: 3072 bytes at offset 40960

This can happen if we hit EOF on the underlying file sooner than
expected, or if the OS just responds with fewer bytes than requested
for any reason.

The same code path tries to do the same NUL-padding if pread() returns
an error (for example, EIO), padding the entire e.g. 4k block with
NULs. However, in this case, the "padding" code often doesn't work as
intended, because we compare 'n' (set to -1) with 'howMany' (set to 4k
in this example), like so:

    if (n < howMany)

Here, 'n' is signed (ssize_t), and 'howMany' is unsigned (size_t), and
so compilers will promote 'n' to the unsigned type, causing this
conditional to fail when n is -1. As a result, all of the relevant log
messages are skipped, and the data in the dumpstream gets corrupted
(we skip a block of data, and our 'howFar' offset goes back by 1). So
this can result in rare silent data corruption in volume dumps, which
can occur during volume releases, moves, etc.

To fix all of this, remove this bizarre NUL-padding behavior in the
volserver. Instead:

- For actual errors from pread(), return an error, like we do for I/O
  errors in most other code paths.

- For short reads, just write out the amount of data we actually read,
  and keep going.

- For premature EOF, treat it like a pread() error, but log a slightly
  different message.

For the 'voldump' utility, the padding behavior can make sense if a
user is trying to recover volume data offline in a disaster recovery
scenario. So for voldump, add a new switch (-pad-errors) to enable the
padding behavior, but change the default behavior to bail out on
errors.

Change-Id: Ibd6e76c5ea0dea95e3354d9b34536296f81b4f67
Reviewed-on: https://gerrit.openafs.org/14255
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
2020-07-24 12:03:44 -04:00
Andrew Deason
10b356c1eb doc: voldump manpage fixes
Add missing documentation for the -time and -help options.

Change-Id: I04ca0fe6d4a5c298415e450a38a19b719dca4800
Reviewed-on: http://gerrit.openafs.org/10391
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
Tested-by: Derrick Brashear <shadow@your-file-system.com>
2013-11-04 04:03:54 -08:00
Russ Allbery
d6df1a8cec Move restorevol to bin from sbin
restorevol only requires access to a dump file and write access to the
directory in which the dump is being unpacked.  It doesn't require being
a superuser, so it should be installed in bin instead of sbin.  Also
move the man page to section 1 and update references accordingly.

Reviewed-on: http://gerrit.openafs.org/333
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Tested-by: Derrick Brashear <shadow@dementia.org>
2009-09-09 21:22:34 -07:00
Steven Jenkins
97b0d23014 man-page-restorevol-20090518
LICENSE IPL10
FIXES 124791

Add man page for restorevol.
2009-05-18 19:46:33 +00:00
Russ Allbery
fc5acc0151 pretty-html-synopsis-20060228
Implement proper synopsis wrapping for HTML generation.

This was done in three pieces.  First, add HTML-specific tags to the POD to
mark the synopsis for HTML purposes so that we can apply style information
to it.  Second, update the style sheet to indent all lines except for the
first in the synopsis section.  Third, add the appropriate S<> tags around
option and argument pairs so that we don't wrap between the option and its
argument.

Unfortunately, due to the <I<foo>> style that looks nicer for other reasons,
we have to use the very verbose S<<< >>>.  Oh well.
2006-03-01 05:02:29 +00:00
Russ Allbery
90bc5c0092 man-page-misc-improvements-20051221
Add new man pages for livesys and voldump.  Fix the man page for sys to say
what it actually does, rather than implying that it works like livesys, and
to recommend livesys instead.  Fix a path error in the NetInfo
documentation.  Update the README for the current status, including
listing all installed commands that don't have man pages.  (There may still
be some subcommands that don't have man pages but aren't listed.)
2005-12-22 07:34:49 +00:00