HDFS-5372. In FSNamesystem, hasReadLock() returns false if the current thread holds the write lock (Contributed by Vinay)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1543029 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Uma Maheswara Rao G 2013-11-18 13:56:39 +00:00
parent 27c0b5fb20
commit c155a5b368
4 changed files with 9 additions and 13 deletions

View File

@ -288,6 +288,9 @@ Release 2.2.1 - UNRELEASED
HDFS-5519. COMMIT handler should update the commit status after sync
(brandonli)
HDFS-5372. In FSNamesystem, hasReadLock() returns false if the current
thread holds the write lock (Vinaykumar B via umamahesh)
Release 2.2.0 - 2013-10-13
INCOMPATIBLE CHANGES

View File

@ -817,7 +817,7 @@ public class BlockManager {
final boolean isFileUnderConstruction, final long offset,
final long length, final boolean needBlockToken, final boolean inSnapshot)
throws IOException {
assert namesystem.hasReadOrWriteLock();
assert namesystem.hasReadLock();
if (blocks == null) {
return null;
} else if (blocks.length == 0) {

View File

@ -1265,11 +1265,7 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
}
@Override
public boolean hasReadLock() {
return this.fsLock.getReadHoldCount() > 0;
}
@Override
public boolean hasReadOrWriteLock() {
return hasReadLock() || hasWriteLock();
return this.fsLock.getReadHoldCount() > 0 || hasWriteLock();
}
public int getReadHoldCount() {
@ -2006,7 +2002,7 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
*/
private void verifyParentDir(String src) throws FileNotFoundException,
ParentNotDirectoryException, UnresolvedLinkException {
assert hasReadOrWriteLock();
assert hasReadLock();
Path parent = new Path(src).getParent();
if (parent != null) {
final INode parentNode = dir.getINode(parent.toString());
@ -2613,7 +2609,7 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
ExtendedBlock previous,
LocatedBlock[] onRetryBlock)
throws IOException {
assert hasReadOrWriteLock();
assert hasReadLock();
checkBlock(previous);
onRetryBlock[0] = null;
@ -2810,7 +2806,7 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
private INodeFileUnderConstruction checkLease(String src, long fileId,
String holder, INode inode) throws LeaseExpiredException,
FileNotFoundException {
assert hasReadOrWriteLock();
assert hasReadLock();
if (inode == null || !inode.isFile()) {
Lease lease = leaseManager.getLease(holder);
throw new LeaseExpiredException(
@ -3769,7 +3765,7 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
@Override
public boolean isInSnapshot(BlockInfoUnderConstruction blockUC) {
assert hasReadOrWriteLock();
assert hasReadLock();
final BlockCollection bc = blockUC.getBlockCollection();
if (bc == null || !(bc instanceof INodeFileUnderConstruction)) {
return false;

View File

@ -39,7 +39,4 @@ public interface RwLock {
/** Check if the current thread holds write lock. */
public boolean hasWriteLock();
/** Check if the current thread holds read or write lock. */
public boolean hasReadOrWriteLock();
}