* [RFC] [PATCH] reiser4progs: add discard support to mkfs.reiser4.
@ 2014-05-08 19:15 Ivan Shapovalov
2014-05-08 19:15 ` [RFC] [PATCH] mkfs: implement discarding device at filesystem creation time Ivan Shapovalov
0 siblings, 1 reply; 2+ messages in thread
From: Ivan Shapovalov @ 2014-05-08 19:15 UTC (permalink / raw)
To: reiserfs-devel; +Cc: Ivan Shapovalov
This uses libaal's discard device operation to erase the destination device
before creating the filesystem on that device.
Ivan Shapovalov (1):
mkfs: implement discarding device at filesystem creation time.
progs/mkfs/mkfs.c | 33 +++++++++++++++++++++++++++++----
1 file changed, 29 insertions(+), 4 deletions(-)
--
1.9.2
^ permalink raw reply [flat|nested] 2+ messages in thread
* [RFC] [PATCH] mkfs: implement discarding device at filesystem creation time.
2014-05-08 19:15 [RFC] [PATCH] reiser4progs: add discard support to mkfs.reiser4 Ivan Shapovalov
@ 2014-05-08 19:15 ` Ivan Shapovalov
0 siblings, 0 replies; 2+ messages in thread
From: Ivan Shapovalov @ 2014-05-08 19:15 UTC (permalink / raw)
To: reiserfs-devel; +Cc: Ivan Shapovalov
A new flag, -d/--discard, is used for that purpose. No discard support
auto-detection is performed.
---
progs/mkfs/mkfs.c | 33 +++++++++++++++++++++++++++++----
1 file changed, 29 insertions(+), 4 deletions(-)
diff --git a/progs/mkfs/mkfs.c b/progs/mkfs/mkfs.c
index 43437d4..7b9bdea 100644
--- a/progs/mkfs/mkfs.c
+++ b/progs/mkfs/mkfs.c
@@ -34,7 +34,8 @@ typedef enum mkfs_behav_flags {
BF_YES = 1 << 1,
BF_LOST = 1 << 2,
BF_SHOW_PARM = 1 << 3,
- BF_SHOW_PLUG = 1 << 4
+ BF_SHOW_PLUG = 1 << 4,
+ BF_DISCARD = 1 << 5
} mkfs_behav_flags_t;
/* Prints mkfs options */
@@ -62,7 +63,9 @@ static void mkfs_print_usage(char *name) {
" -V, --version prints current version.\n"
" -y, --yes assumes an answer 'yes' to all questions.\n"
" -f, --force makes mkfs to use whole disk, not\n"
- " block device or mounted partition.\n");
+ " block device or mounted partition.\n"
+ " -d, --discard tells mkfs to discard given device\n"
+ " before creating the filesystem.\n");
}
/* Initializes used by mkfs exception streams */
@@ -128,6 +131,7 @@ int main(int argc, char *argv[]) {
{"print-profile", no_argument, NULL, 'p'},
{"print-plugins", no_argument, NULL, 'l'},
{"override", required_argument, NULL, 'o'},
+ {"discard", no_argument, NULL, 'd'},
{0, 0, 0, 0}
};
@@ -146,7 +150,7 @@ int main(int argc, char *argv[]) {
memset(hint.label, 0, sizeof(hint.label));
/* Parsing parameters */
- while ((c = getopt_long(argc, argv, "hVyfb:U:L:splo:?",
+ while ((c = getopt_long(argc, argv, "hVyfb:U:L:splo:d?",
long_options, (int *)0)) != EOF)
{
switch (c) {
@@ -172,6 +176,9 @@ int main(int argc, char *argv[]) {
case 's':
flags |= BF_LOST;
break;
+ case 'd':
+ flags |= BF_DISCARD;
+ break;
case 'o':
aal_strncat(override, optarg,
aal_strlen(optarg));
@@ -440,7 +447,25 @@ int main(int argc, char *argv[]) {
goto error_free_device;
}
}
-
+
+ if (flags & BF_DISCARD) {
+ if (gauge) {
+ aal_gauge_rename(gauge, "Discarding %s ... ",
+ host_dev);
+ aal_gauge_touch(gauge);
+ }
+
+ if ((aal_device_discard(device, 0, dev_len) != 0)) {
+ aal_error("Failed to discard %s (%s).",
+ device->name, device->error);
+ /* discard is optional, don't fail the mkfs */
+ }
+
+ if (gauge) {
+ aal_gauge_done(gauge);
+ }
+ }
+
if (gauge) {
aal_gauge_rename(gauge, "Creating reiser4 on %s ... ",
host_dev);
--
1.9.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-05-08 19:15 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-08 19:15 [RFC] [PATCH] reiser4progs: add discard support to mkfs.reiser4 Ivan Shapovalov
2014-05-08 19:15 ` [RFC] [PATCH] mkfs: implement discarding device at filesystem creation time Ivan Shapovalov
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).