umamaheswararao commented on a change in pull request #2092:
URL: https://github.com/apache/hadoop/pull/2092#discussion_r445925144



##########
File path: 
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFs.java
##########
@@ -1139,6 +1139,27 @@ public void mkdir(final Path dir, final FsPermission 
permission,
       if (theInternalDir.isRoot() && dir == null) {
         throw new FileAlreadyExistsException("/ already exits");
       }
+
+      if (this.fsState.getRootFallbackLink() != null) {
+        AbstractFileSystem linkedFallbackFs =
+            this.fsState.getRootFallbackLink().getTargetFileSystem();
+        Path p = Path.getPathWithoutSchemeAndAuthority(
+            new Path(theInternalDir.fullPath));
+        String child = (InodeTree.SlashPath.equals(dir)) ?
+            InodeTree.SlashPath.toString() :
+            dir.getName();
+        Path dirToCreate = new Path(p, child);
+        try {
+          linkedFallbackFs.mkdir(dirToCreate, permission, createParent);
+        } catch (IOException e) {
+          if (LOG.isDebugEnabled()) {
+            StringBuilder msg = new StringBuilder("Failed to create {}")
+                .append(" at fallback fs : {}");
+            LOG.debug(msg.toString(), dirToCreate, linkedFallbackFs.getUri());
+          }
+        }
+      }
+

Review comment:
       Thanks a lot @ayushtkn for review!
   1) Yes, I agree somehow we kept Viewfs.java on lowlight, probably due t it's 
low usage :-) I have added tests.
   2) a) This is a good point. I just checked that ViewFs#mkdir is already 
throwing IOE. I think we can just throw IOE out. So, that users would know what 
happened.
       b) Another missed was, even in positive case, I was not returning 
before. Added return after mkdir success.
       c) We always pass createParent as true here. We don't need to actually 
worry parent exist or not, because parent is exist in mount Internal dir, 
that's why it got resolved to InternalDirViewFS#mkdir. So, passing createParent 
as true always in fallback case.
   3) Added tests to cover the cases with ViewFs#mkdir with createParentDir 
true or false, with one level and multipleLevels (means to check recursive 
creation. Both seems to be working.)
   Let's discuss if this behavior make sense to you.




----------------------------------------------------------------
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]



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

Reply via email to