diff options
author | Lukas Czerner <lczerner@redhat.com> | 2011-09-15 23:44:59 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2011-09-15 23:49:20 -0400 |
commit | d2bfdc7ff15ce7b6b40c087021528ce190ef43c3 (patch) | |
tree | ea82b4878bc41543066c26592db48e7a186b65c8 /misc | |
parent | c859cb1de0d624caa0779fb17d1a53766143136e (diff) | |
download | e2fsprogs-d2bfdc7ff15ce7b6b40c087021528ce190ef43c3.tar.gz |
e2fsprogs: Use punch hole as "discard" on regular files
If e2fsprogs tools (mke2fs, e2fsck) is run on regular file instead of
on block device, we can use punch hole instead of regular discard
command which would not work on regular file anyway. This gives us
several advantages. First of all when e2fsck is run with '-E discard'
parameter it will punch out all ununsed space from the image, hence
trimming down the file system image. And secondly, when creating an
file system on regular file (with '-E discard' which is default), we
can use punch hole to clear the file content, hence we can skip inode
table initialization, because reads from sparse area returns zeros. This
will result in faster file system creation (without the need to specify
lazy_itable_init) and smaller images.
This commit also fixes some tests that would fail due to mke2fs showing
discard progress, hence the output would differ.
Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'misc')
-rw-r--r-- | misc/mke2fs.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/misc/mke2fs.c b/misc/mke2fs.c index 63538cd9..abcfbf02 100644 --- a/misc/mke2fs.c +++ b/misc/mke2fs.c @@ -2077,12 +2077,18 @@ static int mke2fs_discard_device(ext2_filsys fs) struct ext2fs_numeric_progress_struct progress; blk64_t blocks = ext2fs_blocks_count(fs->super); blk64_t count = DISCARD_STEP_MB; - blk64_t cur = 0; + blk64_t cur; int retval = 0; - retval = io_channel_discard(fs->io, 0, 0); + /* + * Let's try if discard really works on the device, so + * we do not print numeric progress resulting in failure + * afterwards. + */ + retval = io_channel_discard(fs->io, 0, fs->blocksize); if (retval) return retval; + cur = fs->blocksize; count *= (1024 * 1024); count /= fs->blocksize; |