[ 
https://issues.apache.org/jira/browse/HADOOP-4771?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12653204#action_12653204
 ] 

Ruyue Ma commented on HADOOP-4771:
----------------------------------

The modification is simple.

In FSDirectory, the original code is 

  public FSDirectory(FSImage fsImage, FSNamesystem ns, Configuration conf) 
throws IOException {
    rootDir = new INodeDirectoryWithQuota(INodeDirectory.ROOT_NAME, 
        ns.createFsOwnerPermissions(new FsPermission((short)0755)), 
ns.getDefaultReplication(),
        Integer.MAX_VALUE, -1);
    this.fsImage = fsImage;
    namesystem = ns;
    initialize(conf);
  }

the modified version is:

  public FSDirectory(FSImage fsImage, FSNamesystem ns, Configuration conf) 
throws IOException {
    rootDir = new INodeDirectoryWithQuota(INodeDirectory.ROOT_NAME, 
        ns.createFsOwnerPermissions(new FsPermission((short)0755)), 
ns.getDefaultReplication(),
        Integer.MAX_VALUE, -1);
    this.fsImage = fsImage;
    namesystem = ns;
    initialize(conf);
    updateCountForINodeWithQuota();
  }



> FSImage saveFSImage() will have problem.
> ----------------------------------------
>
>                 Key: HADOOP-4771
>                 URL: https://issues.apache.org/jira/browse/HADOOP-4771
>             Project: Hadoop Core
>          Issue Type: Bug
>          Components: dfs
>    Affects Versions: 0.19.0, 0.19.1, 0.20.0
>            Reporter: Ruyue Ma
>             Fix For: 0.19.1, 0.20.0
>
>
> Now the directory doesn't have replication factor. so in 
> FSImage.saveFsImage().
> When you format the namenode , hadoop will call FSImage.saveFsImage(). 
> saveFsImage includes the following code:
> out.writeLong(fsDir.rootDir.numItemsInTree());
> When format, the fsDir.rootDir.numItemsInTree() should be 1 (it include the 
> rootdir). But now fsDir.rootDir.numItemsInTree() is 0. 
> The reason why the bug is not simply discovered or triggered is the code in  
> FSImage.saveFsImage().->saveINode2Image().
>     } else {   // write directory inode
>       out.writeShort(0);  // replication
> Because  the directory doesn't have replication factor, so  here is 0. This 
> will cause loadFilesUnderConstruction() will load any files when hadoop fisrt 
> starts up after format.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to