code: public void updateBlock(int namespaceId, Block oldblock, Block newblock) throws IOException {
      if (oldblock.getBlockId() != newblock.getBlockId()) {
        throw new IOException("Cannot update oldblock (=" + oldblock
            + ") to newblock (=" + newblock + ").");
      }
  
      // Protect against a straggler updateblock call moving a block backwards
      // in time.
      boolean isValidUpdate =
        (newblock.getGenerationStamp() > oldblock.getGenerationStamp()) ||
        (newblock.getGenerationStamp() == oldblock.getGenerationStamp() &&
         newblock.getNumBytes() == oldblock.getNumBytes());
  
      if (!isValidUpdate) {
        throw new IOException(
          "Cannot update oldblock=" + oldblock +
          " to newblock=" + newblock + " since generation stamps must " +
          "increase, or else length must not change.");
      }
  
      for(;;) {
        final List<Thread> threads = tryUpdateBlock(namespaceId, oldblock, newblock);
        if (threads == null) {
          DataNode.LOG.info("Updated Block: namespaceid: " + namespaceId + " oldBlock: "
              + oldblock + " newBlock: " + newblock);
          return;
        }
  
        DataNode.LOG.info("Waiting other threads to update block: namespaceid: "
            + namespaceId + " oldBlock: " + oldblock + " newBlock: " + newblock);
        interruptAndJoinThreads(threads);
      }
    }
docs: {@inheritDoc}