reiser4progs: add discard support to mkfs.reiser4.
RFC PATCH 1/1 reiser4progs: add discard support to mkfs.reiser4.
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(-)
Signature · 1 line
1.9.2
RFC PATCH 1/1 mkfs: implement discarding device at filesystem creation time.
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(-)
progs/mkfs/mkfs.c +29 -4
@@ -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);
Signature · 1 line
1.9.2