Browse Source

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.2@1543087 13f79535-47bb-0310-9956-ffa450edef68
Uma Maheswara Rao G 11 years ago
parent
commit
a7787314ea

+ 3 - 0
hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt

@@ -98,6 +98,9 @@ Release 2.2.1 - UNRELEASED
     HDFS-5469. Add configuration property for the sub-directroy export path
     HDFS-5469. Add configuration property for the sub-directroy export path
     (brandonli)
     (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
 Release 2.2.0 - 2013-10-13
 
 
   INCOMPATIBLE CHANGES
   INCOMPATIBLE CHANGES

+ 1 - 1
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManager.java

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

+ 4 - 8
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java

@@ -1253,11 +1253,7 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
   }
   }
   @Override
   @Override
   public boolean hasReadLock() {
   public boolean hasReadLock() {
-    return this.fsLock.getReadHoldCount() > 0;
-  }
-  @Override
-  public boolean hasReadOrWriteLock() {
-    return hasReadLock() || hasWriteLock();
+    return this.fsLock.getReadHoldCount() > 0 || hasWriteLock();
   }
   }
 
 
   NamespaceInfo getNamespaceInfo() {
   NamespaceInfo getNamespaceInfo() {
@@ -1990,7 +1986,7 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
    */
    */
   private void verifyParentDir(String src) throws FileNotFoundException,
   private void verifyParentDir(String src) throws FileNotFoundException,
       ParentNotDirectoryException, UnresolvedLinkException {
       ParentNotDirectoryException, UnresolvedLinkException {
-    assert hasReadOrWriteLock();
+    assert hasReadLock();
     Path parent = new Path(src).getParent();
     Path parent = new Path(src).getParent();
     if (parent != null) {
     if (parent != null) {
       final INode parentNode = dir.getINode(parent.toString());
       final INode parentNode = dir.getINode(parent.toString());
@@ -2588,7 +2584,7 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
                                 ExtendedBlock previous,
                                 ExtendedBlock previous,
                                 LocatedBlock[] onRetryBlock)
                                 LocatedBlock[] onRetryBlock)
           throws IOException  {
           throws IOException  {
-    assert hasReadOrWriteLock();
+    assert hasReadLock();
 
 
     checkBlock(previous);
     checkBlock(previous);
     onRetryBlock[0] = null;
     onRetryBlock[0] = null;
@@ -2785,7 +2781,7 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
   private INodeFileUnderConstruction checkLease(String src, long fileId,
   private INodeFileUnderConstruction checkLease(String src, long fileId,
       String holder, INode inode) throws LeaseExpiredException,
       String holder, INode inode) throws LeaseExpiredException,
       FileNotFoundException {
       FileNotFoundException {
-    assert hasReadOrWriteLock();
+    assert hasReadLock();
     if (inode == null || !inode.isFile()) {
     if (inode == null || !inode.isFile()) {
       Lease lease = leaseManager.getLease(holder);
       Lease lease = leaseManager.getLease(holder);
       throw new LeaseExpiredException(
       throw new LeaseExpiredException(

+ 0 - 3
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/util/RwLock.java

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