From: Andrew Deason Date: Thu, 2 Sep 2010 20:05:21 +0000 (-0500) Subject: namei: Limit traversal when removing data dirs X-Git-Tag: upstream/1.6.0.pre2^2~23 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=e0753a6f560c45aa47e038bc6b718873d2fd634d;p=packages%2Fo%2Fopenafs.git namei: Limit traversal when removing data dirs namei_RemoveDataDirectories currently calls delTree with 'tree' pointing to the part of the path immediately following n_base (i.e. starting at the beginning of n_voldir1). This causes delTree to traverse all of n_voldir1, trying to delete every directory it finds. Since we are typically only trying to remove a single volume when calling namei_RemoveDataDirectories, instead call delTree with 'tree' pointing to immediately after n_voldir1, and beginning at n_voldir2 and try to just rmdir n_voldir1 afterwards. This way, we do not traverse a large fraction of the entire partition when just trying to delete a single volume, and so can significantly speed up volume removals. (cherry picked from commit 1ca0a24775794ba2e645854a3bbaa656f2fc8086) Reviewed-on: http://gerrit.openafs.org/2651 Tested-by: Andrew Deason Tested-by: BuildBot Reviewed-by: Derrick Brashear Change-Id: Iadae1e231b533695af615a231e42ad8204674fe4 Reviewed-on: http://gerrit.openafs.org/3908 Tested-by: BuildBot Reviewed-by: Derrick Brashear --- diff --git a/src/vol/namei_ops.c b/src/vol/namei_ops.c index e039523a6..659577612 100644 --- a/src/vol/namei_ops.c +++ b/src/vol/namei_ops.c @@ -602,8 +602,8 @@ namei_RemoveDataDirectories(namei_t * name) strlcpy(path, name->n_path, sizeof(pbuf)); - /* move past the prefix */ - path = path + prefixlen + 1; /* skip over the trailing / */ + /* move past the prefix and n_voldir1 */ + path = path + prefixlen + 1 + vollen + 1; /* skip over the trailing / */ /* now delete all dirs upto path */ code = delTree(pbuf, path, &err);