Uploaded image for project: 'Hadoop HDFS'
  1. Hadoop HDFS
  2. HDFS-6423

Diskspace quota usage should be updated when appending data to partial block

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 2.5.0
    • namenode
    • None
    • Reviewed

    Description

      When appending new data to a file whose last block is a partial block, the diskspace quota usage is not correctly update. For example, suppose the block size is 1024 bytes, and a file has size 1536 bytes (1.5 blocks). If we then append another 1024 bytes to the file, the diskspace usage for this file will not be updated to (2560 * replication) as expected, but (2048 * replication).

      The cause of the issue is that in FSNamesystem#commitOrCompleteLastBlock, we have

          // Adjust disk space consumption if required
          final long diff = fileINode.getPreferredBlockSize() - commitBlock.getNumBytes();    
          if (diff > 0) {
            try {
              String path = fileINode.getFullPathName();
              dir.updateSpaceConsumed(path, 0, -diff*fileINode.getFileReplication());
            } catch (IOException e) {
              LOG.warn("Unexpected exception while updating disk space.", e);
            }
          }
      

      This code assumes that the last block of the file has never been completed before, thus is always counted with the preferred block size in quota computation.

      Attachments

        1. HDFS-6423.000.patch
          7 kB
          Jing Zhao
        2. HDFS-6423.001.patch
          8 kB
          Jing Zhao
        3. HDFS-6423.002.patch
          6 kB
          Jing Zhao

        Issue Links

          Activity

            People

              jingzhao Jing Zhao
              jingzhao Jing Zhao
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: