synchronized void decrementSafeBlockCount(BlockInfo b) {
    assert namesystem.hasWriteLock();
    if (status == BMSafeModeStatus.OFF) {
      return;
    }

    final int safeNumberOfNodes = b.isStriped() ?
        ((BlockInfoStriped)b).getRealDataBlockNum() : safeReplication;
    BlockInfo storedBlock = blockManager.getStoredBlock(b);
    if (storedBlock.isComplete() &&
        blockManager.countNodes(b).liveReplicas() == safeNumberOfNodes - 1) {
      this.blockSafe--;
      assert blockSafe >= 0;
      checkSafeMode();
    }
  }
@Test(timeout = 30000)
  public void testDecrementSafeBlockCount() {
    bmSafeMode.activate(BLOCK_TOTAL);
    Whitebox.setInternalState(bmSafeMode, "extension", 0);

    mockBlockManagerForBlockSafeDecrement();
    setBlockSafe(BLOCK_THRESHOLD);
    for (long i = BLOCK_THRESHOLD; i > 0; i--) {
      BlockInfo blockInfo = mock(BlockInfo.class);
      bmSafeMode.decrementSafeBlockCount(blockInfo);

      assertEquals(i - 1, getblockSafe());
      assertTrue(bmSafeMode.isInSafeMode());
    }
  }