From: Hartmut Reuter Date: Wed, 5 Oct 2011 14:06:05 +0000 (-0400) Subject: vol_split: avoid using stale open directory vnodes X-Git-Tag: upstream/1.6.1.pre1^2~188 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=fc14f8545a8a6fc5bc3233f51705890b782f3d40;p=packages%2Fo%2Fopenafs.git vol_split: avoid using stale open directory vnodes we could in case of multiple splits end up using a stale open vnode for a directory; attempt to close and thus force-reopen any fdhandles backing ihandles. Reviewed-on: http://gerrit.openafs.org/5553 Reviewed-by: Hartmut Reuter Tested-by: Derrick Brashear Reviewed-by: Derrick Brashear (cherry picked from commit 3df03f0abe3e706eaba57e4d9d8c46f2f4d7414c) Change-Id: I4894b21ac3ee114f57192261220c002a2e213ae9 Reviewed-on: http://gerrit.openafs.org/5698 Tested-by: BuildBot Reviewed-by: Derrick Brashear --- diff --git a/src/volser/vol_split.c b/src/volser/vol_split.c index c34cbbeed..7522b9bb3 100644 --- a/src/volser/vol_split.c +++ b/src/volser/vol_split.c @@ -264,6 +264,15 @@ copyDir(struct Msg *m, IHandle_t *inh, IHandle_t *outh) return EIO; } outfdP = IH_OPEN(outh); + /* + * In case that a file with the same (NAMEI) name existed before and is still + * open outfdP may point to the wrong (unlinked) file. To make sure we write + * into the correct file it's safer to 1st FDH_REALLYCLOSE it and then to + * re-open it. + */ + if (outfdP) + FDH_REALLYCLOSE(outfdP); + outfdP = IH_OPEN(outh); if (!outfdP) { sprintf(m->line, "Couldn't open output directory %u.%u.%u\n", outfdP->fd_ih->ih_vid, @@ -516,7 +525,7 @@ createMountpoint(Volume *vol, Volume *newvol, struct VnodeDiskObject *parent, afs_int32 code; Inode ino, newino; DirHandle dir; - IHandle_t *h; + IHandle_t *h, *hp; struct VnodeDiskObject vnode; FdHandle_t *fdP, *fdP2; afs_uint64 size; @@ -625,6 +634,13 @@ createMountpoint(Volume *vol, Volume *newvol, struct VnodeDiskObject *parent, code = Create(&dir, name, &fid); FidZap(&dir); + /* Make sure the directory file doesn't remain open */ + IH_INIT(hp, V_device(vol), V_parentId(vol), ino); + fdP = IH_OPEN(hp); + if (fdP) + FDH_REALLYCLOSE(fdP); + IH_RELEASE(hp); + class = vLarge; vcp = &VnodeClassInfo[class]; fdP = IH_OPEN(vol->vnodeIndex[class].handle);