vol: Fix VCreateVolume special inode cleanup
authorAndrew Deason <adeason@sinenomine.net>
Wed, 11 Jan 2012 15:00:35 +0000 (10:00 -0500)
committerDerrick Brashear <shadow@dementix.org>
Wed, 11 Jan 2012 18:14:23 +0000 (10:14 -0800)
In order to dec the relevant special inodes, we need to know the
parent vol id in addition to the vol id itself. Use the appropriate
volume IDs when IH_DEC'ing special inodes after we fail to create the
volume, so we don't leave behind special inodes.

Change-Id: I77cfafac80c49debf46c86faefadd2a586d6f06b
Reviewed-on: http://gerrit.openafs.org/6529
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>

src/vol/vutil.c

index 74eaaed..80bbf97 100644 (file)
@@ -67,7 +67,8 @@
 
 #ifdef FSSYNC_BUILD_CLIENT
 static void
-RemoveInodes(struct afs_inode_info *stuff, Device dev, VolumeId vid)
+RemoveInodes(struct afs_inode_info *stuff, Device dev, VolumeId parent,
+             VolumeId vid)
 {
     int i;
     IHandle_t *handle;
@@ -75,11 +76,16 @@ RemoveInodes(struct afs_inode_info *stuff, Device dev, VolumeId vid)
     /* This relies on the fact that IDEC only needs the device and NT only
      * needs the dev and vid to decrement volume special files.
      */
-    IH_INIT(handle, dev, vid, -1);
+    IH_INIT(handle, dev, parent, -1);
     for (i = 0; i < MAXINODETYPE; i++) {
        Inode inode = *stuff[i].inode;
-       if (VALID_INO(inode))
-           IH_DEC(handle, inode, vid);
+       if (VALID_INO(inode)) {
+           if (stuff[i].inodeType == VI_LINKTABLE) {
+               IH_DEC(handle, inode, parent);
+           } else {
+               IH_DEC(handle, inode, vid);
+           }
+       }
     }
     IH_RELEASE(handle);
 }
@@ -237,7 +243,7 @@ VCreateVolume_r(Error * ec, char *partname, VolId volumeId, VolId parentId)
          bad:
            if (handle)
                IH_RELEASE(handle);
-           RemoveInodes(stuff, device, vol.id);
+           RemoveInodes(stuff, device, vol.parentId, vol.id);
            if (!*ec) {
                *ec = VNOVOL;
            }