Repository navigation
Conversation
33f4f3e to
a60b11c
Compare
|
Rebased on top of changes on the master branch |
235954f to
67ad361
Compare
|
hugo-hur:ltfs-aware |
|
Changed to draft for now as I found out some problems with testing I have to look at and test other things too locally (mainly compatibilities between rsync versions). |
|
Now tests pass on Debian and Cygwin, should pass also elsewhere (famous last words). The |
|
Also worth noting that currently Cygwin configure flags xattrs as linux style available. I'm not sure if that works as expected... |
|
Rebased to master once more. Also added another pr #1007 for sha256 support for OpenSSL builds for possibly helping on the future |
8313559 to
195e436
Compare
Introduce the machinery for tape-aware transfers without yet changing the read order. On an LTFS volume each file's metadata -- including the block where its data begins -- lives in the volume index and is cheap to read, while reading content requires physically positioning the tape. Add a new ltfs.c module that reads a file's starting block from the ltfs.startblock virtual xattr (also honoring a user.ltfs.startblock alias so the feature can be exercised on an ordinary filesystem). The sender records that block into a new optional 64-bit file-list extra and transmits it, so the generator -- which on a local copy is chdir'd into the destination and cannot read the source xattrs itself -- receives each file's physical position. Wire up the --ltfs option: it allocates the extra, implies --whole-file (a delta transfer would re-read the source off tape anyway), forces --no-inc-recursive (the full list is needed before a read order can be chosen), and refuses --checksum (which would read the whole tape just to decide what to transfer). The option is propagated to the server side so both ends agree on the file-list extra layout. Reading the start block requires xattr support, so the whole feature is gated on SUPPORT_XATTRS: the file-list extra is only registered when xattrs are available, and a build without them refuses --ltfs (like --crtimes and friends) rather than silently accepting an inert option.
With the start block of every file now available on the generator side,
order the data-read phase by ascending block instead of by name when --ltfs
is in effect. The drive then makes a single forward streaming pass rather
than seeking back and forth ("shoe-shining"), which on a real tape can cut a
restore from hours to one pass.
Entries with no start block (directories, symlinks, anything not on tape)
sort first in their original order, which conveniently front-loads creation
of the destination directory tree before the bulk data read begins. A NULL
ordering (ltfs off, no metadata negotiated, or an empty range) falls back to
the natural low..high sweep.
Add the option summary line and a full description covering what LTFS ordering does, the options it implies (--whole-file, --no-inc-recursive) and refuses (--checksum), that the fast index metadata still drives the normal size+mtime quick check, and that only the read (restore) direction is optimized.
Exercise --ltfs on an ordinary filesystem via the user.ltfs.startblock alias, assigning blocks that run opposite to name order. The test verifies round-trip integrity, that the itemized output (rsync's observable processing order) comes out in physical block order across subdirectories with directories handled first, and that --ltfs --checksum is refused. Skips cleanly when the build lacks xattr support or the scratch filesystem rejects a user.* xattr.
--ltfs's value is that an LTFS source serves size and mtime from the tape index for free, letting rsync's quick check skip unchanged files without reading their content off the tape. That only works if the destination keeps the source mtimes: without -t, every run sees a time mismatch and re-reads the whole tape, defeating the purpose. Process --ltfs in the option loop (via OPT_LTFS) and set preserve_mtimes there, the same way --archive implies -t, so a later --no-times can still override it in option order. When it is overridden, warn that unchanged files can no longer be skipped, rather than silently doing the slow thing. Found while testing against a real LTO-5 LTFS volume: a bare -r --ltfs left current mtimes on the destination, so the next run wanted to re-read every file.
Note in the manpage that --ltfs enables mtime preservation (like --archive) so the index quick-check can skip unchanged files across runs, and that a later --no-times overrides it with a warning.
Verify that --ltfs preserves source mtimes without an explicit -t (so an immediate re-run finds nothing to transfer) and that an explicit --no-times still runs but emits a warning.
Add SUPPORT_LTFS to rsync.h, defined whenever SUPPORT_XATTRS is present, as a named compile-time capability for the feature. Remove the parse_one_refuse_match() call that hard-refused --ltfs on non-xattr builds. Instead, move startblock_ndx allocation out of its #ifdef SUPPORT_XATTRS guard so both sides of a connection always agree on the file-list layout when ltfs_mode is on. A server-side runtime check (#ifndef SUPPORT_LTFS) aborts with "--ltfs is not supported on this server" if the server lacks the capability. This lets a client without extended attribute support accept --ltfs and forward it to a remote server that does have SUPPORT_LTFS, while ensuring a non-capable server fails loudly rather than silently.
The test exercises local-to-local copy ordering only; it does not test remote flag forwarding. Rename testsuite/ltfs_test.py to testsuite/ltfs-local_test.py, add a clarifying comment at the top of the script, and update the RSYNC_EXPECT_SKIPPED list in both the macOS and Cygwin CI workflows to match the new test base name.
Two bugs prevented --ltfs from being rejected by a server that lacks
SUPPORT_LTFS:
1. The abort guard in parse_arguments() checked only am_server, which is
0 in daemon mode (it is set only when --server appears in argv, i.e.
remote-shell invocation). Daemon mode sets am_daemon instead, so the
condition now reads am_server || am_daemon.
2. The test binary rsync_noltfs was compiled with -USUPPORT_XATTRS to
suppress SUPPORT_LTFS, but config.h (which has no include guard and
is re-included by rsync.h) redefines SUPPORT_XATTRS regardless of
-U flags. The fix uses a positive compile-time hook:
-DLTFS_SERVER_REJECT_TEST activates the abort block via
#if !defined(SUPPORT_LTFS) || defined(LTFS_SERVER_REJECT_TEST)
so the rejection path is always compiled into the test binary
regardless of config.h.
Makefile.in gains the rsync_noltfs build rules (options.c recompiled with
the test hook; all other .o files shared with the normal rsync binary).
The ltfs-server-reject test drives this: it starts rsync_noltfs as the
daemon via RSYNC_CONNECT_PROG and verifies that the client gets a clear
"--ltfs is not supported on this server" error.
ltfs-daemon_test.py exercises the full client-server path over a
RSYNC_CONNECT_PROG pipe (no TCP socket, no real LTFS volume needed):
1. Round-trip integrity: files with user.ltfs.startblock xattrs pushed
to a daemon module and received successfully with --ltfs.
2. Physical ordering: files with startblocks assigned in reverse name
order; the -i output from the generator (daemon side) must list them
in ascending startblock order, confirming that ltfs_build_order()
runs correctly across the daemon pipe.
The test skips on platforms where os.setxattr is unavailable (Cygwin,
macOS without the xattr shim), so ltfs-daemon is added to
RSYNC_EXPECT_SKIPPED in both CI workflows.
…n the autotools toolchain.
…mon, verifying both a push and a pull complete correctly with no errors
CHECK_PROGS unconditionally included rsync_noltfs, so it was built even on MinGW where LTFS is disabled. shutil.which() then found it and the ltfs-server-reject / ltfs-client-compat tests ran instead of skipping. Gate the binary and its intermediate object on the same condition that gates SUPPORT_LTFS in configure.ac: xattr support present and --ltfs not explicitly disabled.
…ng regenerating configure files after make distclean
referencing the autogen.sh script in Makefile.in
The test transferred with -r but compared tls listings that include mtimes. Without -t the destination mtimes are set to the transfer time rather than copied from the source, so the listings only matched when the whole test happened to run inside a single wall-clock second. It failed intermittently otherwise (~25% of parallel runs here). The other ltfs tests pass --ltfs, which implies -t, so this was the only one affected. Preserve times on all four transfers instead. Also move DAEMON_PORT off 12897, which daemon-path-root-read_test.py already uses, to the unused 12900.
|
Should likely require the complete xattr value to be a valid non-negative decimal and reject ERANGE or trailing characters. As written, |
|
@hugo-hur Any chance I could get you to test this on LTFS? It now handles a flat local restore from one volume. A comparison with plain |
Motivation
I'm running several LTFS formatted LTO tapes for incremental backups. Backupping to tape has been working fine with rsync (using the --whole-file and -t options) but reading from the tape is basically impossible due to the reasons stated below.
Summary
Adds a
--ltfsoption that makes rsync read an LTFS-tape source in physicalblock order instead of name order, so a restore streams the tape forward in a
single pass instead of seeking back and forth ("shoe-shining").
On an LTFS volume, each file's metadata — name, size, mtime, and the block where
its data begins — lives in the volume index and is cheap to read. File content,
however, requires physically positioning the tape. rsync's normal name-sorted
traversal bears no relation to physical layout, so an unordered restore can take
many times longer than one forward pass.
What it does
ltfs.startblockvirtual xattr (also honoring a
user.ltfs.startblockalias) and transmits itas a new optional 64-bit file-list extra.
with no start block (directories, symlinks) sort first, which front-loads
creation of the destination directory tree before the bulk data read.
Behavior & safeguards
--ltfsis opinionated about the things that would silently defeat it:--whole-file— a delta transfer would re-read the source offtape anyway.
--no-inc-recursive— the complete file list is needed before aread order can be chosen.
--checksum— it would read every byte of every file off the tapejust to decide what to transfer.
--times(just like--archive) — the whole benefit is that the indexserves size+mtime for free so unchanged files are skipped without reading
content; that only holds across runs if mtimes are preserved. A later
--no-timesoverrides it but emits a warning.Compatibility / requirements
SUPPORT_XATTRS: the file-list extra is only registered when xattrs areavailable, and a build without them refuses
--ltfs(like--crtimes)rather than silently no-op'ing.
orders the reads);
--ltfsis forwarded to the server side.Testing
testsuite/ltfs_test.pyexercises ordering on an ordinary filesystem viathe
user.ltfs.startblockalias: round-trip integrity, physical-block readorder across subdirectories (directories handled first), the implied
-t/--no-timeswarning, and that--checksumis refused. It skips cleanly whenthe build lacks xattr support or the platform/filesystem can't set a
user.*xattr (e.g. Windows, where
os.setxattris absent).--disable-xattr-support.--ltfsread three fileswhose start blocks ran opposite to name order in correct forward order
(verified via
straceon the drive), all MD5s matched the tape, and a second-tpass skipped every file from index metadata alone — zero content reads.Not in scope (possible follow-ups)