]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os: Fix HashIndex::recursive_remove() to remove everything but original path 10565/head
authorDavid Zafman <dzafman@redhat.com>
Wed, 3 Aug 2016 05:32:02 +0000 (22:32 -0700)
committerDavid Zafman <dzafman@redhat.com>
Wed, 3 Aug 2016 06:55:41 +0000 (23:55 -0700)
Fixes: http://tracker.ceph.com/issues/16672
Signed-off-by: David Zafman <dzafman@redhat.com>
src/os/filestore/HashIndex.cc
src/os/filestore/HashIndex.h

index a358ef3a8146c1c69ba92ee8e0f12f12497b459a..b1bf7024fd2180d4f09ccda372710a4b28a3d0bc 100644 (file)
@@ -550,7 +550,12 @@ int HashIndex::recursive_create_path(vector<string>& path, int level)
 }
 
 int HashIndex::recursive_remove(const vector<string> &path) {
+  return _recursive_remove(path, true);
+}
+
+int HashIndex::_recursive_remove(const vector<string> &path, bool top) {
   vector<string> subdirs;
+  dout(20) << __func__ << " path=" << path << dendl;
   int r = list_subdirs(path, &subdirs);
   if (r < 0)
     return r;
@@ -565,12 +570,15 @@ int HashIndex::recursive_remove(const vector<string> &path) {
        i != subdirs.end();
        ++i) {
     subdir.push_back(*i);
-    r = recursive_remove(subdir);
+    r = _recursive_remove(subdir, false);
     if (r < 0)
       return r;
     subdir.pop_back();
   }
-  return remove_path(path);
+  if (top)
+    return 0;
+  else
+    return remove_path(path);
 }
 
 int HashIndex::start_col_split(const vector<string> &path) {
index d4222f912fa9aa59ecae4044529d701ab6a95e5f..461eddcac93664d0ee959c82ec947cef169fa4ab 100644 (file)
@@ -198,6 +198,11 @@ protected:
     ghobject_t *next
     );
 private:
+  /// Internal recursively remove path and its subdirs
+  int _recursive_remove(
+    const vector<string> &path, ///< [in] path to remove
+    bool top                   ///< [in] internal tracking of first caller
+    ); /// @return Error Code, 0 on success
   /// Recursively remove path and its subdirs
   int recursive_remove(
     const vector<string> &path ///< [in] path to remove