From 5b62fac45d9eab00626f8aba9d9994d9138980c0 Mon Sep 17 00:00:00 2001 From: Andrew Deason Date: Thu, 29 Aug 2013 15:16:00 -0500 Subject: [PATCH] namei: Remove redundant linktable SetLinkCount If we're setting the linktable linkcount to 0, we're about to delete the whole linktable. So, don't bother setting the link count. Still make sure we unlock the linktable, as we still have it locked at this point, from the previous GetLinkCount call. Change-Id: Ia00c1e14de6b8fcd69d594f0dbdbafa32b066dc5 Reviewed-on: http://gerrit.openafs.org/10195 Tested-by: BuildBot Reviewed-by: D Brashear --- src/vol/namei_ops.c | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/src/vol/namei_ops.c b/src/vol/namei_ops.c index 05d20e9a0..bae4039f6 100644 --- a/src/vol/namei_ops.c +++ b/src/vol/namei_ops.c @@ -70,6 +70,7 @@ int Testing=0; +static void namei_UnlockLinkCount(FdHandle_t * fdP, Inode ino); afs_sfsize_t namei_iread(IHandle_t * h, afs_foff_t offset, char *buf, afs_fsize_t size) @@ -1162,18 +1163,23 @@ namei_dec(IHandle_t * ih, Inode ino, int p1) } count--; - if (namei_SetLinkCount(fdP, (Inode) 0, count < 0 ? 0 : count, 1) < - 0) { - FDH_REALLYCLOSE(fdP); - IH_RELEASE(tmp); - return -1; - } - if (count > 0) { + /* if our count is non-zero, we just set our new linkcount and + * return. But if our count is 0, don't bother updating the + * linktable, since we're about to delete the link table, + * below. */ + if (namei_SetLinkCount(fdP, (Inode) 0, count < 0 ? 0 : count, 1) < 0) { + FDH_REALLYCLOSE(fdP); + IH_RELEASE(tmp); + return -1; + } + FDH_CLOSE(fdP); IH_RELEASE(tmp); return 0; } + + namei_UnlockLinkCount(fdP, (Inode) 0); } if ((code = OS_UNLINK(name.n_path)) == 0) { @@ -1716,6 +1722,17 @@ namei_SetLinkCount(FdHandle_t * fdP, Inode ino, int count, int locked) return (int)nBytes; } +static void +namei_UnlockLinkCount(FdHandle_t * fdP, Inode ino) +{ + afs_foff_t offset; + int index; + + namei_GetLCOffsetAndIndexFromIno(ino, &offset, &index); + + FDH_UNLOCKFILE(fdP, offset); +} + /* ListViceInodes - write inode data to a results file. */ static int DecodeInode(char *dpath, char *name, struct ViceInodeInfo *info, -- 2.39.5