]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
mke2fs: Deprecate -K option, introduce discard/nodiscard
authorLukas Czerner <lczerner@redhat.com>
Thu, 18 Nov 2010 13:38:39 +0000 (14:38 +0100)
committerTheodore Ts'o <tytso@mit.edu>
Mon, 22 Nov 2010 18:00:11 +0000 (13:00 -0500)
It would be nice to have consistent "discard" options in every system
tool (mount, fsck, mkfs) taking advantage of discards. Also "discard"
and "nodiscard" is more descriptive instead of just "-K" and can be
easily defaulted and it is something we can not do with "-K".

With this commit you need to specify extended option like this:

./mke2fs -T <fstype> -E nodiscard <device>

in order make a filesystem without discarding the device first. And

./mke2fs -T <fstype> -E discard <device>

respectively.

-K option is with this commit deprecated and should not be used anymore.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
misc/mke2fs.8.in
misc/mke2fs.c

index b46e7e21c4ed2f0881c7a4a248797a7c976c4da1..c587d8104b3a743f5cc620cac9ba1c2e10b39972 100644 (file)
@@ -45,9 +45,6 @@ mke2fs \- create an ext2/ext3/ext4 filesystem
 .I journal-options
 ]
 [
-.B \-K
-]
-[
 .B \-N
 .I number-of-inodes
 ]
@@ -240,6 +237,17 @@ enable lazy inode table initialization.
 .B test_fs
 Set a flag in the filesystem superblock indicating that it may be
 mounted using experimental kernel code, such as the ext4dev filesystem.
+.TP
+.BI discard
+Attempt to discard blocks at mkfs time (discarding blocks initially is useful
+on solid state devices and sparse / thin-provisioned storage). When the device
+advertises that discard also zeroes data (any subsequent read after the discard
+and before write returns zero), then mark all not-yet-zeroed inode tables as
+zeroed. This significantly speeds up filesystem initialization. This is set
+as default.
+.TP
+.BI nodiscard
+Do not attempt to discard blocks at mkfs time. This is the default.
 .RE
 .TP
 .BI \-f " fragment-size"
@@ -369,10 +377,6 @@ and may be no more than 102,400 filesystem blocks.
 @JDEV@.BR size " or " device
 @JDEV@options can be given for a filesystem.
 .TP
-.BI \-K
-Keep, do not attempt to discard blocks at mkfs time (discarding blocks initially
-is useful on solid state devices and sparse / thin-provisioned storage).
-.TP
 .BI \-l " filename"
 Read the bad blocks list from
 .IR filename .
index 286f6ee43573e89091592feaeab4ddd011fa027e..ec4a810f3d187f2642259f25da8aac4a3b0ed335 100644 (file)
@@ -806,6 +806,10 @@ static void parse_extended_opts(struct ext2_super_block *param,
                                lazy_itable_init = strtoul(arg, &p, 0);
                        else
                                lazy_itable_init = 1;
+               } else if (!strcmp(token, "discard")) {
+                       discard = 1;
+               } else if (!strcmp(token, "nodiscard")) {
+                       discard = 0;
                } else {
                        r_usage++;
                        badopt = token;
@@ -821,7 +825,9 @@ static void parse_extended_opts(struct ext2_super_block *param,
                        "\tstripe-width=<RAID stride * data disks in blocks>\n"
                        "\tresize=<resize maximum size in blocks>\n"
                        "\tlazy_itable_init=<0 to disable, 1 to enable>\n"
-                       "\ttest_fs\n\n"),
+                       "\ttest_fs\n"
+                       "\tdiscard\n"
+                       "\tnodiscard\n\n"),
                        badopt ? badopt : "");
                free(buf);
                exit(1);
@@ -1301,6 +1307,10 @@ static void PRS(int argc, char *argv[])
                        parse_journal_opts(optarg);
                        break;
                case 'K':
+                       fprintf(stderr, _("Warning: -K option is deprecated and "
+                                         "should not be used anymore. Use "
+                                         "\'-E nodiscard\' extended option "
+                                         "instead!\n"));
                        discard = 0;
                        break;
                case 'j':