Uploaded image for project: 'Lustre'
  1. Lustre
  2. LU-13103

e2fsprogs has problem when calculation block number

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Minor
    • None
    • None
    • None
    • 3
    • 9223372036854775807

    Description

      static blkcnt_t blocks_from_inode(ext2_filsys fs,
      				  struct ext2_inode_large *inode)
      {
      	blkcnt_t b;
      
      	b = inode->i_blocks;
      	if (ext2fs_has_feature_huge_file(fs->super))
      		b += ((long long) inode->osd2.linux2.l_i_blocks_hi) << 32;
      
      	if (!ext2fs_has_feature_huge_file(fs->super) ||
      	    !(inode->i_flags & EXT4_HUGE_FILE_FL))
      		b *= fs->blocksize / 512;
      	b *= EXT2FS_CLUSTER_RATIO(fs);
      
      	return b;
      }
      

      This is wrong, it should be something like

      static blkcnt_t blocks_from_inode(ext2_filsys fs, struct ext2_inode *inode)
      {
      	blkcnt_t b;
      
      	b = inode->i_blocks;
      	if (ext2fs_has_feature_huge_file(fs->super)) {
      		b += ((long long) inode->osd2.linux2.l_i_blocks_hi) << 32;
      		if (inode->i_flags & EXT4_HUGE_FILE_FL)
      			b *= fs->blocksize / 512;
      	}
      	b *= EXT2FS_CLUSTER_RATIO(fs);
      
      	return b;
      }
      

      ext2fs_iblk_add_blocks(), ext2fs_iblk_sub_blocks() and ext2fs_iblk_set() has similar problems.

      Attachments

        Activity

          People

            wshilong Wang Shilong (Inactive)
            lixi_wc Li Xi
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: