From 219f4c199e45f8ce7f41192493bf0dc8f1e5dc30 Mon Sep 17 00:00:00 2001 From: Xiao Chen Date: Thu, 1 Jun 2017 14:13:57 -0700 Subject: [PATCH] HDFS-11904. Reuse iip in unprotectedRemoveXAttrs calls. --- .../hadoop/hdfs/server/namenode/FSDirErasureCodingOp.java | 2 +- .../org/apache/hadoop/hdfs/server/namenode/FSDirXAttrOp.java | 5 ++--- .../apache/hadoop/hdfs/server/namenode/FSEditLogLoader.java | 3 ++- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirErasureCodingOp.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirErasureCodingOp.java index a875e4b50a..bedbe7d8a2 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirErasureCodingOp.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirErasureCodingOp.java @@ -242,7 +242,7 @@ private static List removeErasureCodingPolicyXAttr( final List xattrs = Lists.newArrayListWithCapacity(1); xattrs.add(ecXAttr); - FSDirXAttrOp.unprotectedRemoveXAttrs(fsd, srcIIP.getPath(), xattrs); + FSDirXAttrOp.unprotectedRemoveXAttrs(fsd, srcIIP, xattrs); return xattrs; } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirXAttrOp.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirXAttrOp.java index e5243eed5e..ddc088c5a7 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirXAttrOp.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirXAttrOp.java @@ -170,7 +170,7 @@ static FileStatus removeXAttr( src = iip.getPath(); checkXAttrChangeAccess(fsd, iip, xAttr, pc); - List removedXAttrs = unprotectedRemoveXAttrs(fsd, src, xAttrs); + List removedXAttrs = unprotectedRemoveXAttrs(fsd, iip, xAttrs); if (removedXAttrs != null && !removedXAttrs.isEmpty()) { fsd.getEditLog().logRemoveXAttrs(src, removedXAttrs, logRetryCache); } else { @@ -184,10 +184,9 @@ static FileStatus removeXAttr( } static List unprotectedRemoveXAttrs( - FSDirectory fsd, final String src, final List toRemove) + FSDirectory fsd, final INodesInPath iip, final List toRemove) throws IOException { assert fsd.hasWriteLock(); - INodesInPath iip = fsd.getINodesInPath(src, DirOp.WRITE); INode inode = FSDirectory.resolveLastINode(iip); int snapshotId = iip.getLatestSnapshotId(); List existingXAttrs = XAttrStorage.readINodeXAttrs(inode); diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLogLoader.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLogLoader.java index ae0b304fba..060bd59793 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLogLoader.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLogLoader.java @@ -931,7 +931,8 @@ private long applyEditLogOp(FSEditLogOp op, FSDirectory fsDir, } case OP_REMOVE_XATTR: { RemoveXAttrOp removeXAttrOp = (RemoveXAttrOp) op; - FSDirXAttrOp.unprotectedRemoveXAttrs(fsDir, removeXAttrOp.src, + INodesInPath iip = fsDir.getINodesInPath(removeXAttrOp.src, DirOp.WRITE); + FSDirXAttrOp.unprotectedRemoveXAttrs(fsDir, iip, removeXAttrOp.xAttrs); if (toAddRetryCache) { fsNamesys.addCacheEntry(removeXAttrOp.rpcClientId,