aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Sandeen <sandeen@redhat.com>2019-12-17 16:52:39 -0500
committerEric Sandeen <sandeen@redhat.com>2019-12-17 16:52:39 -0500
commit2383d7c5cf20efcff75cb29ca3e02cfbe1bf2209 (patch)
tree293c8157cd3beca96f36df7879f08f3e2075dbb1
parent7e8a6edb4d1ba0079152eb477abbbc1dfb1ebb7e (diff)
downloadxfsprogs-dev-2383d7c5cf20efcff75cb29ca3e02cfbe1bf2209.tar.gz
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>
-rw-r--r--mkfs/xfs_mkfs.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index 4bfdebf6f3..606f79dafc 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -1251,10 +1251,6 @@ discard_blocks(dev_t dev, uint64_t nsectors, int quiet)
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
@@ -1267,12 +1263,20 @@ discard_blocks(dev_t dev, uint64_t nsectors, int quiet)
* 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");
}