HDFS-7615. Remove longReadLock. Contributed by Kihwal Lee.
This commit is contained in:
parent
b6ff9c03a4
commit
44eed6cbc9
@ -520,6 +520,8 @@ Release 2.7.0 - UNRELEASED
|
|||||||
HDFS-7454. Reduce memory footprint for AclEntries in NameNode.
|
HDFS-7454. Reduce memory footprint for AclEntries in NameNode.
|
||||||
(Vinayakumar B via wheat9)
|
(Vinayakumar B via wheat9)
|
||||||
|
|
||||||
|
HDFS-7615. Remove longReadLock (kihwal)
|
||||||
|
|
||||||
BUG FIXES
|
BUG FIXES
|
||||||
|
|
||||||
HDFS-6741. Improve permission denied message when
|
HDFS-6741. Improve permission denied message when
|
||||||
|
@ -1465,47 +1465,20 @@ public void readLock() {
|
|||||||
this.fsLock.readLock().lock();
|
this.fsLock.readLock().lock();
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void longReadLockInterruptibly() throws InterruptedException {
|
|
||||||
this.fsLock.longReadLock().lockInterruptibly();
|
|
||||||
try {
|
|
||||||
this.fsLock.readLock().lockInterruptibly();
|
|
||||||
} catch (InterruptedException ie) {
|
|
||||||
// In the event we're interrupted while getting the normal FSNS read lock,
|
|
||||||
// release the long read lock.
|
|
||||||
this.fsLock.longReadLock().unlock();
|
|
||||||
throw ie;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void longReadUnlock() {
|
|
||||||
this.fsLock.readLock().unlock();
|
|
||||||
this.fsLock.longReadLock().unlock();
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void readUnlock() {
|
public void readUnlock() {
|
||||||
this.fsLock.readLock().unlock();
|
this.fsLock.readLock().unlock();
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void writeLock() {
|
public void writeLock() {
|
||||||
this.fsLock.longReadLock().lock();
|
|
||||||
this.fsLock.writeLock().lock();
|
this.fsLock.writeLock().lock();
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void writeLockInterruptibly() throws InterruptedException {
|
public void writeLockInterruptibly() throws InterruptedException {
|
||||||
this.fsLock.longReadLock().lockInterruptibly();
|
this.fsLock.writeLock().lockInterruptibly();
|
||||||
try {
|
|
||||||
this.fsLock.writeLock().lockInterruptibly();
|
|
||||||
} catch (InterruptedException ie) {
|
|
||||||
// In the event we're interrupted while getting the normal FSNS write
|
|
||||||
// lock, release the long read lock.
|
|
||||||
this.fsLock.longReadLock().unlock();
|
|
||||||
throw ie;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void writeUnlock() {
|
public void writeUnlock() {
|
||||||
this.fsLock.writeLock().unlock();
|
this.fsLock.writeLock().unlock();
|
||||||
this.fsLock.longReadLock().unlock();
|
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public boolean hasWriteLock() {
|
public boolean hasWriteLock() {
|
||||||
@ -7137,11 +7110,6 @@ public ReentrantReadWriteLock getFsLockForTests() {
|
|||||||
return fsLock.coarseLock;
|
return fsLock.coarseLock;
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
|
||||||
public ReentrantLock getLongReadLockForTests() {
|
|
||||||
return fsLock.longReadLock;
|
|
||||||
}
|
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
public ReentrantLock getCpLockForTests() {
|
public ReentrantLock getCpLockForTests() {
|
||||||
return cpLock;
|
return cpLock;
|
||||||
|
@ -34,24 +34,6 @@ class FSNamesystemLock implements ReadWriteLock {
|
|||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
protected ReentrantReadWriteLock coarseLock;
|
protected ReentrantReadWriteLock coarseLock;
|
||||||
|
|
||||||
/**
|
|
||||||
* When locking the FSNS for a read that may take a long time, we take this
|
|
||||||
* lock before taking the regular FSNS read lock. All writers also take this
|
|
||||||
* lock before taking the FSNS write lock. Regular (short) readers do not
|
|
||||||
* take this lock at all, instead relying solely on the synchronization of the
|
|
||||||
* regular FSNS lock.
|
|
||||||
*
|
|
||||||
* This scheme ensures that:
|
|
||||||
* 1) In the case of normal (fast) ops, readers proceed concurrently and
|
|
||||||
* writers are not starved.
|
|
||||||
* 2) In the case of long read ops, short reads are allowed to proceed
|
|
||||||
* concurrently during the duration of the long read.
|
|
||||||
*
|
|
||||||
* See HDFS-5064 for more context.
|
|
||||||
*/
|
|
||||||
@VisibleForTesting
|
|
||||||
protected final ReentrantLock longReadLock = new ReentrantLock(true);
|
|
||||||
|
|
||||||
FSNamesystemLock(boolean fair) {
|
FSNamesystemLock(boolean fair) {
|
||||||
this.coarseLock = new ReentrantReadWriteLock(fair);
|
this.coarseLock = new ReentrantReadWriteLock(fair);
|
||||||
}
|
}
|
||||||
@ -66,10 +48,6 @@ public Lock writeLock() {
|
|||||||
return coarseLock.writeLock();
|
return coarseLock.writeLock();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Lock longReadLock() {
|
|
||||||
return longReadLock;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getReadHoldCount() {
|
public int getReadHoldCount() {
|
||||||
return coarseLock.getReadHoldCount();
|
return coarseLock.getReadHoldCount();
|
||||||
}
|
}
|
||||||
|
@ -22,15 +22,6 @@ public interface RwLock {
|
|||||||
/** Acquire read lock. */
|
/** Acquire read lock. */
|
||||||
public void readLock();
|
public void readLock();
|
||||||
|
|
||||||
/**
|
|
||||||
* Acquire the long read lock, unless interrupted while waiting. The long
|
|
||||||
* read lock should also serve to block all concurrent writers.
|
|
||||||
**/
|
|
||||||
void longReadLockInterruptibly() throws InterruptedException;
|
|
||||||
|
|
||||||
/** Release the long read lock. */
|
|
||||||
public void longReadUnlock();
|
|
||||||
|
|
||||||
/** Release read lock. */
|
/** Release read lock. */
|
||||||
public void readUnlock();
|
public void readUnlock();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user