vol: Nuke parent vol special inodes
authorAndrew Deason <adeason@sinenomine.net>
Wed, 18 Sep 2013 21:56:23 +0000 (16:56 -0500)
committerDerrick Brashear <shadow@your-file-system.com>
Mon, 23 Sep 2013 18:17:19 +0000 (11:17 -0700)
When we "nuke" a volume, we delete all inodes we can find that are for
the given volume id. This currently means that if we nuke an RW volume
id, we delete all of the inodes for file data for the entire volume
group (since they're all stored in the VG id), but we do not delete
the special inodes for any non-RW volumes in that volume group. Those
special inodes left behind are not very useful, since we just deleted
all of the actual file data.

Currently this means that on namei, it's impossible to nuke the
special inodes for non-RW volumes, since the namei nuke will only look
in the subdir for the given volume id. If you give it the RW volume
id, it won't delete the special inodes as menioned above; if you give
it the RO volume id, it will only look in the RO subdir, and won't
find the RO special inodes in the RW subdir.

If a volume group is damaged in such a way that the salvager cannot
fix it (due to a bug), this means that it is impossible to get rid of
that volume group completely from the partition on namei without
manually running "rm -rf" on the relevant AFSIDat directory. Normally
we have a failsafe of running 'vos zap -force', but that doesn't work
for non-RW special inodes, as mentioned above.

So, in order to allow this 'vos zap -force' failsafe to work in
hopefully all situations, also delete the special inodes for the
parent volume. Use similar logic as exists in the salvager's
OnlyOneVolume function.

Change-Id: Id29da48a548c70b2b9ada1dd09f41cb59452bd11
Reviewed-on: http://gerrit.openafs.org/10256
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>

src/vol/nuke.c

index 7679c50..3d520ff 100644 (file)
@@ -48,7 +48,6 @@ struct ilist {
 
 /* called with a structure specifying info about the inode, and our rock (which
  * is the volume ID.  Returns true if we should keep this inode, otherwise false.
- * Note that ainfo->u.param[0] is always the volume ID, for any vice inode.
  */
 static int
 NukeProc(struct ViceInodeInfo *ainfo, VolumeId avolid, void *arock)
@@ -62,8 +61,21 @@ NukeProc(struct ViceInodeInfo *ainfo, VolumeId avolid, void *arock)
 #endif /* !AFS_PTHREAD_ENV */
 
     /* check if this is the volume we're looking for */
-    if (ainfo->u.param[0] != avolid)
-       return 0;               /* don't want this one */
+    if (ainfo->u.vnode.vnodeNumber == INODESPECIAL) {
+       /* For special inodes, look at both the volume id and the parent id.
+        * If we were given an RW vol id to nuke, we should delete the special
+        * inodes for all volumes in the VG, since we're deleting all of the
+        * regular inodes, too. If we don't do this, on namei would be
+        * impossible to nuke the special inodes for a non-RW volume. */
+       if (ainfo->u.special.volumeId != avolid && ainfo->u.special.parentId != avolid) {
+           return 0;
+       }
+    } else {
+       if (ainfo->u.vnode.volumeId != avolid) {
+           return 0;           /* don't want this one */
+       }
+    }
+
     /* record the info */
     if (!*allInodes || (*allInodes)->freePtr >= MAXATONCE) {
        ti = calloc(1, sizeof(struct ilist));