Repository: hadoop Updated Branches: refs/heads/branch-2.7.2 2311560ec -> 54a1abb41
HDFS-9273. ACLs on root directory may be lost after NN restart. Contributed by Xiao Chen. (cherry picked from commit 1b525a9c32fabd8919c80717a58afbfa7fdce27e) (cherry picked from commit faf1c608990408e2aa59a5e676f86d0c82dbd7f3) Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/54a1abb4 Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/54a1abb4 Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/54a1abb4 Branch: refs/heads/branch-2.7.2 Commit: 54a1abb41464906b69a8d341b9378ff4d25b8053 Parents: 2311560 Author: cnauroth <[email protected]> Authored: Wed Oct 21 16:39:02 2015 -0700 Committer: Vinod Kumar Vavilapalli <[email protected]> Committed: Tue Dec 8 11:24:44 2015 -0800 ---------------------------------------------------------------------- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 3 ++ .../server/namenode/FSImageFormatPBINode.java | 4 +++ .../server/namenode/TestFSImageWithAcl.java | 29 ++++++++++++++++++++ 3 files changed, 36 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/54a1abb4/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 69c5c41..4231f12 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -101,6 +101,9 @@ Release 2.7.2 - 2015-11-11 HDFS-9294. DFSClient deadlock when close file and failed to renew lease. (Brahma Reddy Battula via szetszwo) + HDFS-9273. ACLs on root directory may be lost after NN restart. + (Xiao Chen via cnauroth) + Release 2.7.1 - 2015-07-06 INCOMPATIBLE CHANGES http://git-wip-us.apache.org/repos/asf/hadoop/blob/54a1abb4/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSImageFormatPBINode.java ---------------------------------------------------------------------- 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 3b8c044..6cdd343 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 @@ -384,6 +384,10 @@ public final class FSImageFormatPBINode { } 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) { http://git-wip-us.apache.org/repos/asf/hadoop/blob/54a1abb4/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFSImageWithAcl.java ---------------------------------------------------------------------- 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 bd88478..690fec6 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 class TestFSImageWithAcl { 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. *
