]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
repart: mention how long it took to copy in data blocks
authorLennart Poettering <lennart@poettering.net>
Fri, 10 Nov 2023 21:44:36 +0000 (22:44 +0100)
committerLennart Poettering <lennart@poettering.net>
Fri, 10 Nov 2023 21:53:49 +0000 (22:53 +0100)
This is quite interesting information, show it.

src/partition/repart.c

index a88d6ed68256a2e08379b944f499c76f59ff0a62..fc0ed48a542976019238a09a3c05208dd02cd922 100644 (file)
@@ -4277,6 +4277,8 @@ static int context_copy_blocks(Context *context) {
                 assert(p->copy_blocks_size != UINT64_MAX);
                 assert(p->new_size >= p->copy_blocks_size + (p->encrypt != ENCRYPT_OFF ? LUKS2_METADATA_KEEP_FREE : 0));
 
+                usec_t start_timestamp = now(CLOCK_MONOTONIC);
+
                 r = partition_target_prepare(context, p, p->new_size,
                                              /*need_path=*/ p->encrypt != ENCRYPT_OFF || p->siblings[VERITY_HASH],
                                              &t);
@@ -4311,6 +4313,14 @@ static int context_copy_blocks(Context *context) {
                 if (r < 0)
                         return r;
 
+                usec_t time_spent = usec_sub_unsigned(now(CLOCK_MONOTONIC), start_timestamp);
+                if (time_spent > 250 * USEC_PER_MSEC) /* Show throughput, but not if we spent too little time on it, since it's just noise then */
+                        log_info("Block level copying and synchronization of partition %" PRIu64 " complete in %s (%s/s).",
+                                 p->partno, FORMAT_TIMESPAN(time_spent, 0), FORMAT_BYTES((uint64_t) ((double) p->copy_blocks_size / time_spent * USEC_PER_SEC)));
+                else
+                        log_info("Block level copying and synchronization of partition %" PRIu64 " complete in %s.",
+                                 p->partno, FORMAT_TIMESPAN(time_spent, 0));
+
                 if (p->siblings[VERITY_HASH] && !partition_type_defer(&p->siblings[VERITY_HASH]->type)) {
                         r = partition_format_verity_hash(context, p->siblings[VERITY_HASH],
                                                          /* node = */ NULL, partition_target_path(t));