[PATCH] mkfs: tidy up discard notifications

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---

diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index 4bfdebf6..afa7feb4 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,8 +1263,16 @@ 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 (!quiet) {
+			if (offset != 0)
+				printf("\n");
 			return;
+		}
 
 		offset += tmp_step;
 	}




[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux