From: Eric Biggers Date: Mon, 8 May 2017 22:47:57 +0000 (-0700) Subject: misc: fix 'zero_hugefiles = false' regression X-Git-Tag: v1.43.5~56 X-Git-Url: https://git.whamcloud.com/gitweb?a=commitdiff_plain;h=e3d591eb1dfc6e03639171b120d48e8738deff04;p=tools%2Fe2fsprogs.git misc: fix 'zero_hugefiles = false' regression When mk_hugefiles() was switched to use ext2fs_fallocate(), it was accidentally changed to ignore the 'zero_hugefiles = false' setting, which should cause hugefiles to be allocated without initializing their contents. Fix this by only passing EXT2_FALLOCATE_ZERO_BLOCKS to ext2fs_fallocate() when zero_hugefiles is true. Google-Bug-Id: 38037607 Fixes: 4f868703f6f2 ("libext2fs: use fallocate for creating journals and hugefiles") Cc: Darrick J. Wong Signed-off-by: Eric Biggers Signed-off-by: Theodore Ts'o --- diff --git a/misc/mk_hugefiles.c b/misc/mk_hugefiles.c index 71a15c5..049c6f4 100644 --- a/misc/mk_hugefiles.c +++ b/misc/mk_hugefiles.c @@ -260,6 +260,7 @@ static errcode_t mk_hugefile(ext2_filsys fs, blk64_t num, { errcode_t retval; struct ext2_inode inode; + int falloc_flags; retval = ext2fs_new_inode(fs, 0, LINUX_S_IFREG, NULL, ino); if (retval) @@ -281,10 +282,11 @@ static errcode_t mk_hugefile(ext2_filsys fs, blk64_t num, if (ext2fs_has_feature_extents(fs->super)) inode.i_flags |= EXT4_EXTENTS_FL; - retval = ext2fs_fallocate(fs, - EXT2_FALLOCATE_FORCE_INIT | - EXT2_FALLOCATE_ZERO_BLOCKS, - *ino, &inode, goal, 0, num); + + falloc_flags = EXT2_FALLOCATE_FORCE_INIT; + if (zero_hugefile) + falloc_flags |= EXT2_FALLOCATE_ZERO_BLOCKS; + retval = ext2fs_fallocate(fs, falloc_flags, *ino, &inode, goal, 0, num); if (retval) return retval; retval = ext2fs_inode_size_set(fs, &inode, num * fs->blocksize);