code: public synchronized void saveNamespace(boolean forUncompressed) 
        throws IOException {
      
      InjectionHandler
        .processEvent(InjectionEvent.FSIMAGE_STARTING_SAVE_NAMESPACE);
      
      if (editLog == null) {
        throw new IOException("editLog must be initialized");
      }
      storage.attemptRestoreRemovedStorage();
  
      InjectionHandler
        .processEvent(InjectionEvent.FSIMAGE_STARTING_SAVE_NAMESPACE);
      
      boolean editLogWasOpen = editLog.isOpen();
      
      if (editLogWasOpen) {
        editLog.endCurrentLogSegment(true);
      }
      long imageTxId = editLog.getLastWrittenTxId();
      try {    
        // for testing only - we will wait until interruption comes
        InjectionHandler
            .processEvent(InjectionEvent.FSIMAGE_CREATING_SAVER_THREADS);
        saveFSImageInAllDirs(imageTxId, forUncompressed);
        storage.writeAll();
      } finally {
        if (editLogWasOpen) {
          editLog.startLogSegment(imageTxId + 1, true);
          // Take this opportunity to note the current transaction.
          // Even if the namespace save was cancelled, this marker
          // is only used to determine what transaction ID is required
          // for startup. So, it doesn't hurt to update it unnecessarily.
          storage.writeTransactionIdFileToStorage(imageTxId + 1, this);
        }
        saveNamespaceContext.clear();
      }
      
    }
docs: Save the contents of the FS image to a new image file in each of the
  current storage directories.