From 14045511d3d91f36845a138359718c0fe7dff21c Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Mon, 2 Feb 2026 22:18:25 +0100 Subject: Use user-provided Listxattr buffer size This huge buffer showed up big time in ./profiling/ls.bash and caused a 2x LS benchmark slowdown. Instead of the fixed-size buffer, use the buffer size hint the user has provided us. We return inaccurate (larger than actual, which should be safe) numbers when the user has provided no buffer (size probe). --- fsck.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'fsck.go') diff --git a/fsck.go b/fsck.go index 2a76020..243eed9 100644 --- a/fsck.go +++ b/fsck.go @@ -12,6 +12,7 @@ import ( "syscall" "github.com/hanwen/go-fuse/v2/fuse" + "golang.org/x/sys/unix" "github.com/rfjakob/gocryptfs/v2/internal/exitcodes" "github.com/rfjakob/gocryptfs/v2/internal/fusefrontend" @@ -233,7 +234,10 @@ func (ck *fsckObj) watchMitigatedCorruptionsListXAttr(path string) { func (ck *fsckObj) xattrs(relPath string) { // Run ListXAttr() and catch transparently mitigated corruptions go ck.watchMitigatedCorruptionsListXAttr(relPath) - attrs, err := syscallcompat.Llistxattr(ck.abs(relPath)) + // TODO: smarter buffer sizing + buf := make([]byte, 64*1024) + sz, err := unix.Llistxattr(ck.abs(relPath), buf) + attrs := syscallcompat.ParseListxattrBlob(buf[:sz]) ck.watchDone <- struct{}{} if err != nil { fmt.Printf("fsck: error listing xattrs on %q: %v\n", relPath, err) -- cgit v1.2.3