Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
708fce6
ltfs: add --ltfs option and start-block file-list plumbing
hugo-hur Jun 11, 2026
d735688
ltfs: drive the generator's read order by start block
hugo-hur Jun 11, 2026
0f816f6
ltfs: document --ltfs in the manpage
hugo-hur Jun 11, 2026
50b0b61
ltfs: add testsuite coverage for --ltfs
hugo-hur Jun 11, 2026
64a11f9
ltfs: imply -t so the index quick-check can skip unchanged files
hugo-hur Jun 12, 2026
38d1328
ltfs: document that --ltfs implies --times
hugo-hur Jun 12, 2026
475d704
ltfs: test the implied -t and the --no-times warning
hugo-hur Jun 12, 2026
ed3686c
Skip LTFS aware test on platforms where xattrs do not work
hugo-hur Jun 12, 2026
04414ea
Added LTFS test to expected test skip lists for mac and cygwin
hugo-hur Jun 13, 2026
736ddf0
ltfs: introduce SUPPORT_LTFS; let --ltfs forward to a capable server
hugo-hur Jun 13, 2026
1746cd5
ltfs: rename test to ltfs-local to reflect local-only scope
hugo-hur Jun 13, 2026
025646c
ltfs: add server-reject test and fix the two bugs it exposed
hugo-hur Jun 13, 2026
d288521
ltfs: add daemon-pipe ordering test
hugo-hur Jun 13, 2026
e82c0d2
Fixed missing test directory creation on ltfs-daemon test case.
hugo-hur Jun 13, 2026
86b06d1
Added separate disablement flag for the ltfs awarness functionality i…
hugo-hur Jun 13, 2026
9592f16
ltfs: report LTFS capability in --version and -VV output
hugo-hur Jun 13, 2026
e2e0b83
ltfs: fix test skip guard to check ltfs capability, not xattrs
hugo-hur Jun 13, 2026
21de795
new test: runs rsync_noltfs as the client against an LTFS-capable dae…
hugo-hur Jun 13, 2026
afdc30e
ltfs: skip building rsync_noltfs on platforms without LTFS support
hugo-hur Jun 13, 2026
59548ae
ltfs: LTFS is not a Cygwin target, disable it completely
hugo-hur Jun 13, 2026
a26a0ee
Added ./autogen.sh (as is available in some other projects) for forci…
hugo-hur Jun 13, 2026
2589507
Update Makefile.in
hugo-hur Jun 13, 2026
ea975cd
Matching the test invokes to rest of the project tests
hugo-hur Jun 13, 2026
df0b887
Made autogen.sh executable by default
hugo-hur Jun 13, 2026
a77bb00
ltfs: make ltfs-client-compat deterministic and move its daemon port
hugo-hur Aug 12, 2026
de8d744
merge: sort LTFS reads by partition and block within one volume
steadytao Nov 26, 2026
590c36b
flist: reconcile LTFS ordering with directory selection
steadytao Dec 4, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@

- Added the opt-in SHA-256 transfer checksum `sha256` for builds with OpenSSL
SHA-256 support. Default negotiation is unchanged.
- Add `--ltfs` for partition and block ordering in flat local restores.
- Add `--skip-dir-with` to omit source directories marked by a regular file
in recursive local copies without deletion.

Expand Down
4 changes: 4 additions & 0 deletions compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ extern int preserve_uid;
extern int preserve_gid;
extern int preserve_atimes;
extern int preserve_crtimes;
extern int ltfs_mode;
extern int preserve_acls;
extern int preserve_xattrs;
extern int xfer_flags_as_varint;
Expand Down Expand Up @@ -78,6 +79,7 @@ extern struct name_num_item *xfer_sum_nni;

int remote_protocol = 0;
int file_extra_cnt = 0; /* count of file-list extras that everyone gets */
int ltfs_ndx;
int inc_recurse = 0;
int compat_flags = 0;
int use_safe_inc_flist = 0;
Expand Down Expand Up @@ -589,6 +591,8 @@ void setup_protocol(int f_out,int f_in)
atimes_ndx = (file_extra_cnt += EXTRA64_CNT);
if (preserve_crtimes)
crtimes_ndx = (file_extra_cnt += EXTRA64_CNT);
if (ltfs_mode && local_server)
ltfs_ndx = (file_extra_cnt += EXTRA64_CNT);
if (am_sender) /* This is most likely in the file_extras64 union as well. */
pathname_ndx = (file_extra_cnt += PTR_EXTRA_CNT);
else
Expand Down
98 changes: 98 additions & 0 deletions flist.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
#include "rounding.h"
#include "inums.h"
#include "io.h"
#ifdef SUPPORT_LTFS_ORDER
#include "lib/sysxattrs.h"
#endif

