Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

fix(filer): update hard link ctime when nlink changes on unlink (#9018)

Chris Lu3f368466424e
diff --git a/test/pjdfstest/known_failures.txt b/test/pjdfstest/known_failures.txt
index a15ddfdc00..e6459933f4 100644
--- a/test/pjdfstest/known_failures.txt
+++ b/test/pjdfstest/known_failures.txt
@@ -38,12 +38,9 @@ tests/unlink/02.t
tests/unlink/03.t
# ── Hard link nlink/ctime tracking (requires filer changes) ────────────
-# The filer does not update ctime on remaining hard link entries when one
-# link is removed, and nlink counts are not correctly maintained across
-# rename operations.
+# nlink counts are not correctly maintained across rename operations.
tests/rename/23.t
tests/rename/24.t
-tests/unlink/00.t
# ── Parent directory mtime/ctime on deferred file create ───────────────
# When file creation is deferred (not flushed to filer immediately),
diff --git a/weed/filer/filerstore_hardlink.go b/weed/filer/filerstore_hardlink.go
index bfac44a710..ae5ff78a0a 100644
--- a/weed/filer/filerstore_hardlink.go
+++ b/weed/filer/filerstore_hardlink.go
@@ -5,6 +5,7 @@ import (
"context"
"errors"
"fmt"
+ "time"
"github.com/seaweedfs/seaweedfs/weed/glog"
"github.com/seaweedfs/seaweedfs/weed/pb/filer_pb"
@@ -113,6 +114,9 @@ func (fsw *FilerStoreWrapper) DeleteHardLink(ctx context.Context, hardLinkId Har
return fsw.KvDelete(ctx, key)
}
+ // POSIX: update ctime when nlink changes (a hard link was removed).
+ entry.Attr.Ctime = time.Now().UTC()
+
newBlob, encodeErr := entry.EncodeAttributesAndChunks()
if encodeErr != nil {
return encodeErr