HDFS-7028: FSDirectory should not get storage policy id from symlinks

This commit is contained in:
Tsz-Wo Nicholas Sze 2014-09-10 12:34:15 +08:00
parent 6997c1c658
commit 4124905aa5

View File

@ -1423,8 +1423,8 @@ DirectoryListing getListing(String src, byte[] startAfter,
HdfsFileStatus listing[] = new HdfsFileStatus[numOfListing]; HdfsFileStatus listing[] = new HdfsFileStatus[numOfListing];
for (int i=0; i<numOfListing && locationBudget>0; i++) { for (int i=0; i<numOfListing && locationBudget>0; i++) {
INode cur = contents.get(startChild+i); INode cur = contents.get(startChild+i);
byte curPolicy = isSuperUser ? cur.getLocalStoragePolicyID() : byte curPolicy = isSuperUser && !cur.isSymlink()?
BlockStoragePolicy.ID_UNSPECIFIED; cur.getLocalStoragePolicyID(): BlockStoragePolicy.ID_UNSPECIFIED;
listing[i] = createFileStatus(cur.getLocalNameBytes(), cur, needLocation, listing[i] = createFileStatus(cur.getLocalNameBytes(), cur, needLocation,
getStoragePolicyID(curPolicy, parentStoragePolicy), snapshot, getStoragePolicyID(curPolicy, parentStoragePolicy), snapshot,
isRawPath); isRawPath);
@ -1503,7 +1503,7 @@ HdfsFileStatus getFileInfo(String src, boolean resolveLink,
} }
final INodesInPath inodesInPath = getLastINodeInPath(srcs, resolveLink); final INodesInPath inodesInPath = getLastINodeInPath(srcs, resolveLink);
final INode i = inodesInPath.getINode(0); final INode i = inodesInPath.getINode(0);
byte policyId = includeStoragePolicy && i != null ? byte policyId = includeStoragePolicy && i != null && !i.isSymlink() ?
i.getStoragePolicyID() : BlockStoragePolicy.ID_UNSPECIFIED; i.getStoragePolicyID() : BlockStoragePolicy.ID_UNSPECIFIED;
return i == null ? null : createFileStatus(HdfsFileStatus.EMPTY_NAME, i, return i == null ? null : createFileStatus(HdfsFileStatus.EMPTY_NAME, i,
policyId, inodesInPath.getPathSnapshotId(), isRawPath); policyId, inodesInPath.getPathSnapshotId(), isRawPath);