linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Biggers <ebiggers3@gmail.com>
To: linux-ext4@vger.kernel.org
Cc: Theodore Ts'o <tytso@mit.edu>, Eric Biggers <ebiggers@google.com>,
	"Darrick J . Wong" <darrick.wong@oracle.com>
Subject: [PATCH] misc: fix 'zero_hugefiles = false' regression
Date: Mon,  8 May 2017 15:47:57 -0700	[thread overview]
Message-ID: <20170508224757.94528-1-ebiggers3@gmail.com> (raw)

From: Eric Biggers <ebiggers@google.com>

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.

Fixes: 4f868703f6f2 ("libext2fs: use fallocate for creating journals and hugefiles")
Cc: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Biggers <ebiggers@google.com>
---
 misc/mk_hugefiles.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/misc/mk_hugefiles.c b/misc/mk_hugefiles.c
index 71a15c5d..049c6f41 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);
-- 
2.13.0.rc2.291.g57267f2277-goog

             reply	other threads:[~2017-05-08 22:48 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-08 22:47 Eric Biggers [this message]
2017-05-09  1:56 ` [PATCH] misc: fix 'zero_hugefiles = false' regression Darrick J. Wong
2017-05-09 16:36   ` Theodore Ts'o

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170508224757.94528-1-ebiggers3@gmail.com \
    --to=ebiggers3@gmail.com \
    --cc=darrick.wong@oracle.com \
    --cc=ebiggers@google.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=tytso@mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).