feat(native): preserve access and birth time of every entry
Read atime and btime with statx and set them together with owner, mode and mtime. Verification compares both, so a published snapshot must match the source in all three times. The integration fixture compares the times through libcephfs, since ceph-fuse does not expose the birth time. The ctime cannot be preserved: Ceph 21.2.0 accepts CEPH_SETATTR_CTIME but stores the time of the call. The rsync backend still preserves only the mtime. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
a6fda8f8d3
commit
02ebc08c88
7 files changed
+137
-19
No files matched your search
@@ -273,3 +273,35 @@ func TestNativeVerifyCommittedRound(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNativeMetadataPreservesAccessAndBirthTime(t *testing.T) {
|
||||
n := storage.Node{Mode: storage.Regular | 0640, UID: 1, GID: 2,
|
||||
Atime: time.Unix(100, 1), Mtime: time.Unix(200, 2), Btime: time.Unix(50, 3)}
|
||||
|
||||
for _, tc := range []struct {
|
||||
name string
|
||||
change func(*storage.Node)
|
||||
}{
|
||||
{"atime", func(x *storage.Node) { x.Atime = time.Unix(999, 0) }},
|
||||
{"btime", func(x *storage.Node) { x.Btime = time.Unix(999, 0) }},
|
||||
} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
target := n
|
||||
tc.change(&target)
|
||||
src := &attrsTestFS{n: n, attrs: map[string][]byte{}}
|
||||
dst := &attrsTestFS{n: target, attrs: map[string][]byte{}}
|
||||
|
||||
if err := syncNativeMetadata(src, dst, "/src", "/dst", n, true); err == nil {
|
||||
t.Fatal("mismatch not detected")
|
||||
}
|
||||
|
||||
if err := syncNativeMetadata(src, dst, "/src", "/dst", n, false); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if dst.setCalls != 1 || !dst.n.Atime.Equal(n.Atime) || !dst.n.Btime.Equal(n.Btime) {
|
||||
t.Fatalf("times not restored: %+v", dst.n)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user