aboutsummaryrefslogtreecommitdiff
path: root/misc/mke2fs.c
diff options
context:
space:
mode:
authorLukas Czerner <lczerner@redhat.com>2010-11-18 03:38:37 +0000
committerTheodore Ts'o <tytso@mit.edu>2010-11-22 20:41:46 -0500
commitd866599ab4955858b1541f0891b1b165ba66493a (patch)
tree8044870624bd8bc18a6ac26a3abef8f7064a0343 /misc/mke2fs.c
parente90a59ed434d6c5e38dd148aa4ba5b22b8f7eb24 (diff)
downloade2fsprogs-d866599ab4955858b1541f0891b1b165ba66493a.tar.gz
e2fsprogs: Add CHANNEL_FLAGS_DISCARD_ZEROES flag for io_manager
When the device have discard support and simultaneously discard zeroes data (and it is properly advertised), then we can take advantage of such behavior in several e2fsprogs tools. Add new flag CHANNEL_FLAGS_DISCARD_ZEROES for struct_io_channel so each io_manager can take advantage of this. The flag is properly set according to BLKDISCARDZEROES ioctl in unix_open. Also remove old mke2fs_discard_zeroes_data() function and substitute it with helper which test this flag. Signed-off-by: Lukas Czerner <lczerner@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'misc/mke2fs.c')
-rw-r--r--misc/mke2fs.c23
1 files changed, 1 insertions, 22 deletions
diff --git a/misc/mke2fs.c b/misc/mke2fs.c
index 01ad9bfa..0c30339e 100644
--- a/misc/mke2fs.c
+++ b/misc/mke2fs.c
@@ -1928,10 +1928,6 @@ static int mke2fs_setup_tdb(const char *name, io_manager *io_ptr)
#define BLKDISCARD _IO(0x12,119)
#endif
-#ifndef BLKDISCARDZEROES
-#define BLKDISCARDZEROES _IO(0x12,124)
-#endif
-
/*
* Return zero if the discard succeeds, and -1 if the discard fails.
*/
@@ -1966,23 +1962,6 @@ static int mke2fs_discard_blocks(ext2_filsys fs)
return ret;
}
-static int mke2fs_discard_zeroes_data(ext2_filsys fs)
-{
- int fd;
- int ret;
- int discard_zeroes_data = 0;
-
- fd = open64(fs->device_name, O_RDWR);
-
- if (fd > 0) {
- ioctl(fd, BLKDISCARDZEROES, &discard_zeroes_data);
- close(fd);
- }
- return discard_zeroes_data;
-}
-#else
-#define mke2fs_discard_blocks(fs) 1
-#define mke2fs_discard_zeroes_data(fs) 0
#endif
int main (int argc, char *argv[])
@@ -2047,7 +2026,7 @@ int main (int argc, char *argv[])
if (discard && (io_ptr != undo_io_manager)) {
retval = mke2fs_discard_blocks(fs);
- if (!retval && mke2fs_discard_zeroes_data(fs)) {
+ if (!retval && io_channel_discard_zeroes_data(fs->io)) {
if (verbose)
printf(_("Discard succeeded and will return 0s "
" - skipping inode table wipe\n"));