public void downgradeEdgeToInode(Inode inode, LockMode mode) {
    Preconditions.checkState(!endsInInode());
    Preconditions.checkState(!mEntries.isEmpty());
    Preconditions.checkState(mLockMode == LockMode.WRITE);

    EdgeEntry last = (EdgeEntry) mEntries.get(mEntries.size() - 1);
    LockResource inodeLock = mInodeLockManager.lockInode(inode, mode);
    LockResource edgeLock = mInodeLockManager.lockEdge(last.mEdge, LockMode.READ);
    last.getLock().close();
    mEntries.set(mEntries.size() - 1, new EdgeEntry(edgeLock, last.getEdge()));
    mEntries.add(new InodeEntry(inodeLock, inode));
    mLockedInodes.add(inode);
    mLockMode = mode;
  }
public void downgradeEdgeToInode ( Inode inode , LockMode mode ) { Preconditions . checkState ( ! endsInInode ( ) ) ; Preconditions . checkState ( ! mEntries . isEmpty ( ) ) ; Preconditions . checkState ( mLockMode == LockMode . WRITE ) ; EdgeEntry last = ( EdgeEntry ) mEntries . get ( mEntries . size ( ) - 1 ) ; LockResource inodeLock = mInodeLockManager . lockInode ( inode , mode ) ; LockResource edgeLock = mInodeLockManager . lockEdge ( last . mEdge , LockMode . READ ) ; last . getLock ( ) . close ( ) ; mEntries . set ( mEntries . size ( ) - 1 , new EdgeEntry ( edgeLock , last . getEdge ( ) ) ) ; mEntries . add ( new InodeEntry ( inodeLock , inode ) ) ; mLockedInodes . add ( inode ) ; mLockMode = mode ; }
Downgrades from edge write-locking to inode write-locking. This reduces the scope of the write
lock by pushing it forward one entry.

For example, if the lock list is in write mode with entries [a, a->b, b, b->c],
downgradeEdgeToInode(c, mode) will change the list to [a, a->b, b, b->c, c], with b->c
downgraded to a read lock. c will be locked according to the mode.

The read lock on the final edge is taken before releasing the write lock.

@param inode the next inode in the lock list
@param mode the mode to downgrade to