[PATCH 3/5] blkdiscard: don't report "zero range" at the end

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

 



From: Ruediger Meier <ruediger.meier@xxxxxxxxxxx>

We want to address the case that we have printed the last useful
stats line already within the loop. Avoiding an additional line
"Discarded 0 bytes ..." at the end.

Note there is a behavior change now for the edge cases "-v -l 0" and
"-v -o blksize" where we don't print any stats line anymore. But actually
it's correct, we never make any BLKDISCARD syscall with zero range.
Perhaps we should return error in these cases to help people who always
want to parse stats output on success.

CC: Federico Simoncelli <fsimonce@xxxxxxxxxx>
Signed-off-by: Ruediger Meier <ruediger.meier@xxxxxxxxxxx>
---
 sys-utils/blkdiscard.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys-utils/blkdiscard.c b/sys-utils/blkdiscard.c
index bb4bae6..f36e504 100644
--- a/sys-utils/blkdiscard.c
+++ b/sys-utils/blkdiscard.c
@@ -211,7 +211,7 @@ int main(int argc, char **argv)
 		}
 	}
 
-	if (verbose)
+	if (verbose && stats[1])
 		print_stats(path, stats);
 
 	close(fd);
-- 
1.8.4.5

--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux