jianghuazhu commented on code in PR #4761:
URL: https://github.com/apache/hadoop/pull/4761#discussion_r952485905


##########
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/INode.java:
##########
@@ -73,7 +73,8 @@ public abstract class INode implements INodeAttributes, 
Diff.Element<byte[]> {
    * Check whether this is the root inode.
    */
   final boolean isRoot() {
-    return getLocalNameBytes().length == 0;
+    // Note: There is no restriction that id must be equal to 
INodeId#ROOT_INODE_ID
+    return getLocalNameBytes() == null || getLocalNameBytes().length == 0;

Review Comment:
   @Hexiaoqiao , thanks for your comment and review.
   I found this question while exploring the FGL module.
   In the FGL module, INodeMap#INodeMap() runs the name is null when 
constructing the INodeDirectory. Here: 
https://github.com/apache/hadoop/blob/fgl/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/INodeMap.java
   
![image](https://user-images.githubusercontent.com/6416939/186145767-9b51ec6c-2c7b-46b0-913d-8d0385488507.png)
   
   When verifying the lease, INode#isRoot() is called. See here:
   
https://github.com/apache/hadoop/blob/fgl/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
   Calling link: FSNamesystem#checkLease()->isFileDeleted()->INode#isRoot().
   
![image](https://user-images.githubusercontent.com/6416939/186145904-bffe4dee-a708-4f29-b728-4780a6589e8e.png)
   
   I think this is a hidden problem because we didn't allow 
INodeWithAdditionalFields#name to always be an empty string.



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

To unsubscribe, e-mail: [email protected]

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