From: Andrew Deason Date: Tue, 22 Mar 2011 21:36:47 +0000 (-0500) Subject: ihandle: Ensure FDH_REALLYCLOSE really closes X-Git-Tag: openafs-devel-1_7_1~763 X-Git-Url: http://git.openafs.org/?p=openafs.git;a=commitdiff_plain;h=a50f4c8d802c7b1c258a9cbe388dfab50425596b ihandle: Ensure FDH_REALLYCLOSE really closes If FDH_REALLYCLOSE is given an FdHandle_t that has more than one user, currently it does effectively nothing. Ensure that the file descriptor actually gets closed on a subsequent FDH_CLOSE, but setting the new fd_needs_rclose field. Change-Id: I04794662ca64e6be718da82e10994a4a7bc0b39a Reviewed-on: http://gerrit.openafs.org/4274 Tested-by: BuildBot Reviewed-by: Derrick Brashear --- diff --git a/src/vol/ihandle.c b/src/vol/ihandle.c index a745666..a198320 100644 --- a/src/vol/ihandle.c +++ b/src/vol/ihandle.c @@ -295,6 +295,7 @@ fdHandleAllocateChunk(void) fdP[i].fd_fd = INVALID_FD; fdP[i].fd_ihnext = NULL; fdP[i].fd_ihprev = NULL; + fdP[i].fd_needs_rclose = 0; DLL_INSERT_TAIL(&fdP[i], fdAvailHead, fdAvailTail, fd_next, fd_prev); } } @@ -386,6 +387,7 @@ ih_open_retry: fdP->fd_status = FD_HANDLE_AVAIL; fdP->fd_ih = NULL; fdP->fd_fd = INVALID_FD; + fdP->fd_needs_rclose = 0; IH_UNLOCK; OS_CLOSE(closeFd); goto ih_open_retry; @@ -403,6 +405,7 @@ ih_open_retry: fdP->fd_status = FD_HANDLE_INUSE; fdP->fd_fd = fd; fdP->fd_ih = ihP; + fdP->fd_needs_rclose = 0; fdP->fd_refcnt++; ihP->ih_refcnt++; @@ -445,7 +448,9 @@ fd_close(FdHandle_t * fdP) * failed (this is determined by checking the ihandle for the flag * IH_REALLY_CLOSED) or we have too many open files. */ - if (ihP->ih_flags & IH_REALLY_CLOSED || fdInUseCount > fdCacheSize) { + if (ihP->ih_flags & IH_REALLY_CLOSED || fdInUseCount > fdCacheSize || + fdP->fd_needs_rclose) { + IH_UNLOCK; return fd_reallyclose(fdP); } @@ -501,6 +506,9 @@ fd_reallyclose(FdHandle_t * fdP) fdP->fd_refcnt = 0; fdP->fd_ih = NULL; fdP->fd_fd = INVALID_FD; + fdP->fd_needs_rclose = 0; + } else { + fdP->fd_needs_rclose = 1; } /* All the file descriptor handles have been closed; reset @@ -828,6 +836,7 @@ ih_fdclose(IHandle_t * ihP) fdP->fd_refcnt = 0; fdP->fd_fd = INVALID_FD; fdP->fd_ih = NULL; + fdP->fd_needs_rclose = 0; closeCount++; } diff --git a/src/vol/ihandle.h b/src/vol/ihandle.h index 08e2d8b..44b163b 100644 --- a/src/vol/ihandle.h +++ b/src/vol/ihandle.h @@ -159,6 +159,7 @@ typedef int FD_t; typedef struct FdHandle_s { int fd_status; /* status flags */ int fd_refcnt; /* refcnt */ + int fd_needs_rclose; /* do we need to fd_reallyclose? */ FD_t fd_fd; /* file descriptor */ struct IHandle_s *fd_ih; /* Pointer to Inode handle */ struct FdHandle_s *fd_next; /* LRU/Avail list pointers */