code: private static long getAndUpdateLastInodeId(FSDirectory fsDir, 
        long inodeIdFromOp, int logVersion) throws IOException {
      long inodeId = inodeIdFromOp;
      if (inodeId == INodeId.GRANDFATHER_INODE_ID) {
        // This id is read from old edit log
        if (LayoutVersion.supports(Feature.ADD_INODE_ID, logVersion)) {
          throw new IOException("The layout version " + logVersion
              + " supports inodeId but gave bogus inodeId");
        }
        inodeId = fsDir.allocateNewInodeId();
      } else {
        // need to reset lastInodeId. fsdir gets lastInodeId firstly from
        // fsimage but editlog captures more recent inodeId allocations
        if (inodeId > fsDir.getLastInodeId()) {
          fsDir.resetLastInodeId(inodeId);
        }
      }
      return inodeId;
    }
docs: Allocate inode id for legacy edit log, or generate inode id for new edit log,
  and update lastInodeId in {@link FSDirectory}
  Also doing some sanity check
  
  @param fsDir {@link FSDirectory}
  @param inodeIdFromOp inode id read from edit log
  @param logVersion current layout version
  @param lastInodeId the latest inode id in the system
  @return inode id
  @throws IOException When invalid inode id in layout that supports inode id.