HDFS-7242. Code improvement for FSN#checkUnreadableBySuperuser
@@ -1123,8 +1123,10 @@ public void acquireLock(TransactionLocks locks) throws IOException {
locks.add(il).add(lf.getBlockLock())
.add(lf.getBlockRelated(BLK.RE, BLK.ER, BLK.CR, BLK.UC, BLK.CA));
locks.add(lf.getAcesLock());
+ if(dir.getPermissionChecker().isSuperUser()) {
locks.add(lf.getXAttrLock());
}
+ }
@Override
public Object performTask() throws IOException {
@@ -1190,8 +1192,10 @@ public void acquireLock(TransactionLocks locks) throws IOException {
.setActiveNameNodes(nameNode.getActiveNameNodes().getActiveNodes());
locks.add(il).add(lf.getBlockLock())
.add(lf.getBlockRelated(BLK.RE, BLK.ER, BLK.CR, BLK.UC, BLK.CA));
+ if(dir.getPermissionChecker().isSuperUser()) {
locks.add(lf.getXAttrLock());
}
+ }
@Override
public Object performTask() throws IOException {
@@ -1302,6 +1306,7 @@ private GetBlockLocationsResult getBlockLocationsInt(String src, long offset,
private void checkUnreadableBySuperuser(FSPermissionChecker pc,
INode inode)
throws IOException {
+ if(pc.isSuperUser()) {
for (XAttr xattr : dir.getXAttrs(inode)) {
if (XAttrHelper.getPrefixName(xattr).
equals(SECURITY_XATTR_UNREADABLE_BY_SUPERUSER)) {
@@ -1313,6 +1318,7 @@ private void checkUnreadableBySuperuser(FSPermissionChecker pc,
}
}
}
+ }
/**
* Moves all the blocks from srcs and appends them to trg
* To avoid rollbacks we will verify validity of ALL of the args