extern int am_root;
extern int am_server;
Expand Down Expand Up @@ -65,6 +68,7 @@ extern int missing_args;
extern int eol_nulls;
extern int atimes_ndx;
extern int crtimes_ndx;
extern int ltfs_ndx;
extern int relative_paths;
extern int implied_dirs;
extern int ignore_perishable;
Expand Down Expand Up @@ -912,6 +916,9 @@ static void send_file_entry(int f, const char *fname, struct file_struct *file,
}
#endif

/* Same-binary local restores have no batch or remote file-list format. */
if (ltfs_ndx)
write_varlong(f, F_LTFS_KEY(file), 3);
write_varlong30(f, F_LENGTH(file), 3);
if (!(xflags & XMIT_SAME_TIME)) {
if (protocol_version >= 30)
Expand Down Expand Up @@ -1040,6 +1047,7 @@ static struct file_struct *recv_file_entry(int f, struct file_list *flist, int x
int first_hlink_ndx = -1;
char real_ISREG_entry;
int64 file_length;
int64 ltfs_key = 0;
#ifdef CAN_SET_NSEC
uint32 modtime_nsec;
#endif
Expand Down Expand Up @@ -1167,6 +1175,8 @@ static struct file_struct *recv_file_entry(int f, struct file_list *flist, int x
}
#endif

if (ltfs_ndx)
ltfs_key = read_varlong(f, 3);
file_length = read_varlong30(f, 3);
if (!(xflags & XMIT_SAME_TIME)) {
if (protocol_version >= 30) {
Expand Down Expand Up @@ -1443,6 +1453,13 @@ static struct file_struct *recv_file_entry(int f, struct file_list *flist, int x
}
#endif
file->mode = mode;
if (ltfs_ndx) {
if (ltfs_key < 0 || (ltfs_key != 0) != (S_ISREG(mode) && file_length > 0)) {
rprintf(FERROR, "invalid local LTFS order key\n");
exit_cleanup(RERR_PROTOCOL);
}
F_LTFS_KEY(file) = ltfs_key;
}
if (preserve_uid)
F_OWNER(file) = uid;
if (preserve_gid) {
Expand Down Expand Up @@ -1631,6 +1648,71 @@ static struct file_struct *recv_file_entry(int f, struct file_list *flist, int x
return file;
}

#ifdef SUPPORT_LTFS_ORDER
static int64 ltfs_order_key(const char *name, const STRUCT_STAT *expected)
{
static char volume[36];
const int64 partition_range = INT64_MAX / 2 + 1;
char uuid[36], partition[2], value[20];
int64 block = 0;
int fd, i;
ssize_t n;
STRUCT_STAT actual;

if (scan_dirfd < 0 || strchr(name, '/') || !*name)
goto invalid;
fd = openat(scan_dirfd, name, O_RDONLY | O_NOFOLLOW | O_NONBLOCK | O_NOCTTY | O_CLOEXEC);
if (fd < 0)
goto invalid;
if (do_fstat(fd, &actual) != 0 || !S_ISREG(actual.st_mode)
|| actual.st_dev != expected->st_dev || actual.st_ino != expected->st_ino
|| actual.st_size != expected->st_size
|| sys_fgetxattr(fd, "user.ltfs.volumeUUID", uuid, sizeof uuid) != sizeof uuid
|| sys_fgetxattr(fd, "user.ltfs.partition", partition, sizeof partition) != 1
|| (partition[0] != 'a' && partition[0] != 'b')) {
close(fd);
goto invalid;
}
n = sys_fgetxattr(fd, "user.ltfs.startblock", value, sizeof value);
close(fd);
if (n <= 0 || n >= (ssize_t)sizeof value)
goto invalid;

for (i = 0; i < (int)sizeof uuid; i++) {
char ch = uuid[i];
if (i == 8 || i == 13 || i == 18 || i == 23) {
if (ch != '-')
goto invalid;
} else if (!(ch >= '0' && ch <= '9') && !(ch >= 'a' && ch <= 'f')
&& !(ch >= 'A' && ch <= 'F'))
goto invalid;
else if (ch >= 'A' && ch <= 'F')
uuid[i] = ch - 'A' + 'a';
}

for (i = 0; i < n; i++) {
int digit = value[i] - '0';
if (digit < 0 || digit > 9 || block > (partition_range - 2 - digit) / 10)
goto invalid;
block = block * 10 + digit;
}

if (!volume[0])
memcpy(volume, uuid, sizeof volume);
else if (memcmp(volume, uuid, sizeof volume) != 0) {
rprintf(FERROR, "LTFS restore must use one volume: %s\n", full_fname(name));
exit_cleanup(RERR_FILEIO);
}

/* Zero is reserved for the directory and empty files. */
return block + 1 + (partition[0] == 'b' ? partition_range : 0);

invalid:
rprintf(FERROR, "cannot read a valid LTFS position for %s\n", full_fname(name));
exit_cleanup(RERR_FILEIO);
}
#endif

#if defined HAVE_DIRFD && defined AT_FDCWD && defined AT_SYMLINK_NOFOLLOW
static DIR *open_scan_directory(const char *path, BOOL sending);

Expand Down Expand Up @@ -1683,6 +1765,7 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
char linkname[MAXPATHLEN];
int alloc_len, basename_len, linkname_len;
int extra_len = file_extra_cnt * EXTRA_LEN;
int64 ltfs_key = 0;
const char *basename;
alloc_pool_t *pool;
STRUCT_STAT st = {0};
Expand Down Expand Up @@ -1791,6 +1874,19 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,

skip_filters:

#ifdef SUPPORT_LTFS_ORDER
if (ltfs_ndx && am_sender && flist) {
if (S_ISREG(st.st_mode) && !(flags & FLAG_TOP_DIR)) {
if (st.st_size)
ltfs_key = ltfs_order_key(thisname, &st);
} else if (!(flags & FLAG_TOP_DIR) || !S_ISDIR(st.st_mode) || strcmp(thisname, ".") != 0) {
rprintf(FERROR, "LTFS ordering requires a flat source of regular files: %s\n",
full_fname(thisname));
exit_cleanup(RERR_FILEIO);
}
}
#endif

#if defined HAVE_DIRFD && defined AT_FDCWD && defined AT_SYMLINK_NOFOLLOW
if (skip_dir_marker && am_sender && flist && S_ISDIR(st.st_mode)
&& !(flags & FLAG_MOUNT_DIR) && skip_marked_dir(thisname, &st))
Expand Down Expand Up @@ -1945,6 +2041,8 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
}
#endif
file->mode = st.st_mode;
if (ltfs_ndx)
F_LTFS_KEY(file) = ltfs_key;
if (preserve_uid)
F_OWNER(file) = st.st_uid;
if (preserve_gid)
Expand Down
30 changes: 28 additions & 2 deletions generator.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ extern int logfile_format_has_i;
extern int am_root;
extern int operator_path_resolve;
extern int am_server;
extern int ltfs_ndx;
extern int am_daemon;
extern int inc_recurse;
extern int relative_paths;
Expand Down Expand Up @@ -3124,6 +3125,19 @@ static void create_deferred_symlinks(void)
#endif
}

static int compare_ltfs_order(const void *left, const void *right)
{
int a = *(const int *)left, b = *(const int *)right;
const struct file_struct *first = cur_flist->sorted[a];
const struct file_struct *second = cur_flist->sorted[b];
int64 x = F_IS_ACTIVE(first) ? F_LTFS_KEY(first) : 0;
int64 y = F_IS_ACTIVE(second) ? F_LTFS_KEY(second) : 0;

if (x != y)
return x < y ? -1 : 1;
return (a > b) - (a < b);
}

void generate_files(int f_out, const char *local_name)
{
int i, ndx, next_loopchk = 0;
Expand Down Expand Up @@ -3184,6 +3198,7 @@ void generate_files(int f_out, const char *local_name)
dflt_perms = (ACCESSPERMS & ~orig_umask);

do {
int *order = NULL;
#ifdef SUPPORT_HARD_LINKS
if (preserve_hard_links && inc_recurse) {
while (!flist_eof && file_total < MIN_FILECNT_LOOKAHEAD/2)
Expand Down Expand Up @@ -3214,16 +3229,26 @@ void generate_files(int f_out, const char *local_name)
change_local_filter_dir(fbuf, strlen(fbuf), F_DEPTH(fp));
}
}
if (ltfs_ndx && cur_flist->low <= cur_flist->high) {
int count = cur_flist->high - cur_flist->low + 1;

/* Change the iteration order without changing file-list indices. */
order = new_array(int, count);
for (i = 0; i < count; i++)
order[i] = cur_flist->low + i;
qsort(order, count, sizeof *order, compare_ltfs_order);
}
for (i = cur_flist->low; i <= cur_flist->high; i++) {
struct file_struct *file = cur_flist->sorted[i];
int pos = order ? order[i - cur_flist->low] : i;
struct file_struct *file = cur_flist->sorted[pos];

if (!F_IS_ACTIVE(file))
continue;

if (unsort_ndx)
ndx = F_NDX(file);
else
ndx = i + cur_flist->ndx_start;
ndx = pos + cur_flist->ndx_start;

if (solo_file)
strlcpy(fbuf, solo_file, sizeof fbuf);
Expand All @@ -3242,6 +3267,7 @@ void generate_files(int f_out, const char *local_name)
}
}

free(order);
if (!inc_recurse) {
write_ndx(f_out, NDX_DONE);
break;
Expand Down
6 changes: 6 additions & 0 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ extern int inc_recurse;
extern int blocking_io;
extern int always_checksum;
extern int time_only;
extern int ltfs_mode;
extern struct chmod_mode_struct *dest_chmod_modes;
extern int remove_source_files;
extern int output_needs_newline;
Expand Down Expand Up @@ -1610,6 +1611,11 @@ static int start_client(int argc, char *argv[])
old_style_args = 2;
trust_sender_args = trust_sender_filter = 1;
}
if (ltfs_mode && (!local_server || argc != 1 || !*argv[0]
|| argv[0][strlen(argv[0]) - 1] != '/')) {
rprintf(FERROR, "--ltfs requires one local source directory ending in a slash\n");
exit_cleanup(RERR_SYNTAX);
}
if (time_only && am_sender && !local_server) {
rprintf(FERROR, "--time-only requires a local receiver or a remote source\n");
exit_cleanup(RERR_SYNTAX);
Expand Down
26 changes: 26 additions & 0 deletions options.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ int human_readable = 1;
int recurse = 0;
int mkpath_dest_arg = 0;
int allow_inc_recurse = 1;
int ltfs_mode = 0;
int xfer_dirs = -1;
int am_daemon = 0;
/* Set after a successful per-module chroot ("use chroot = yes") in
Expand Down Expand Up @@ -647,6 +648,7 @@ static struct poptOption long_options[] = {
{"no-r", 0, POPT_ARG_VAL, &recurse, 0, 0, 0 },
{"inc-recursive", 0, POPT_ARG_VAL, &allow_inc_recurse, 1, 0, 0 },
{"no-inc-recursive", 0, POPT_ARG_VAL, &allow_inc_recurse, 0, 0, 0 },
{"ltfs", 0, POPT_ARG_NONE, &ltfs_mode, 0, 0, 0 },
{"i-r", 0, POPT_ARG_VAL, &allow_inc_recurse, 1, 0, 0 },
{"no-i-r", 0, POPT_ARG_VAL, &allow_inc_recurse, 0, 0, 0 },
{"dirs", 'd', POPT_ARG_VAL, &xfer_dirs, 2, 0, 0 },
Expand Down Expand Up @@ -2352,6 +2354,11 @@ int parse_arguments(int *argc_p, const char ***argv_p)
if (orig_protect_args == 2 && am_server)
protect_args = orig_protect_args;

if (ltfs_mode && (am_server || am_daemon)) {
snprintf(err_buf, sizeof err_buf, "--ltfs requires a local restore\n");
goto cleanup;
}

if (per_dir_basis && (am_server || am_daemon)) {
snprintf(err_buf, sizeof err_buf, "%s requires a local transfer\n", alt_dest_opt(0));
goto cleanup;
Expand Down Expand Up @@ -2937,6 +2944,25 @@ int parse_arguments(int *argc_p, const char ***argv_p)
}
}

if (ltfs_mode) {
#ifndef SUPPORT_LTFS_ORDER
snprintf(err_buf, sizeof err_buf, "--ltfs requires Linux directory descriptors and xattrs\n");
goto cleanup;
#endif
if (!recurse || list_only || relative_paths || files_from || skip_dir_marker
|| whole_file == 0 || always_checksum || delete_mode || missing_args == 2 || force_delete
|| remove_source_files || inplace || keep_partial || basis_dir_cnt || fuzzy_basis
|| preserve_hard_links || copy_links || copy_dirlinks || copy_unsafe_links
|| copy_devices || insecure_links || need_unsorted_flist || read_batch || write_batch
|| remote_option_cnt || INFO_GTE(PROGRESS, 1)) {
snprintf(err_buf, sizeof err_buf,
"--ltfs requires a flat local whole-file restore without deletion or progress reporting\n");
goto cleanup;
}
allow_inc_recurse = 0;
whole_file = 1;
}

if (placement_log && (list_only || inplace || tmpdir || backup_dir || keep_dirlinks
|| insecure_links || confine_root
|| (partial_dir && partial_dir != tmp_partialdir) || read_batch || write_batch)) {
Expand Down
5 changes: 5 additions & 0 deletions progress.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

extern int am_sender;
extern int am_server;
extern int ltfs_ndx;
extern int flist_eof;
extern int quiet;
extern int human_readable;
Expand Down Expand Up @@ -208,6 +209,10 @@ void set_current_file_index(struct file_struct *file, int ndx)
void instant_progress(const char *fname)
{
/* We only get here if want_progress_now is True */
if (ltfs_ndx) {
want_progress_now = False;
return;
}
if (!stdout_format_has_i && !INFO_GTE(NAME, 1))
rprintf(FINFO, "%s\n", fname);
end_progress(0);
Expand Down
Loading
Loading