jojochuang commented on a change in pull request #1670: HDFS-14925. Rename 
operation should check nest snapshot
URL: https://github.com/apache/hadoop/pull/1670#discussion_r339287961
 
 

 ##########
 File path: 
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirRenameOp.java
 ##########
 @@ -574,7 +580,28 @@ private static void validateRenameSource(FSDirectory fsd,
     }
     // srcInode and its subtree cannot contain snapshottable directories with
     // snapshots
-    FSDirSnapshotOp.checkSnapshot(fsd, srcIIP, null);
+    FSDirSnapshotOp.checkSnapshot(fsd, srcIIP, snapshottableDirs);
+  }
+
+  private static void validateNestSnapshot(FSDirectory fsd, INodeDirectory 
dstParent,
+      List<INodeDirectory> snapshottableDirs) throws SnapshotException {
+
+    if (fsd.getFSNamesystem().getSnapshotManager().isAllowNestedSnapshots()) {
+      return;
+    }
+
+    /*
+     * snapshottableDirs is a list of snapshottable directory(child of rename 
src)
+     * which do not have snapshots yet. If this list is not empty, that means 
rename
+     * src have snapshottable descendant directories.
+     */
+    if (snapshottableDirs != null && snapshottableDirs.size() > 0) {
+      if 
(fsd.getFSNamesystem().getSnapshotManager().isDescendantOfSnapshotRoot(dstParent))
 {
+        String fullPath = dstParent.getFullPathName();
+        throw new SnapshotException("Failed to rename to " + fullPath +
+                " due to nested snapshottable directory");
 
 Review comment:
   this error message is a little cryptic. We want to make sure an average user 
understand what the problem is without looking at the source code. 
   Can you print something like "Unable to rename because " + fullPath + " is a 
snapshottable directory and the destination is a descent of a snapshottable 
directory, and HDFS does not support nested snapshottable directory" 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to