code: private ClientRWLock getBlockLock(long blockId) {
      // Loop until we either find the block lock in the mLocks map, or successfully acquire a new
      // block lock from the lock pool.
      while (true) {
        ClientRWLock blockLock;
        // Check whether a lock has already been allocated for the block id.
        synchronized (mSharedMapsLock) {
          blockLock = mLocks.get(blockId);
          if (blockLock != null) {
            blockLock.addReference();
            return blockLock;
          }
        }
        // Since a block lock hasn't already been allocated, try to acquire a new one from the pool.
        // Acquire the lock outside the synchronized section because #acquire might need to block.
        // We shouldn't wait indefinitely in acquire because the another lock for this block could be
        // allocated to another thread, in which case we could just use that lock.
        blockLock = mLockPool.acquire(1, TimeUnit.SECONDS);
        if (blockLock != null) {
          synchronized (mSharedMapsLock) {
            // Check if someone else acquired a block lock for blockId while we were acquiring one.
            if (mLocks.containsKey(blockId)) {
              mLockPool.release(blockLock);
              blockLock = mLocks.get(blockId);
            } else {
              mLocks.put(blockId, blockLock);
            }
            blockLock.addReference();
            return blockLock;
          }
        }
      }
    }
docs: Returns the block lock for the given block id, acquiring such a lock if it doesn't exist yet.
  
  If all locks have been allocated, this method will block until one can be acquired.
  
  @param blockId the block id to get the lock for
  @return the block lock