You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

53 lines
1.6 KiB

From 2383d7c5cf20efcff75cb29ca3e02cfbe1bf2209 Mon Sep 17 00:00:00 2001
From: Eric Sandeen <sandeen@redhat.com>
Date: Tue, 17 Dec 2019 16:52:39 -0500
Subject: [PATCH] mkfs: tidy up discard notifications
Only notify user of discard operations if the first one succeeds,
and be sure to print a trailing newline if we stop early.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
---
mkfs/xfs_mkfs.c | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
Index: xfsprogs-4.5.0/mkfs/xfs_mkfs.c
===================================================================
--- xfsprogs-4.5.0.orig/mkfs/xfs_mkfs.c
+++ xfsprogs-4.5.0/mkfs/xfs_mkfs.c
@@ -886,10 +886,6 @@ discard_blocks(dev_t dev, __uint64_t nse
fd = libxfs_device_to_fd(dev);
if (fd <= 0)
return;
- if (!quiet) {
- printf("Discarding blocks...");
- fflush(stdout);
- }
/* The block discarding happens in smaller batches so it can be
* interrupted prematurely
@@ -902,12 +898,20 @@ discard_blocks(dev_t dev, __uint64_t nse
* not necessary for the mkfs functionality but just an
* optimization. However we should stop on error.
*/
- if (platform_discard_blocks(fd, offset, tmp_step))
+ if (platform_discard_blocks(fd, offset, tmp_step) == 0) {
+ if (offset == 0 && !quiet) {
+ printf("Discarding blocks...");
+ fflush(stdout);
+ }
+ } else {
+ if (offset > 0 && !quiet)
+ printf("\n");
return;
+ }
offset += tmp_step;
}
- if (!quiet)
+ if (offset > 0 && !quiet)
printf("Done.\n");
}