Attempting to free block 0 or a block that is already free has no
effect.
547026
final void freeBlock(long blockId) throws IOException {
        if (blockId == 0) {
            // Can't free block 0.
        }
        else {
            try {
                mFreeBlocksBitlist.lock().acquireWriteLock();
                mFreeBlocksBitlist.set(blockId);
                if (mFirstFreeBlock == 0 || blockId < mFirstFreeBlock) {
                    setFirstFreeBlock(blockId);
                }
            }
            catch (InterruptedException e) {
                throw new InterruptedIOException();
            }
            finally {
                mFreeBlocksBitlist.lock().releaseLock();
            }
        }
    }
126620
def lock(self, block=True):
		
		self._locked = True
		return self._lock.acquire(block)
1109851
@Override
    public void free(AllocationPoint point, AllocationStatus target) {
        //if (point.getAllocationStatus() == AllocationStatus.DEVICE)
        //deviceAllocations.get(point.getDeviceId()).remove(point.getObjectId());

        //zeroAllocations.get(point.getBucketId()).remove(point.getObjectId());
        if (point.getAllocationStatus() == AllocationStatus.DEVICE)
            deviceMemoryTracker.subFromAllocation(Thread.currentThread().getId(), point.getDeviceId(),
                            AllocationUtils.getRequiredMemory(point.getShape()));

        memoryProvider.free(point);
    }
379851
def acquire(self, block=True):
        """"""
        while True:
            # Try to set the lock
            if self.redis.set(self.name, self.value, px=self.timeout, nx=True):
                # It's ours until the timeout now
                return True
            # Lock is taken
            if not block:
                return False
            # If blocking, try again in a bit
            time.sleep(self.sleep)
159687
private boolean delBlockFromDisk(File blockFile, File metaFile, Block b) {
    if (blockFile == null) {
      DataNode.LOG.warn("No file exists for block: " + b);
      return true;
    }

    if (!blockFile.delete()) {
      DataNode.LOG.warn("Not able to delete the block file: " + blockFile);
      return false;
    } else { // remove the meta file
      if (metaFile != null && !metaFile.delete()) {
        DataNode.LOG.warn(
            "Not able to delete the meta block file: " + metaFile);
        return false;
      }
    }
    return true;
  }
801009
def unpersist(self, blocking=False):
        
        self.is_cached = False
        self._jdf.unpersist(blocking)
        return self
608078
def cancel(self, block=True):
        
        if self._consumer:
            self._consumer.cancel(block=block)
286728
private boolean isBlockFinalizedWithLock(int namespaceId, Block b) {
    lock.readLock().lock();
    try {
      return isBlockFinalizedInternal(namespaceId, b, true);
    } finally {
      lock.readLock().unlock();
    }
  }
1014800
void assignToBlock(BlockId blk) {
		internalLock.writeLock().lock();
		try {
			flush();
			this.blk = blk;
			contents.read(blk);
			pins = 0;
			lastLsn = LogSeqNum.readFromPage(contents, LAST_LSN_OFFSET);
		} finally {
			internalLock.writeLock().unlock();
		}
	}
758535
private void removeStoredBlock(Block block, DatanodeDescriptor node) {
    if (NameNode.stateChangeLog.isDebugEnabled()) {
      NameNode.stateChangeLog.debug("BLOCK* NameSystem.removeStoredBlock: "
        + block + " from " + node.getName());
    }
    if (!blocksMap.removeNode(block, node)) {
      if (NameNode.stateChangeLog.isDebugEnabled()) {
        NameNode.stateChangeLog.debug("BLOCK* NameSystem.removeStoredBlock: "
          + block + " has already been removed from node " + node);
      }
      return;
    }

    //
    // if file is being actively written to and it is the last block, 
    // then do not check replication-factor here.
    //
    BlockInfo storedBlock = blocksMap.getStoredBlock(block);
    INodeFile fileINode = (storedBlock == null) ? null : storedBlock.getINode();
    if (fileINode != null && 
        fileINode.isUnderConstruction() && fileINode.isLastBlock(storedBlock)) {
      decrementSafeBlockCount(block);
      return;
    }      

    //
    // It's possible that the block was removed because of a datanode
    // failure.  If the block is still valid, check if replication is
    // necessary.  In that case, put block on a possibly-will-
    // be-replicated list.
    //
    if (fileINode != null) {
      decrementSafeBlockCount(block);
      // handle under replication
      // Use storedBlock here because block maybe a deleted block with size DELETED
      if (isPopulatingReplQueuesInternal()) {
        NumberReplicas num = countNodes(storedBlock);
        int numCurrentReplicas = num.liveReplicas()
            +
        pendingReplications.getNumReplicas(storedBlock);
        updateNeededReplicationQueue(storedBlock, -1, numCurrentReplicas,
            num.decommissionedReplicas, node, 
            fileINode.getBlockReplication(storedBlock));
      }
    }

    //
    // We've removed a block from a node, so it's definitely no longer
    // in "excess" there.
    //
    removeFromExcessReplicateMap(block, node);

    // Remove the replica from corruptReplicas
    corruptReplicas.removeFromCorruptReplicasMap(block, node);
  }
