-
Notifications
You must be signed in to change notification settings - Fork 8.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HDFS-16733.Improve INode#isRoot(). #4761
base: trunk
Are you sure you want to change the base?
Conversation
760969f
to
2624c60
Compare
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
Can you help review this pr, @jojochuang @virajjasani @Hexiaoqiao . |
@@ -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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I did not get why change here. IIUC, ROOT_NAME
is not null but empty string, right? If that, I think it will not throw NPE here. So any information I missed? Thanks @jianghuazhu .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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
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().
I think this is a hidden problem because we didn't allow INodeWithAdditionalFields#name to always be an empty string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it. If that is true, I think we should submit PR to branch FGL first? Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @Hexiaoqiao .
Description of PR
When constructing an INodeFile or INodeDirectory, if the given name is null, an exception will be thrown when checking whether it is root.
Details: HDFS-16733
How was this patch tested?
When constructing an INodeFile or INodeDirectory, if the given name is null, an exception will not occur when checking whether it is root.