Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 5C344200B98 for ; Mon, 3 Oct 2016 19:51:23 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 5AC90160ADC; Mon, 3 Oct 2016 17:51:23 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 98266160ACD for ; Mon, 3 Oct 2016 19:51:22 +0200 (CEST) Received: (qmail 7702 invoked by uid 500); 3 Oct 2016 17:51:20 -0000 Mailing-List: contact hdfs-dev-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list hdfs-dev@hadoop.apache.org Received: (qmail 7387 invoked by uid 99); 3 Oct 2016 17:51:20 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 03 Oct 2016 17:51:20 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id 9E64E2C2A62 for ; Mon, 3 Oct 2016 17:51:20 +0000 (UTC) Date: Mon, 3 Oct 2016 17:51:20 +0000 (UTC) From: "Karthik Palaniappan (JIRA)" To: hdfs-dev@hadoop.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Created] (HDFS-10948) HDFS setOwner no-op should not generate an edit log transaction MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Mon, 03 Oct 2016 17:51:23 -0000 Karthik Palaniappan created HDFS-10948: ------------------------------------------ Summary: HDFS setOwner no-op should not generate an edit log transaction Key: HDFS-10948 URL: https://issues.apache.org/jira/browse/HDFS-10948 Project: Hadoop HDFS Issue Type: Bug Components: hdfs Affects Versions: 2.7.0 Reporter: Karthik Palaniappan Priority: Minor The HDFS setOwner RPC takes a path, optional username, and optional groupname (see ClientNamenodeProtocol.proto). If neither username nor groupname are set, the RPC is a no-op. However, an entry in the edit log is still committed, and when retrieved through getEditsFromTxid, both username and groupname are set to the empty string. This does not match the behavior of the setTimes RPC. There atime and mtime are both required, and you can set "-1" to indicated "don't change the time". If both are set to "-1", the RPC is a no-op, and appropriately no edit log transaction is created. Here's an example of an (untested) patch to fix the issue: ``` diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirAttrOp.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirAttrOp.java index 3dc1c30..0728bc5 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirAttrOp.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirAttrOp.java @@ -77,6 +77,7 @@ static HdfsFileStatus setOwner( if (FSDirectory.isExactReservedName(src)) { throw new InvalidPathException(src); } + boolean changed = false; FSPermissionChecker pc = fsd.getPermissionChecker(); INodesInPath iip; fsd.writeLock(); @@ -92,11 +93,13 @@ static HdfsFileStatus setOwner( throw new AccessControlException("User does not belong to " + group); } } - unprotectedSetOwner(fsd, src, username, group); + changed = unprotectedSetOwner(fsd, src, username, group); } finally { fsd.writeUnlock(); } - fsd.getEditLog().logSetOwner(src, username, group); + if (changed) { + fsd.getEditLog().logSetOwner(src, username, group); + } return fsd.getAuditFileInfo(iip); } @@ -287,22 +290,27 @@ static void unprotectedSetPermission( inode.setPermission(permissions, snapshotId); } - static void unprotectedSetOwner( + static boolean unprotectedSetOwner( FSDirectory fsd, String src, String username, String groupname) throws FileNotFoundException, UnresolvedLinkException, QuotaExceededException, SnapshotAccessControlException { assert fsd.hasWriteLock(); + boolean status = false; final INodesInPath inodesInPath = fsd.getINodesInPath4Write(src, true); INode inode = inodesInPath.getLastINode(); if (inode == null) { throw new FileNotFoundException("File does not exist: " + src); } if (username != null) { + status = true; inode = inode.setUser(username, inodesInPath.getLatestSnapshotId()); } if (groupname != null) { + status = true; inode.setGroup(groupname, inodesInPath.getLatestSnapshotId()); } + + return status; } static boolean setTimes( ``` -- This message was sent by Atlassian JIRA (v6.3.4#6332) --------------------------------------------------------------------- To unsubscribe, e-mail: hdfs-dev-unsubscribe@hadoop.apache.org For additional commands, e-mail: hdfs-dev-help@hadoop.apache.org