From: Theodore Ts'o Date: Mon, 28 Feb 2011 01:09:54 +0000 (-0500) Subject: mke2fs: If the device supports discard, don't print an error message X-Git-Tag: v1.42-WIP-0702~47 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aa07cb79b0a38d9d8407c5631624ef8534bdde3f;p=thirdparty%2Fe2fsprogs.git mke2fs: If the device supports discard, don't print an error message Check to see if the device supports discard before starting the progress bar, and then printing an error about inappropriate ioctl for device (when creating a file system image to a file, for example). Also, add a function signature in the ext2_io.h header file for io_channel_discard() and fix an extra, uneeded argument in mke2fs's call to that function. Signed-off-by: "Theodore Ts'o" --- diff --git a/lib/ext2fs/ext2_io.h b/lib/ext2fs/ext2_io.h index ba97341b1..e71ada99d 100644 --- a/lib/ext2fs/ext2_io.h +++ b/lib/ext2fs/ext2_io.h @@ -117,6 +117,9 @@ extern errcode_t io_channel_read_blk64(io_channel channel, extern errcode_t io_channel_write_blk64(io_channel channel, unsigned long long block, int count, const void *data); +extern errcode_t io_channel_discard(io_channel channel, + unsigned long long block, + unsigned long long count); /* unix_io.c */ extern io_manager unix_io_manager; diff --git a/misc/mke2fs.c b/misc/mke2fs.c index 7866c2c1d..9798b888d 100644 --- a/misc/mke2fs.c +++ b/misc/mke2fs.c @@ -2015,6 +2015,10 @@ static int mke2fs_discard_device(ext2_filsys fs) blk64_t cur = 0; int retval = 0; + retval = io_channel_discard(fs->io, 0, 0); + if (retval) + return retval; + count *= (1024 * 1024); count /= fs->blocksize; @@ -2027,7 +2031,7 @@ static int mke2fs_discard_device(ext2_filsys fs) if (cur + count > blocks) count = blocks - cur; - retval = io_channel_discard(fs->io, cur, count, fs->blocksize); + retval = io_channel_discard(fs->io, cur, count); if (retval) break; cur += count;