825325
function cl_block(outs) {
    cl_hash(HSIZE);
    free_ent = ClearCode + 2;
    clear_flg = true;
    output(ClearCode, outs);
  }
1145317
void releaseBlock(BlockId blockId) throws IOException {
        synchronized (m_accessLock) {
            if (! m_blockPathMap.containsKey(blockId)) {
                throw new IllegalArgumentException("Request to release block that is not stored: " + blockId);
            }

            Path blockPath = m_blockPathMap.get(blockId);
            Files.delete(blockPath);
            m_blockPathMap.remove(blockId);
        }
    }
1325144
protected function deleteBlocks()
    {
        $blocks = $this->blockRepository->retrieveContentsBySlotName($this->slot->getSlotName());
        if (count($blocks) <= 0) {
            return null;
        }
        try {
            $result = null;

            $this->blockRepository->startTransaction();
            foreach ($blocks as $block) {
                $result = $this->blockRepository
                            ->setRepositoryObject($block)
                            ->delete();

                if(!$result) break;
            }

            if ($result) {
                $this->blockRepository->commit();
            } else {
                $this->blockRepository->rollBack();
            }

            return $result;
        } catch (\Exception $e) {
            if (isset($this->blockRepository) && $this->blockRepository !== null) {
                $this->blockRepository->rollBack();
            }

            throw $e;
        }
    }
541728
boolean remove(BlockInfo blockInfo, RaidCodec codec) {
    if(queues.get(codec).remove(blockInfo)) {
      if (NameNode.stateChangeLog.isDebugEnabled()) {
        NameNode.stateChangeLog.debug(
                                      "BLOCK* NameSystem.RaidMissingBlocks.remove:"
                                      + blockInfo
                                      + " file "+ blockInfo.getINode()
                                      + " codec " + codec.id);
      }
      return true;
    }
    return false;
  }
259106
private boolean continueBlock() throws IOException {
        byte lastByte = buffer[readPtr - 1];
        while(true) {
            if(maybeFlush()) return true;
            if(!hasFullBlock()) {
                refillBuffer();
                if(!hasFullBlock()) {
                    state = StateContinuePartialBlock;
                    return continueContinuePartialBlock(lastByte);
                }
            }
            int weakHash = rc.roll(lastByte, buffer[readPtr + blockSize - 1]);
            int blockNum = signatureTable.findBlock(weakHash, buffer, readPtr, blockSize);
            if(blockNum != -1) {
                writeBlock(blockNum, blockSize);
                state = StateNewBlock;
                return true;
            }
            lastByte = buffer[readPtr];
            readPtr += 1;
        }
    }
848086
def iterateBlocksBackFrom(block):
        
        count = 0
        while block.isValid() and count < MAX_SEARCH_OFFSET_LINES:
            yield block
            block = block.previous()
            count += 1
1141903
def remove_block(self, name):
        

        if not self._ast or not name in self._block_map:
            raise ValueError(u"Block '{0}' does not exist"
                             .format(common.from_utf8(name)))

        block_idx = self._block_map[name]

        # remove block
        self._ast[2].pop(block_idx)
        del self._block_map[name]