From b7786df093dcbcb50f610318da0bc3df2fe5b87e Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 10 Nov 2023 22:44:36 +0100 Subject: [PATCH 1/4] repart: mention how long it took to copy in data blocks This is quite interesting information, show it. --- src/partition/repart.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/partition/repart.c b/src/partition/repart.c index a88d6ed6825..fc0ed48a542 100644 --- a/src/partition/repart.c +++ b/src/partition/repart.c @@ -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)); From a053f801f85190fb7dd608f7aa57df55cb6d9161 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 10 Nov 2023 22:45:02 +0100 Subject: [PATCH 2/4] repart: when we copy in blocks, indicate we are doing from an offset At first I thought when using --copy-from= that it was copying in my whole disk into a partition instead of just a partition into a partition. Let's make the log message clearer and say that we copy starting from an offset. --- src/partition/repart.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/partition/repart.c b/src/partition/repart.c index fc0ed48a542..d01fec63f58 100644 --- a/src/partition/repart.c +++ b/src/partition/repart.c @@ -4291,11 +4291,16 @@ static int context_copy_blocks(Context *context) { return r; } - log_info("Copying in '%s' (%s) on block level into future partition %" PRIu64 ".", - p->copy_blocks_path, FORMAT_BYTES(p->copy_blocks_size), p->partno); + if (p->copy_blocks_offset == UINT64_MAX) + log_info("Copying in '%s' (%s) on block level into future partition %" PRIu64 ".", + p->copy_blocks_path, FORMAT_BYTES(p->copy_blocks_size), p->partno); + else { + log_info("Copying in '%s' @ %" PRIu64 " (%s) on block level into future partition %" PRIu64 ".", + p->copy_blocks_path, p->copy_blocks_offset, FORMAT_BYTES(p->copy_blocks_size), p->partno); - if (p->copy_blocks_offset != UINT64_MAX && lseek(p->copy_blocks_fd, p->copy_blocks_offset, SEEK_SET) < 0) - return log_error_errno(errno, "Failed to seek to copy blocks offset in %s: %m", p->copy_blocks_path); + if (lseek(p->copy_blocks_fd, p->copy_blocks_offset, SEEK_SET) < 0) + return log_error_errno(errno, "Failed to seek to copy blocks offset in %s: %m", p->copy_blocks_path); + } r = copy_bytes(p->copy_blocks_fd, partition_target_fd(t), p->copy_blocks_size, COPY_REFLINK); if (r < 0) From acdf6bcfdb5c383d2eceedf07d96bf6a52a4ca83 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 10 Nov 2023 22:45:57 +0100 Subject: [PATCH 3/4] repart: say on which device we apply things So far we never mention the device in our output. Let's fix that. --- src/partition/repart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/partition/repart.c b/src/partition/repart.c index d01fec63f58..bbf10a96d36 100644 --- a/src/partition/repart.c +++ b/src/partition/repart.c @@ -5509,7 +5509,7 @@ static int context_write_partition_table(Context *context) { return 0; } - log_info("Applying changes."); + log_info("Applying changes to %s.", context->node); if (context->from_scratch && arg_empty != EMPTY_CREATE) { /* Erase everything if we operate from scratch, except if the image was just created anyway, and thus is definitely empty. */ From dc7e34b3693eed9cdb4fb49abc9cee2c5fdcc2c8 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 10 Nov 2023 22:46:19 +0100 Subject: [PATCH 4/4] repart: downgrade pcrlock pickup log message This is not relevant in most cases, hence don't mention this all the time. --- src/partition/repart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/partition/repart.c b/src/partition/repart.c index bbf10a96d36..d76732b349e 100644 --- a/src/partition/repart.c +++ b/src/partition/repart.c @@ -7038,7 +7038,7 @@ static int parse_argv(int argc, char *argv[]) { if (r != -ENOENT) log_warning_errno(r, "Search for pcrlock.json failed, assuming it does not exist: %m"); } else - log_info("Automatically using pcrlock policy '%s'.", arg_tpm2_pcrlock); + log_debug("Automatically using pcrlock policy '%s'.", arg_tpm2_pcrlock); } if (auto_public_key_pcr_mask) {