vol: remove empty directories left by vos zap -force 79/12879/4
authorMarcio Barbosa <mbarbosa@sinenomine.net>
Sat, 11 Aug 2018 17:17:28 +0000 (13:17 -0400)
committerBenjamin Kaduk <kaduk@mit.edu>
Fri, 18 Jan 2019 14:16:50 +0000 (09:16 -0500)
The vos zap -force command does not remove the directories associated
with the volume in question (AFS_NAMEI_ENV). When the vos zap -force
command is executed, the volume server goes through the /vicep*/AFSIDat
directories and removes the files associated with the volume id received
as an argument. Unfortunately, the volume server does not remove the
directories associated with this volume. As a result, empty directories
are left behind.

To fix this problem, remove the empty directories left behind when vos
zap -force is executed.

Change-Id: I56fd52918223f87e424121bac6a086d7b0a46284
Reviewed-on: https://gerrit.openafs.org/12879
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

src/vol/namei_ops.c
src/vol/namei_ops.h
src/vol/nuke.c

index aee57a3..1916843 100644 (file)
@@ -3337,4 +3337,37 @@ FreeZLCList(void)
 }
 #endif
 
+/**
+ * Remove empty directories associated with the volume received
+ * as an argument.
+ *
+ * @param[in] pname    vice partition path
+ * @param[in] vid      volume id
+ *
+ * @return 0 on success
+ */
+int
+namei_RemoveDirectories(char *pname, afs_int32 vid)
+{
+    IHandle_t dirIH;
+    namei_t name;
+
+    memset(&dirIH, 0, sizeof(dirIH));
+
+    dirIH.ih_vid = vid;
+
+#ifdef AFS_NT40_ENV
+    dirIH.ih_dev = nt_DriveToDev(pname);
+#else
+    dirIH.ih_dev = volutil_GetPartitionID(pname);
+#endif
+    if (dirIH.ih_dev == -1) {
+       return -1;
+    }
+
+    namei_HandleToVolDir(&name, &dirIH);
+
+    return namei_RemoveDataDirectories(&name);
+}
+
 #endif /* AFS_NAMEI_ENV */
index cacb42f..f3de432 100644 (file)
@@ -88,6 +88,8 @@ int namei_replace_file_by_hardlink(IHandle_t *hLink, IHandle_t *hTarget);
 extern void namei_SetWorkQueue(struct afs_work_queue *wq);
 # endif
 
+int namei_RemoveDirectories(char *pname, afs_int32 vid);
+
 #endif /* AFS_NAMEI_ENV */
 
 #endif /* _AFS_NAMEI_OPS_H_H_ */
index 3d520ff..6b35db8 100644 (file)
@@ -205,6 +205,13 @@ nuke(char *aname, VolumeId avolid)
 
        allInodes = NULL;
 
+#ifdef AFS_NAMEI_ENV
+       if (namei_RemoveDirectories(aname, avolid)) {
+           Log("Nuke: Could not remove some empty directories associated with "
+               "volume %u\n", avolid);
+       }
+#endif
+
        /* at this point, we should try to remove the volume header file itself.
         * the volume header file is the file named VNNNNN.vol in the UFS file
         * system, and is a normal file.  As such, it is not stamped with the