diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 4565f8a3374..949dc804d14 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -2107,6 +2107,9 @@ Release 2.8.0 - UNRELEASED HDFS-9274. Default value of dfs.datanode.directoryscan.throttle.limit.ms.per.sec should be consistent. (Yi Liu via zhz) + HDFS-9273. ACLs on root directory may be lost after NN restart. + (Xiao Chen via cnauroth) + Release 2.7.2 - UNRELEASED INCOMPATIBLE CHANGES diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSImageFormatPBINode.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSImageFormatPBINode.java index 34b28e4ba04..cf7895bfbd0 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSImageFormatPBINode.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSImageFormatPBINode.java @@ -418,6 +418,10 @@ private void loadRootINode(INodeSection.INode p) { } dir.rootDir.cloneModificationTime(root); dir.rootDir.clonePermissionStatus(root); + final AclFeature af = root.getFeature(AclFeature.class); + if (af != null) { + dir.rootDir.addAclFeature(af); + } // root dir supports having extended attributes according to POSIX final XAttrFeature f = root.getXAttrFeature(); if (f != null) { diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFSImageWithAcl.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFSImageWithAcl.java index bd884783576..690fec6aaeb 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFSImageWithAcl.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFSImageWithAcl.java @@ -206,6 +206,35 @@ public void testEditLogDefaultAclNewChildren() throws IOException { doTestDefaultAclNewChildren(false); } + @Test + public void testRootACLAfterLoadingFsImage() throws IOException { + DistributedFileSystem fs = cluster.getFileSystem(); + Path rootdir = new Path("/"); + AclEntry e1 = new AclEntry.Builder().setName("foo") + .setPermission(ALL).setScope(ACCESS).setType(GROUP).build(); + AclEntry e2 = new AclEntry.Builder().setName("bar") + .setPermission(READ).setScope(ACCESS).setType(GROUP).build(); + fs.modifyAclEntries(rootdir, Lists.newArrayList(e1, e2)); + + AclStatus s = cluster.getNamesystem().getAclStatus(rootdir.toString()); + AclEntry[] returned = + Lists.newArrayList(s.getEntries()).toArray(new AclEntry[0]); + Assert.assertArrayEquals( + new AclEntry[] { aclEntry(ACCESS, GROUP, READ_EXECUTE), + aclEntry(ACCESS, GROUP, "bar", READ), + aclEntry(ACCESS, GROUP, "foo", ALL) }, returned); + + // restart - hence save and load from fsimage + restart(fs, true); + + s = cluster.getNamesystem().getAclStatus(rootdir.toString()); + returned = Lists.newArrayList(s.getEntries()).toArray(new AclEntry[0]); + Assert.assertArrayEquals( + new AclEntry[] { aclEntry(ACCESS, GROUP, READ_EXECUTE), + aclEntry(ACCESS, GROUP, "bar", READ), + aclEntry(ACCESS, GROUP, "foo", ALL) }, returned); + } + /** * Restart the NameNode, optionally saving a new checkpoint. *