synchronized(blockCache) { byte[] bitmap = getBlock(gdesc.getBlockBitmap());    synchronized( bitmap ) { BlockBitmap.freeBit( bitmap, index );  writeBlock(groupDescriptors[group].getBlockBitmap(), bitmap, false);  modifyFreeBlocksCount(group, 1); } } }
long iNodeTableBlock = groupDescriptors[group].getInodeTable(); long firstNonMetadataBlock = iNodeTableBlock + INodeTable.getSizeInBlocks(this);  if (blockNr < firstNonMetadataBlock) throw new FileSystemException( "Attempt to free a filesystem metadata block!");     synchronized (blockCache) { byte[] bitmap = getBlock(gdesc.getBlockBitmap());      synchronized (bitmap) { BlockBitmap.freeBit(bitmap, index);  writeBlock(groupDescriptors[group].getBlockBitmap(), bitmap, false);  modifyFreeBlocksCount(group, 1); } } }
	public void freeBlock(long blockNr) throws FileSystemException, IOException{		if(blockNr<0 || blockNr>=superblock.getBlocksCount())			throw new FileSystemException("Attempt to free nonexisting block ("+blockNr+")");					int group = translateToGroup(blockNr);		int index = translateToIndex(blockNr);		GroupDescriptor gdesc = groupDescriptors[group];				/* Throw an exception if an attempt is made to free up a filesystem metadata		 * block (the beginning of each block group is filesystem metadata):		 * superblock copy (if present)		 * block bitmap		 * inode bitmap		 * inode table		 * Free blocks begin after the inode table.		 */		long iNodeTableBlock = 	groupDescriptors[group].getInodeTable();		long firstNonMetadataBlock = iNodeTableBlock + INodeTable.getSizeInBlocks(this);		 		if(blockNr<firstNonMetadataBlock)			throw new FileSystemException("Attempt to free a filesystem metadata block!");		//synchronize to the blockCache to avoid flushing the block between reading it		//and synchronizing to it		synchronized(blockCache) {			byte[] bitmap = getBlock(gdesc.getBlockBitmap());						//at any time, only one copy of the Block exists in the cache, so it is			//safe to synchronize to the bitmapBlock object (it's part of Block)			synchronized( bitmap ) {				BlockBitmap.freeBit( bitmap, index );				//update the bitmap block				writeBlock(groupDescriptors[group].getBlockBitmap(), bitmap, false);				//gdesc.setFreeBlocksCount(gdesc.getFreeBlocksCount()+1);				modifyFreeBlocksCount(group, 1);			}		}	}