Skip to content

mv: keep copying xattrs after one fails on a cross-device move - #14629

Open
krosci wants to merge 1 commit into
uutils:mainfrom
krosci:mv-copy-xattr-continue-on-error
Open

krosci wants to merge 1 commit into
uutils:mainfrom
krosci:mv-copy-xattr-continue-on-error

Conversation

@krosci

@krosci krosci commented Sep 16, 2026 •

Copy link
Copy Markdown

When a cross-device move copies a file or directory that carries several xattrs, a single rejected attribute (e.g. one larger than the destination filesystem allows) used to abort the copy loop, silently dropping every remaining xattr, and the move reported success. GNU mv reports the failing attribute on stderr, copies on through the others, and still exits 0.

copy_xattrs*/apply_xattrs* in uucore now report each failing attribute, keep copying the rest, and return the first error. mv no longer aborts the directory path on a reported failure. cp uses a silent marker so the already-reported per-attribute diagnostics are not echoed a second time.

Fixes #14598.

Comment thread src/uu/cp/src/cp.rs Outdated
#[error("{}", translate!("cp-error-not-all-files-copied"))]
NotAllFilesCopied,

/// Extended-attribute copying failed, but every failure was already

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think it can be a one line comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

Comment thread src/uu/cp/src/cp.rs Outdated

// If copying xattrs failed, propagate that error now with context.
//
// `copy_xattrs*` already reported each failing attribute on stderr, so

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same, doesn't have to be that long

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

@krosci
krosci requested a review from sylvestre September 16, 2026 23:14
@github-actions

github-actions Bot commented Sep 17, 2026 •

Copy link
Copy Markdown

GNU testsuite comparison:

Skipping an intermittent issue tests/date/resolution (passes in this run but fails in the 'main' branch)

@krosci
krosci force-pushed the mv-copy-xattr-continue-on-error branch 5 times, most recently from c11d4b9 to 7018e7c Compare September 20, 2026 10:33
@codspeed

codspeed Bot commented Sep 20, 2026 •

Copy link
Copy Markdown

Merging this PR will degrade performance by 17.62%

⚡ 2 improved benchmarks
❌ 9 regressed benchmarks
✅ 378 untouched benchmarks
⏩ 54 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
❌ Memory dd_copy_default 19.7 KB 28.4 KB -30.7%
❌ Memory dd_copy_4k_blocks 23 KB 31.7 KB -27.47%
❌ Memory dd_copy_partial 23 KB 31.8 KB -27.46%
❌ Memory dd_copy_with_skip 23.3 KB 32 KB -27.2%
❌ Memory dd_copy_with_seek 23.3 KB 32 KB -27.2%
❌ Memory dd_copy_8k_blocks 27 KB 35.7 KB -24.39%
❌ Simulation three_39_bit_primes 544.2 ms 648.3 ms -16.05%
❌ Memory dd_copy_64k_blocks 83 KB 91.7 KB -9.5%
❌ Memory dd_copy_separate_blocks 185.2 KB 195.8 KB -5.42%
⚡ Simulation thirteen_39_bit_primes 9.4 s 8.7 s +8.26%
⚡ Simulation five_38_bit_primes 1.8 s 1.7 s +4.29%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing krosci:mv-copy-xattr-continue-on-error (5ccddc9) with main (c08a4e0)

Open in CodSpeed

Footnotes

  1. 54 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@sylvestre
sylvestre force-pushed the mv-copy-xattr-continue-on-error branch from 7018e7c to 9c3117a Compare September 20, 2026 19:29
Comment thread src/uucore/src/lib/features/fsxattr.rs Outdated
} else {
"setting attribute"
};
show_error!("{action} {}: {}", attr_name.quote(), strip_errno(&err));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use translate!() for these two strings
also, GNU says "setting attribute 'user.x' for 'dest': ...", could you please check the LANG=C output and match it (the "for dest" part is missing here)?

Comment thread tests/by-util/test_mv.rs
/// failing `user.m_big` is rejected.
#[test]
#[cfg(target_os = "linux")]
fn test_mv_cross_device_dir_xattr_partial_failure_completes() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this test is ~90% the same as the one above, could be dedup, no?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, I'm done!

Comment thread tests/by-util/test_mv.rs Outdated
assert_eq!(small_z_out.stdout, b"87654321");

let big_out = Command::new("getfattr")
.args(["-n", "user.m_big", "--only-values", "--absolute-names"])

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the getfattr + assert block is repeated 5 times in this file, a small helper please :)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, I'm done!

Comment thread tests/by-util/test_mv.rs Outdated
/// source. Returns `None` when this machine's filesystem combination cannot
/// produce that failure, in which case the test should be skipped.
#[cfg(target_os = "linux")]
fn tmpfs_to_target_failing_xattr_value(dest_dir: &Path) -> Option<String> {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same probe as in the uucore unit test and test_cp, please share it (uutests?)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, moved to uutests::util::tmpfs_to_target_failing_xattr_value.

Comment thread .github/workflows/GnuComment.yml Outdated
Comment thread build.rs
@krosci
krosci force-pushed the mv-copy-xattr-continue-on-error branch 6 times, most recently from 5c5b404 to 6d1d122 Compare September 25, 2026 20:49
@anastygnome

Copy link
Copy Markdown
Contributor

This has just changed in latest coreutils, please check

@krosci
krosci force-pushed the mv-copy-xattr-continue-on-error branch from 6d1d122 to 5ccddc9 Compare September 27, 2026 17:17
@krosci

krosci commented Sep 27, 2026

Copy link
Copy Markdown
Author

This has just changed in latest coreutils, please check

I don't think so; I've rebased to upstream, but it doesn't do anything for me.

@anastygnome

Copy link
Copy Markdown
Contributor

In GNU coreutils there were changes to mv, can you check it's still ok ?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mv: cross-device move drops the rest of the xattrs after one failure, and reports success

3 participants