From 8fb66eb28944668c56d9aa8df961c91ec344f876 Mon Sep 17 00:00:00 2001 From: Ayush Ranjan Date: Wed, 15 Mar 2023 13:23:20 -0700 Subject: [PATCH] Get HardLink test in //runsc/fsgofer:lisafs_test to pass. This test was attempting to create a link with the same name as the target. Changed that to use a different name for link. This test also exposed a ref count bug in LISAFS RPC handlers. Fixed that. Updates #8688 PiperOrigin-RevId: 516912550 --- pkg/lisafs/handlers.go | 1 + pkg/lisafs/testsuite/testsuite.go | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/lisafs/handlers.go b/pkg/lisafs/handlers.go index cb7167bb7..9f3f9c1c6 100644 --- a/pkg/lisafs/handlers.go +++ b/pkg/lisafs/handlers.go @@ -892,6 +892,7 @@ func LinkAtHandler(c *Connection, comm Communicator, payloadLen uint32) (uint32, if err != nil { return 0, err } + defer targetFD.DecRef(nil) if targetFD.IsDir() { // Can not create hard link to directory. return 0, unix.EPERM diff --git a/pkg/lisafs/testsuite/testsuite.go b/pkg/lisafs/testsuite/testsuite.go index e9815baa2..0ae4db28d 100644 --- a/pkg/lisafs/testsuite/testsuite.go +++ b/pkg/lisafs/testsuite/testsuite.go @@ -490,7 +490,8 @@ func testHardLink(ctx context.Context, t *testing.T, tester Tester, root lisafs. defer closeFD(ctx, t, fd) defer unix.Close(hostFD) - link, linkStat := link(ctx, t, root, name, controlFile) + linkName := "linkFile" + link, linkStat := link(ctx, t, root, linkName, controlFile) defer closeFD(ctx, t, link) if linkStat.Ino != fileIno.Ino {