Return-Path: X-Original-To: apmail-hadoop-common-commits-archive@www.apache.org Delivered-To: apmail-hadoop-common-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 674FC17F4F for ; Wed, 21 Oct 2015 23:49:25 +0000 (UTC) Received: (qmail 71494 invoked by uid 500); 21 Oct 2015 23:49:25 -0000 Delivered-To: apmail-hadoop-common-commits-archive@hadoop.apache.org Received: (qmail 71428 invoked by uid 500); 21 Oct 2015 23:49:25 -0000 Mailing-List: contact common-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: common-dev@hadoop.apache.org Delivered-To: mailing list common-commits@hadoop.apache.org Received: (qmail 71419 invoked by uid 99); 21 Oct 2015 23:49:24 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 21 Oct 2015 23:49:24 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id D3CF1E0BA9; Wed, 21 Oct 2015 23:49:24 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: cnauroth@apache.org To: common-commits@hadoop.apache.org Date: Wed, 21 Oct 2015 23:49:24 -0000 Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: [1/2] hadoop git commit: HDFS-9273. ACLs on root directory may be lost after NN restart. Contributed by Xiao Chen. Repository: hadoop Updated Branches: refs/heads/branch-2 7a9b97e6b -> faf1c6089 refs/heads/trunk d1cdce77f -> 1b525a9c3 HDFS-9273. ACLs on root directory may be lost after NN restart. Contributed by Xiao Chen. Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/1b525a9c Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/1b525a9c Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/1b525a9c Branch: refs/heads/trunk Commit: 1b525a9c32fabd8919c80717a58afbfa7fdce27e Parents: d1cdce7 Author: cnauroth Authored: Wed Oct 21 16:39:02 2015 -0700 Committer: cnauroth Committed: Wed Oct 21 16:39:02 2015 -0700 ---------------------------------------------------------------------- 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/1b525a9c/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 4565f8a..949dc80 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 http://git-wip-us.apache.org/repos/asf/hadoop/blob/1b525a9c/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 34b28e4..cf7895b 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 @@ 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/1b525a9c/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. *