|
@@ -894,7 +894,7 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
|
|
+ @Override
|
|
public void checkOperation(OperationCategory op) throws StandbyException {
|
|
public void checkOperation(OperationCategory op) throws StandbyException {
|
|
if (haContext != null) {
|
|
if (haContext != null) {
|
|
// null in some unit tests
|
|
// null in some unit tests
|
|
@@ -1198,12 +1198,14 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
HdfsFileStatus resultingStat = null;
|
|
HdfsFileStatus resultingStat = null;
|
|
FSPermissionChecker pc = getPermissionChecker();
|
|
FSPermissionChecker pc = getPermissionChecker();
|
|
checkOperation(OperationCategory.WRITE);
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
|
+ byte[][] pathComponents = FSDirectory.getPathComponentsForReservedPath(src);
|
|
writeLock();
|
|
writeLock();
|
|
try {
|
|
try {
|
|
checkOperation(OperationCategory.WRITE);
|
|
checkOperation(OperationCategory.WRITE);
|
|
if (isInSafeMode()) {
|
|
if (isInSafeMode()) {
|
|
throw new SafeModeException("Cannot set permission for " + src, safeMode);
|
|
throw new SafeModeException("Cannot set permission for " + src, safeMode);
|
|
}
|
|
}
|
|
|
|
+ src = FSDirectory.resolvePath(src, pathComponents, dir);
|
|
checkOwner(pc, src);
|
|
checkOwner(pc, src);
|
|
dir.setPermission(src, permission);
|
|
dir.setPermission(src, permission);
|
|
resultingStat = getAuditFileInfo(src, false);
|
|
resultingStat = getAuditFileInfo(src, false);
|
|
@@ -1235,12 +1237,14 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
HdfsFileStatus resultingStat = null;
|
|
HdfsFileStatus resultingStat = null;
|
|
FSPermissionChecker pc = getPermissionChecker();
|
|
FSPermissionChecker pc = getPermissionChecker();
|
|
checkOperation(OperationCategory.WRITE);
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
|
+ byte[][] pathComponents = FSDirectory.getPathComponentsForReservedPath(src);
|
|
writeLock();
|
|
writeLock();
|
|
try {
|
|
try {
|
|
checkOperation(OperationCategory.WRITE);
|
|
checkOperation(OperationCategory.WRITE);
|
|
if (isInSafeMode()) {
|
|
if (isInSafeMode()) {
|
|
throw new SafeModeException("Cannot set owner for " + src, safeMode);
|
|
throw new SafeModeException("Cannot set owner for " + src, safeMode);
|
|
}
|
|
}
|
|
|
|
+ src = FSDirectory.resolvePath(src, pathComponents, dir);
|
|
checkOwner(pc, src);
|
|
checkOwner(pc, src);
|
|
if (!pc.isSuperUser()) {
|
|
if (!pc.isSuperUser()) {
|
|
if (username != null && !pc.getUser().equals(username)) {
|
|
if (username != null && !pc.getUser().equals(username)) {
|
|
@@ -1336,6 +1340,7 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
throws FileNotFoundException,
|
|
throws FileNotFoundException,
|
|
UnresolvedLinkException, IOException {
|
|
UnresolvedLinkException, IOException {
|
|
FSPermissionChecker pc = getPermissionChecker();
|
|
FSPermissionChecker pc = getPermissionChecker();
|
|
|
|
+ byte[][] pathComponents = FSDirectory.getPathComponentsForReservedPath(src);
|
|
for (int attempt = 0; attempt < 2; attempt++) {
|
|
for (int attempt = 0; attempt < 2; attempt++) {
|
|
boolean isReadOp = (attempt == 0);
|
|
boolean isReadOp = (attempt == 0);
|
|
if (isReadOp) { // first attempt is with readlock
|
|
if (isReadOp) { // first attempt is with readlock
|
|
@@ -1345,6 +1350,7 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
checkOperation(OperationCategory.WRITE);
|
|
checkOperation(OperationCategory.WRITE);
|
|
writeLock(); // writelock is needed to set accesstime
|
|
writeLock(); // writelock is needed to set accesstime
|
|
}
|
|
}
|
|
|
|
+ src = FSDirectory.resolvePath(src, pathComponents, dir);
|
|
try {
|
|
try {
|
|
if (isReadOp) {
|
|
if (isReadOp) {
|
|
checkOperation(OperationCategory.READ);
|
|
checkOperation(OperationCategory.READ);
|
|
@@ -1390,6 +1396,8 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
* Moves all the blocks from srcs and appends them to trg
|
|
* Moves all the blocks from srcs and appends them to trg
|
|
* To avoid rollbacks we will verify validitity of ALL of the args
|
|
* To avoid rollbacks we will verify validitity of ALL of the args
|
|
* before we start actual move.
|
|
* before we start actual move.
|
|
|
|
+ *
|
|
|
|
+ * This does not support ".inodes" relative path
|
|
* @param target
|
|
* @param target
|
|
* @param srcs
|
|
* @param srcs
|
|
* @throws IOException
|
|
* @throws IOException
|
|
@@ -1575,12 +1583,14 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
HdfsFileStatus resultingStat = null;
|
|
HdfsFileStatus resultingStat = null;
|
|
FSPermissionChecker pc = getPermissionChecker();
|
|
FSPermissionChecker pc = getPermissionChecker();
|
|
checkOperation(OperationCategory.WRITE);
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
|
+ byte[][] pathComponents = FSDirectory.getPathComponentsForReservedPath(src);
|
|
writeLock();
|
|
writeLock();
|
|
try {
|
|
try {
|
|
checkOperation(OperationCategory.WRITE);
|
|
checkOperation(OperationCategory.WRITE);
|
|
if (isInSafeMode()) {
|
|
if (isInSafeMode()) {
|
|
throw new SafeModeException("Cannot set times " + src, safeMode);
|
|
throw new SafeModeException("Cannot set times " + src, safeMode);
|
|
}
|
|
}
|
|
|
|
+ src = FSDirectory.resolvePath(src, pathComponents, dir);
|
|
|
|
|
|
// Write access is required to set access and modification times
|
|
// Write access is required to set access and modification times
|
|
if (isPermissionEnabled) {
|
|
if (isPermissionEnabled) {
|
|
@@ -1606,7 +1616,10 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
PermissionStatus dirPerms, boolean createParent)
|
|
PermissionStatus dirPerms, boolean createParent)
|
|
throws IOException, UnresolvedLinkException {
|
|
throws IOException, UnresolvedLinkException {
|
|
if (!DFSUtil.isValidName(link)) {
|
|
if (!DFSUtil.isValidName(link)) {
|
|
- throw new InvalidPathException("Invalid file name: " + link);
|
|
|
|
|
|
+ throw new InvalidPathException("Invalid link name: " + link);
|
|
|
|
+ }
|
|
|
|
+ if (FSDirectory.isReservedName(target)) {
|
|
|
|
+ throw new InvalidPathException("Invalid target name: " + target);
|
|
}
|
|
}
|
|
try {
|
|
try {
|
|
createSymlinkInt(target, link, dirPerms, createParent);
|
|
createSymlinkInt(target, link, dirPerms, createParent);
|
|
@@ -1626,12 +1639,14 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
HdfsFileStatus resultingStat = null;
|
|
HdfsFileStatus resultingStat = null;
|
|
FSPermissionChecker pc = getPermissionChecker();
|
|
FSPermissionChecker pc = getPermissionChecker();
|
|
checkOperation(OperationCategory.WRITE);
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
|
+ byte[][] pathComponents = FSDirectory.getPathComponentsForReservedPath(link);
|
|
writeLock();
|
|
writeLock();
|
|
try {
|
|
try {
|
|
checkOperation(OperationCategory.WRITE);
|
|
checkOperation(OperationCategory.WRITE);
|
|
if (isInSafeMode()) {
|
|
if (isInSafeMode()) {
|
|
throw new SafeModeException("Cannot create symlink " + link, safeMode);
|
|
throw new SafeModeException("Cannot create symlink " + link, safeMode);
|
|
}
|
|
}
|
|
|
|
+ link = FSDirectory.resolvePath(link, pathComponents, dir);
|
|
if (!createParent) {
|
|
if (!createParent) {
|
|
verifyParentDir(link);
|
|
verifyParentDir(link);
|
|
}
|
|
}
|
|
@@ -1678,18 +1693,20 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private boolean setReplicationInt(final String src, final short replication)
|
|
|
|
|
|
+ private boolean setReplicationInt(String src, final short replication)
|
|
throws IOException {
|
|
throws IOException {
|
|
blockManager.verifyReplication(src, replication, null);
|
|
blockManager.verifyReplication(src, replication, null);
|
|
final boolean isFile;
|
|
final boolean isFile;
|
|
FSPermissionChecker pc = getPermissionChecker();
|
|
FSPermissionChecker pc = getPermissionChecker();
|
|
checkOperation(OperationCategory.WRITE);
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
|
+ byte[][] pathComponents = FSDirectory.getPathComponentsForReservedPath(src);
|
|
writeLock();
|
|
writeLock();
|
|
try {
|
|
try {
|
|
checkOperation(OperationCategory.WRITE);
|
|
checkOperation(OperationCategory.WRITE);
|
|
if (isInSafeMode()) {
|
|
if (isInSafeMode()) {
|
|
throw new SafeModeException("Cannot set replication for " + src, safeMode);
|
|
throw new SafeModeException("Cannot set replication for " + src, safeMode);
|
|
}
|
|
}
|
|
|
|
+ src = FSDirectory.resolvePath(src, pathComponents, dir);
|
|
if (isPermissionEnabled) {
|
|
if (isPermissionEnabled) {
|
|
checkPathAccess(pc, src, FsAction.WRITE);
|
|
checkPathAccess(pc, src, FsAction.WRITE);
|
|
}
|
|
}
|
|
@@ -1715,9 +1732,11 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
throws IOException, UnresolvedLinkException {
|
|
throws IOException, UnresolvedLinkException {
|
|
FSPermissionChecker pc = getPermissionChecker();
|
|
FSPermissionChecker pc = getPermissionChecker();
|
|
checkOperation(OperationCategory.READ);
|
|
checkOperation(OperationCategory.READ);
|
|
|
|
+ byte[][] pathComponents = FSDirectory.getPathComponentsForReservedPath(filename);
|
|
readLock();
|
|
readLock();
|
|
try {
|
|
try {
|
|
checkOperation(OperationCategory.READ);
|
|
checkOperation(OperationCategory.READ);
|
|
|
|
+ filename = FSDirectory.resolvePath(filename, pathComponents, dir);
|
|
if (isPermissionEnabled) {
|
|
if (isPermissionEnabled) {
|
|
checkTraverse(pc, filename);
|
|
checkTraverse(pc, filename);
|
|
}
|
|
}
|
|
@@ -1795,8 +1814,14 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
" minimum value (" + DFSConfigKeys.DFS_NAMENODE_MIN_BLOCK_SIZE_KEY
|
|
" minimum value (" + DFSConfigKeys.DFS_NAMENODE_MIN_BLOCK_SIZE_KEY
|
|
+ "): " + blockSize + " < " + minBlockSize);
|
|
+ "): " + blockSize + " < " + minBlockSize);
|
|
}
|
|
}
|
|
|
|
+ byte[][] pathComponents = FSDirectory.getPathComponentsForReservedPath(src);
|
|
writeLock();
|
|
writeLock();
|
|
try {
|
|
try {
|
|
|
|
+ checkOperation(OperationCategory.WRITE);
|
|
|
|
+ if (isInSafeMode()) {
|
|
|
|
+ throw new SafeModeException("Cannot create file" + src, safeMode);
|
|
|
|
+ }
|
|
|
|
+ src = FSDirectory.resolvePath(src, pathComponents, dir);
|
|
startFileInternal(pc, src, permissions, holder, clientMachine, flag,
|
|
startFileInternal(pc, src, permissions, holder, clientMachine, flag,
|
|
createParent, replication, blockSize);
|
|
createParent, replication, blockSize);
|
|
stat = dir.getFileInfo(src, false);
|
|
stat = dir.getFileInfo(src, false);
|
|
@@ -1838,10 +1863,6 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
AccessControlException, UnresolvedLinkException, FileNotFoundException,
|
|
AccessControlException, UnresolvedLinkException, FileNotFoundException,
|
|
ParentNotDirectoryException, IOException {
|
|
ParentNotDirectoryException, IOException {
|
|
assert hasWriteLock();
|
|
assert hasWriteLock();
|
|
- checkOperation(OperationCategory.WRITE);
|
|
|
|
- if (isInSafeMode()) {
|
|
|
|
- throw new SafeModeException("Cannot create file" + src, safeMode);
|
|
|
|
- }
|
|
|
|
// Verify that the destination does not exist as a directory already.
|
|
// Verify that the destination does not exist as a directory already.
|
|
boolean pathExists = dir.exists(src);
|
|
boolean pathExists = dir.exists(src);
|
|
if (pathExists && dir.isDir(src)) {
|
|
if (pathExists && dir.isDir(src)) {
|
|
@@ -1983,6 +2004,7 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
boolean skipSync = false;
|
|
boolean skipSync = false;
|
|
FSPermissionChecker pc = getPermissionChecker();
|
|
FSPermissionChecker pc = getPermissionChecker();
|
|
checkOperation(OperationCategory.WRITE);
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
|
+ byte[][] pathComponents = FSDirectory.getPathComponentsForReservedPath(src);
|
|
writeLock();
|
|
writeLock();
|
|
try {
|
|
try {
|
|
checkOperation(OperationCategory.WRITE);
|
|
checkOperation(OperationCategory.WRITE);
|
|
@@ -1990,6 +2012,7 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
throw new SafeModeException(
|
|
throw new SafeModeException(
|
|
"Cannot recover the lease of " + src, safeMode);
|
|
"Cannot recover the lease of " + src, safeMode);
|
|
}
|
|
}
|
|
|
|
+ src = FSDirectory.resolvePath(src, pathComponents, dir);
|
|
final INodeFile inode = INodeFile.valueOf(dir.getINode(src), src);
|
|
final INodeFile inode = INodeFile.valueOf(dir.getINode(src), src);
|
|
if (!inode.isUnderConstruction()) {
|
|
if (!inode.isUnderConstruction()) {
|
|
return true;
|
|
return true;
|
|
@@ -2107,6 +2130,11 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
throws AccessControlException, SafeModeException,
|
|
throws AccessControlException, SafeModeException,
|
|
FileAlreadyExistsException, FileNotFoundException,
|
|
FileAlreadyExistsException, FileNotFoundException,
|
|
ParentNotDirectoryException, IOException {
|
|
ParentNotDirectoryException, IOException {
|
|
|
|
+ if (NameNode.stateChangeLog.isDebugEnabled()) {
|
|
|
|
+ NameNode.stateChangeLog.debug("DIR* NameSystem.appendFile: src=" + src
|
|
|
|
+ + ", holder=" + holder
|
|
|
|
+ + ", clientMachine=" + clientMachine);
|
|
|
|
+ }
|
|
boolean skipSync = false;
|
|
boolean skipSync = false;
|
|
if (!supportAppends) {
|
|
if (!supportAppends) {
|
|
throw new UnsupportedOperationException(
|
|
throw new UnsupportedOperationException(
|
|
@@ -2125,8 +2153,14 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
LocatedBlock lb = null;
|
|
LocatedBlock lb = null;
|
|
FSPermissionChecker pc = getPermissionChecker();
|
|
FSPermissionChecker pc = getPermissionChecker();
|
|
checkOperation(OperationCategory.WRITE);
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
|
+ byte[][] pathComponents = FSDirectory.getPathComponentsForReservedPath(src);
|
|
writeLock();
|
|
writeLock();
|
|
try {
|
|
try {
|
|
|
|
+ checkOperation(OperationCategory.WRITE);
|
|
|
|
+ if (isInSafeMode()) {
|
|
|
|
+ throw new SafeModeException("Cannot append to file" + src, safeMode);
|
|
|
|
+ }
|
|
|
|
+ src = FSDirectory.resolvePath(src, pathComponents, dir);
|
|
lb = startFileInternal(pc, src, null, holder, clientMachine,
|
|
lb = startFileInternal(pc, src, null, holder, clientMachine,
|
|
EnumSet.of(CreateFlag.APPEND),
|
|
EnumSet.of(CreateFlag.APPEND),
|
|
false, blockManager.maxReplication, 0);
|
|
false, blockManager.maxReplication, 0);
|
|
@@ -2190,9 +2224,11 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
|
|
|
|
// Part I. Analyze the state of the file with respect to the input data.
|
|
// Part I. Analyze the state of the file with respect to the input data.
|
|
checkOperation(OperationCategory.READ);
|
|
checkOperation(OperationCategory.READ);
|
|
|
|
+ byte[][] pathComponents = FSDirectory.getPathComponentsForReservedPath(src);
|
|
readLock();
|
|
readLock();
|
|
try {
|
|
try {
|
|
checkOperation(OperationCategory.READ);
|
|
checkOperation(OperationCategory.READ);
|
|
|
|
+ src = FSDirectory.resolvePath(src, pathComponents, dir);
|
|
LocatedBlock[] onRetryBlock = new LocatedBlock[1];
|
|
LocatedBlock[] onRetryBlock = new LocatedBlock[1];
|
|
final INode[] inodes = analyzeFileState(
|
|
final INode[] inodes = analyzeFileState(
|
|
src, fileId, clientName, previous, onRetryBlock).getINodes();
|
|
src, fileId, clientName, previous, onRetryBlock).getINodes();
|
|
@@ -2370,7 +2406,7 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
}
|
|
}
|
|
|
|
|
|
/** @see NameNode#getAdditionalDatanode(String, ExtendedBlock, DatanodeInfo[], DatanodeInfo[], int, String) */
|
|
/** @see NameNode#getAdditionalDatanode(String, ExtendedBlock, DatanodeInfo[], DatanodeInfo[], int, String) */
|
|
- LocatedBlock getAdditionalDatanode(final String src, final ExtendedBlock blk,
|
|
|
|
|
|
+ LocatedBlock getAdditionalDatanode(String src, final ExtendedBlock blk,
|
|
final DatanodeInfo[] existings, final HashMap<Node, Node> excludes,
|
|
final DatanodeInfo[] existings, final HashMap<Node, Node> excludes,
|
|
final int numAdditionalNodes, final String clientName
|
|
final int numAdditionalNodes, final String clientName
|
|
) throws IOException {
|
|
) throws IOException {
|
|
@@ -2381,6 +2417,7 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
final long preferredblocksize;
|
|
final long preferredblocksize;
|
|
final List<DatanodeDescriptor> chosen;
|
|
final List<DatanodeDescriptor> chosen;
|
|
checkOperation(OperationCategory.READ);
|
|
checkOperation(OperationCategory.READ);
|
|
|
|
+ byte[][] pathComponents = FSDirectory.getPathComponentsForReservedPath(src);
|
|
readLock();
|
|
readLock();
|
|
try {
|
|
try {
|
|
checkOperation(OperationCategory.READ);
|
|
checkOperation(OperationCategory.READ);
|
|
@@ -2389,6 +2426,7 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
throw new SafeModeException("Cannot add datanode; src=" + src
|
|
throw new SafeModeException("Cannot add datanode; src=" + src
|
|
+ ", blk=" + blk, safeMode);
|
|
+ ", blk=" + blk, safeMode);
|
|
}
|
|
}
|
|
|
|
+ src = FSDirectory.resolvePath(src, pathComponents, dir);
|
|
|
|
|
|
//check lease
|
|
//check lease
|
|
final INodeFileUnderConstruction file = checkLease(src, clientName);
|
|
final INodeFileUnderConstruction file = checkLease(src, clientName);
|
|
@@ -2428,6 +2466,7 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
+ "of file " + src);
|
|
+ "of file " + src);
|
|
}
|
|
}
|
|
checkOperation(OperationCategory.WRITE);
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
|
+ byte[][] pathComponents = FSDirectory.getPathComponentsForReservedPath(src);
|
|
writeLock();
|
|
writeLock();
|
|
try {
|
|
try {
|
|
checkOperation(OperationCategory.WRITE);
|
|
checkOperation(OperationCategory.WRITE);
|
|
@@ -2435,6 +2474,8 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
throw new SafeModeException("Cannot abandon block " + b +
|
|
throw new SafeModeException("Cannot abandon block " + b +
|
|
" for fle" + src, safeMode);
|
|
" for fle" + src, safeMode);
|
|
}
|
|
}
|
|
|
|
+ src = FSDirectory.resolvePath(src, pathComponents, dir);
|
|
|
|
+
|
|
//
|
|
//
|
|
// Remove the block from the pending creates list
|
|
// Remove the block from the pending creates list
|
|
//
|
|
//
|
|
@@ -2506,10 +2547,16 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
checkBlock(last);
|
|
checkBlock(last);
|
|
boolean success = false;
|
|
boolean success = false;
|
|
checkOperation(OperationCategory.WRITE);
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
|
+ byte[][] pathComponents = FSDirectory.getPathComponentsForReservedPath(src);
|
|
writeLock();
|
|
writeLock();
|
|
try {
|
|
try {
|
|
- success = completeFileInternal(src, holder,
|
|
|
|
- ExtendedBlock.getLocalBlock(last));
|
|
|
|
|
|
+ checkOperation(OperationCategory.WRITE);
|
|
|
|
+ if (isInSafeMode()) {
|
|
|
|
+ throw new SafeModeException("Cannot complete file " + src, safeMode);
|
|
|
|
+ }
|
|
|
|
+ src = FSDirectory.resolvePath(src, pathComponents, dir);
|
|
|
|
+ success = completeFileInternal(src, holder,
|
|
|
|
+ ExtendedBlock.getLocalBlock(last));
|
|
} finally {
|
|
} finally {
|
|
writeUnlock();
|
|
writeUnlock();
|
|
}
|
|
}
|
|
@@ -2523,11 +2570,6 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
String holder, Block last) throws SafeModeException,
|
|
String holder, Block last) throws SafeModeException,
|
|
UnresolvedLinkException, IOException {
|
|
UnresolvedLinkException, IOException {
|
|
assert hasWriteLock();
|
|
assert hasWriteLock();
|
|
- checkOperation(OperationCategory.WRITE);
|
|
|
|
- if (isInSafeMode()) {
|
|
|
|
- throw new SafeModeException("Cannot complete file " + src, safeMode);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
INodeFileUnderConstruction pendingFile;
|
|
INodeFileUnderConstruction pendingFile;
|
|
try {
|
|
try {
|
|
pendingFile = checkLease(src, holder);
|
|
pendingFile = checkLease(src, holder);
|
|
@@ -2668,10 +2710,19 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
}
|
|
}
|
|
FSPermissionChecker pc = getPermissionChecker();
|
|
FSPermissionChecker pc = getPermissionChecker();
|
|
checkOperation(OperationCategory.WRITE);
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
|
+ byte[][] srcComponents = FSDirectory.getPathComponentsForReservedPath(src);
|
|
|
|
+ byte[][] dstComponents = FSDirectory.getPathComponentsForReservedPath(dst);
|
|
boolean status = false;
|
|
boolean status = false;
|
|
HdfsFileStatus resultingStat = null;
|
|
HdfsFileStatus resultingStat = null;
|
|
writeLock();
|
|
writeLock();
|
|
try {
|
|
try {
|
|
|
|
+ checkOperation(OperationCategory.WRITE);
|
|
|
|
+ if (isInSafeMode()) {
|
|
|
|
+ throw new SafeModeException("Cannot rename " + src, safeMode);
|
|
|
|
+ }
|
|
|
|
+ src = FSDirectory.resolvePath(src, srcComponents, dir);
|
|
|
|
+ dst = FSDirectory.resolvePath(dst, dstComponents, dir);
|
|
|
|
+ checkOperation(OperationCategory.WRITE);
|
|
status = renameToInternal(pc, src, dst);
|
|
status = renameToInternal(pc, src, dst);
|
|
if (status) {
|
|
if (status) {
|
|
resultingStat = getAuditFileInfo(dst, false);
|
|
resultingStat = getAuditFileInfo(dst, false);
|
|
@@ -2691,10 +2742,6 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
private boolean renameToInternal(FSPermissionChecker pc, String src, String dst)
|
|
private boolean renameToInternal(FSPermissionChecker pc, String src, String dst)
|
|
throws IOException, UnresolvedLinkException {
|
|
throws IOException, UnresolvedLinkException {
|
|
assert hasWriteLock();
|
|
assert hasWriteLock();
|
|
- checkOperation(OperationCategory.WRITE);
|
|
|
|
- if (isInSafeMode()) {
|
|
|
|
- throw new SafeModeException("Cannot rename " + src, safeMode);
|
|
|
|
- }
|
|
|
|
if (isPermissionEnabled) {
|
|
if (isPermissionEnabled) {
|
|
//We should not be doing this. This is move() not renameTo().
|
|
//We should not be doing this. This is move() not renameTo().
|
|
//but for now,
|
|
//but for now,
|
|
@@ -2725,9 +2772,17 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
}
|
|
}
|
|
FSPermissionChecker pc = getPermissionChecker();
|
|
FSPermissionChecker pc = getPermissionChecker();
|
|
checkOperation(OperationCategory.WRITE);
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
|
+ byte[][] srcComponents = FSDirectory.getPathComponentsForReservedPath(src);
|
|
|
|
+ byte[][] dstComponents = FSDirectory.getPathComponentsForReservedPath(dst);
|
|
HdfsFileStatus resultingStat = null;
|
|
HdfsFileStatus resultingStat = null;
|
|
writeLock();
|
|
writeLock();
|
|
try {
|
|
try {
|
|
|
|
+ checkOperation(OperationCategory.WRITE);
|
|
|
|
+ if (isInSafeMode()) {
|
|
|
|
+ throw new SafeModeException("Cannot rename " + src, safeMode);
|
|
|
|
+ }
|
|
|
|
+ src = FSDirectory.resolvePath(src, srcComponents, dir);
|
|
|
|
+ dst = FSDirectory.resolvePath(dst, dstComponents, dir);
|
|
renameToInternal(pc, src, dst, options);
|
|
renameToInternal(pc, src, dst, options);
|
|
resultingStat = getAuditFileInfo(dst, false);
|
|
resultingStat = getAuditFileInfo(dst, false);
|
|
} finally {
|
|
} finally {
|
|
@@ -2746,10 +2801,6 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
private void renameToInternal(FSPermissionChecker pc, String src, String dst,
|
|
private void renameToInternal(FSPermissionChecker pc, String src, String dst,
|
|
Options.Rename... options) throws IOException {
|
|
Options.Rename... options) throws IOException {
|
|
assert hasWriteLock();
|
|
assert hasWriteLock();
|
|
- checkOperation(OperationCategory.WRITE);
|
|
|
|
- if (isInSafeMode()) {
|
|
|
|
- throw new SafeModeException("Cannot rename " + src, safeMode);
|
|
|
|
- }
|
|
|
|
if (isPermissionEnabled) {
|
|
if (isPermissionEnabled) {
|
|
checkParentAccess(pc, src, FsAction.WRITE);
|
|
checkParentAccess(pc, src, FsAction.WRITE);
|
|
checkAncestorAccess(pc, dst, FsAction.WRITE);
|
|
checkAncestorAccess(pc, dst, FsAction.WRITE);
|
|
@@ -2810,12 +2861,14 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
BlocksMapUpdateInfo collectedBlocks = new BlocksMapUpdateInfo();
|
|
BlocksMapUpdateInfo collectedBlocks = new BlocksMapUpdateInfo();
|
|
FSPermissionChecker pc = getPermissionChecker();
|
|
FSPermissionChecker pc = getPermissionChecker();
|
|
checkOperation(OperationCategory.WRITE);
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
|
+ byte[][] pathComponents = FSDirectory.getPathComponentsForReservedPath(src);
|
|
writeLock();
|
|
writeLock();
|
|
try {
|
|
try {
|
|
checkOperation(OperationCategory.WRITE);
|
|
checkOperation(OperationCategory.WRITE);
|
|
if (isInSafeMode()) {
|
|
if (isInSafeMode()) {
|
|
throw new SafeModeException("Cannot delete " + src, safeMode);
|
|
throw new SafeModeException("Cannot delete " + src, safeMode);
|
|
}
|
|
}
|
|
|
|
+ src = FSDirectory.resolvePath(src, pathComponents, dir);
|
|
if (!recursive && dir.isNonEmptyDirectory(src)) {
|
|
if (!recursive && dir.isNonEmptyDirectory(src)) {
|
|
throw new IOException(src + " is non empty");
|
|
throw new IOException(src + " is non empty");
|
|
}
|
|
}
|
|
@@ -2942,9 +2995,14 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
HdfsFileStatus stat = null;
|
|
HdfsFileStatus stat = null;
|
|
FSPermissionChecker pc = getPermissionChecker();
|
|
FSPermissionChecker pc = getPermissionChecker();
|
|
checkOperation(OperationCategory.READ);
|
|
checkOperation(OperationCategory.READ);
|
|
|
|
+ if (!DFSUtil.isValidName(src)) {
|
|
|
|
+ throw new InvalidPathException("Invalid file name: " + src);
|
|
|
|
+ }
|
|
|
|
+ byte[][] pathComponents = FSDirectory.getPathComponentsForReservedPath(src);
|
|
readLock();
|
|
readLock();
|
|
try {
|
|
try {
|
|
checkOperation(OperationCategory.READ);
|
|
checkOperation(OperationCategory.READ);
|
|
|
|
+ src = FSDirectory.resolvePath(src, pathComponents, dir);
|
|
if (isPermissionEnabled) {
|
|
if (isPermissionEnabled) {
|
|
checkTraverse(pc, src);
|
|
checkTraverse(pc, src);
|
|
}
|
|
}
|
|
@@ -3009,10 +3067,16 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
}
|
|
}
|
|
FSPermissionChecker pc = getPermissionChecker();
|
|
FSPermissionChecker pc = getPermissionChecker();
|
|
checkOperation(OperationCategory.WRITE);
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
|
+ byte[][] pathComponents = FSDirectory.getPathComponentsForReservedPath(src);
|
|
HdfsFileStatus resultingStat = null;
|
|
HdfsFileStatus resultingStat = null;
|
|
boolean status = false;
|
|
boolean status = false;
|
|
writeLock();
|
|
writeLock();
|
|
try {
|
|
try {
|
|
|
|
+ checkOperation(OperationCategory.WRITE);
|
|
|
|
+ if (isInSafeMode()) {
|
|
|
|
+ throw new SafeModeException("Cannot create directory " + src, safeMode);
|
|
|
|
+ }
|
|
|
|
+ src = FSDirectory.resolvePath(src, pathComponents, dir);
|
|
status = mkdirsInternal(pc, src, permissions, createParent);
|
|
status = mkdirsInternal(pc, src, permissions, createParent);
|
|
if (status) {
|
|
if (status) {
|
|
resultingStat = dir.getFileInfo(src, false);
|
|
resultingStat = dir.getFileInfo(src, false);
|
|
@@ -3034,10 +3098,6 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
PermissionStatus permissions, boolean createParent)
|
|
PermissionStatus permissions, boolean createParent)
|
|
throws IOException, UnresolvedLinkException {
|
|
throws IOException, UnresolvedLinkException {
|
|
assert hasWriteLock();
|
|
assert hasWriteLock();
|
|
- checkOperation(OperationCategory.WRITE);
|
|
|
|
- if (isInSafeMode()) {
|
|
|
|
- throw new SafeModeException("Cannot create directory " + src, safeMode);
|
|
|
|
- }
|
|
|
|
if (isPermissionEnabled) {
|
|
if (isPermissionEnabled) {
|
|
checkTraverse(pc, src);
|
|
checkTraverse(pc, src);
|
|
}
|
|
}
|
|
@@ -3068,9 +3128,11 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
FileNotFoundException, UnresolvedLinkException, StandbyException {
|
|
FileNotFoundException, UnresolvedLinkException, StandbyException {
|
|
FSPermissionChecker pc = getPermissionChecker();
|
|
FSPermissionChecker pc = getPermissionChecker();
|
|
checkOperation(OperationCategory.READ);
|
|
checkOperation(OperationCategory.READ);
|
|
|
|
+ byte[][] pathComponents = FSDirectory.getPathComponentsForReservedPath(src);
|
|
readLock();
|
|
readLock();
|
|
try {
|
|
try {
|
|
checkOperation(OperationCategory.READ);
|
|
checkOperation(OperationCategory.READ);
|
|
|
|
+ src = FSDirectory.resolvePath(src, pathComponents, dir);
|
|
if (isPermissionEnabled) {
|
|
if (isPermissionEnabled) {
|
|
checkPermission(pc, src, false, null, null, null, FsAction.READ_EXECUTE);
|
|
checkPermission(pc, src, false, null, null, null, FsAction.READ_EXECUTE);
|
|
}
|
|
}
|
|
@@ -3084,6 +3146,8 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
* Set the namespace quota and diskspace quota for a directory.
|
|
* Set the namespace quota and diskspace quota for a directory.
|
|
* See {@link ClientProtocol#setQuota(String, long, long)} for the
|
|
* See {@link ClientProtocol#setQuota(String, long, long)} for the
|
|
* contract.
|
|
* contract.
|
|
|
|
+ *
|
|
|
|
+ * Note: This does not support ".inodes" relative path.
|
|
*/
|
|
*/
|
|
void setQuota(String path, long nsQuota, long dsQuota)
|
|
void setQuota(String path, long nsQuota, long dsQuota)
|
|
throws IOException, UnresolvedLinkException {
|
|
throws IOException, UnresolvedLinkException {
|
|
@@ -3113,12 +3177,14 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
throws IOException, UnresolvedLinkException {
|
|
throws IOException, UnresolvedLinkException {
|
|
NameNode.stateChangeLog.info("BLOCK* fsync: " + src + " for " + clientName);
|
|
NameNode.stateChangeLog.info("BLOCK* fsync: " + src + " for " + clientName);
|
|
checkOperation(OperationCategory.WRITE);
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
|
+ byte[][] pathComponents = FSDirectory.getPathComponentsForReservedPath(src);
|
|
writeLock();
|
|
writeLock();
|
|
try {
|
|
try {
|
|
checkOperation(OperationCategory.WRITE);
|
|
checkOperation(OperationCategory.WRITE);
|
|
if (isInSafeMode()) {
|
|
if (isInSafeMode()) {
|
|
throw new SafeModeException("Cannot fsync file " + src, safeMode);
|
|
throw new SafeModeException("Cannot fsync file " + src, safeMode);
|
|
}
|
|
}
|
|
|
|
+ src = FSDirectory.resolvePath(src, pathComponents, dir);
|
|
INodeFileUnderConstruction pendingFile = checkLease(src, clientName);
|
|
INodeFileUnderConstruction pendingFile = checkLease(src, clientName);
|
|
if (lastBlockLength > 0) {
|
|
if (lastBlockLength > 0) {
|
|
pendingFile.updateLengthOfLastBlock(lastBlockLength);
|
|
pendingFile.updateLengthOfLastBlock(lastBlockLength);
|
|
@@ -3463,9 +3529,11 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
DirectoryListing dl;
|
|
DirectoryListing dl;
|
|
FSPermissionChecker pc = getPermissionChecker();
|
|
FSPermissionChecker pc = getPermissionChecker();
|
|
checkOperation(OperationCategory.READ);
|
|
checkOperation(OperationCategory.READ);
|
|
|
|
+ byte[][] pathComponents = FSDirectory.getPathComponentsForReservedPath(src);
|
|
readLock();
|
|
readLock();
|
|
try {
|
|
try {
|
|
checkOperation(OperationCategory.READ);
|
|
checkOperation(OperationCategory.READ);
|
|
|
|
+ src = FSDirectory.resolvePath(src, pathComponents, dir);
|
|
|
|
|
|
if (isPermissionEnabled) {
|
|
if (isPermissionEnabled) {
|
|
if (dir.isDir(src)) {
|
|
if (dir.isDir(src)) {
|