]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
repart: Add more logging
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 5 Apr 2023 17:36:05 +0000 (19:36 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Thu, 6 Apr 2023 07:45:46 +0000 (09:45 +0200)
src/partition/repart.c
src/shared/mkfs-util.c

index e4ae8a2c89fa23c0fa574d7a021e704fe58fc361..71c69569561f178dfb2b665ad35ad81fa15f6e45 100644 (file)
@@ -3963,6 +3963,8 @@ static int partition_populate_directory(Partition *p, Hashmap *denylist, char **
 
         assert(ret);
 
+        log_info("Populating %s filesystem.", p->format);
+
         r = var_tmp_dir(&vt);
         if (r < 0)
                 return log_error_errno(r, "Could not determine temporary directory: %m");
@@ -3983,6 +3985,8 @@ static int partition_populate_directory(Partition *p, Hashmap *denylist, char **
         if (r < 0)
                 return r;
 
+        log_info("Successfully populated %s filesystem.", p->format);
+
         *ret = TAKE_PTR(root);
         return 0;
 }
@@ -3993,7 +3997,7 @@ static int partition_populate_filesystem(Partition *p, const char *node, Hashmap
         assert(p);
         assert(node);
 
-        log_info("Populating %s filesystem with files.", p->format);
+        log_info("Populating %s filesystem.", p->format);
 
         /* We copy in a child process, since we have to mount the fs for that, and we don't want that fs to
          * appear in the host namespace. Hence we fork a child that has its own file system namespace and
@@ -4030,7 +4034,7 @@ static int partition_populate_filesystem(Partition *p, const char *node, Hashmap
                 _exit(EXIT_SUCCESS);
         }
 
-        log_info("Successfully populated %s filesystem with files.", p->format);
+        log_info("Successfully populated %s filesystem.", p->format);
         return 0;
 }
 
@@ -5436,6 +5440,7 @@ static int context_minimize(Context *context) {
                 _cleanup_(loop_device_unrefp) LoopDevice *d = NULL;
                 _cleanup_strv_free_ char **extra_mkfs_options = NULL;
                 _cleanup_close_ int fd = -EBADF;
+                _cleanup_free_ char *hint = NULL;
                 sd_id128_t fs_uuid;
                 uint64_t fsz;
 
@@ -5456,6 +5461,11 @@ static int context_minimize(Context *context) {
 
                 assert(!p->copy_blocks_path);
 
+                (void) partition_hint(p, context->node, &hint);
+
+                log_info("Pre-populating %s filesystem of partition %s twice to calculate minimal partition size",
+                         p->format, strna(hint));
+
                 r = make_copy_files_denylist(context, p, &denylist);
                 if (r < 0)
                         return r;
@@ -5513,6 +5523,14 @@ static int context_minimize(Context *context) {
                 /* Read-only filesystems are minimal from the first try because they create and size the
                  * loopback file for us. */
                 if (fstype_is_ro(p->format)) {
+                        struct stat st;
+
+                        if (stat(temp, &st) < 0)
+                                return log_error_errno(errno, "Failed to stat temporary file: %m");
+
+                        log_info("Minimal partition size of %s filesystem of partition %s is %s",
+                                 p->format, strna(hint), FORMAT_BYTES(st.st_size));
+
                         p->copy_blocks_path = TAKE_PTR(temp);
                         p->copy_blocks_path_is_our_file = true;
                         continue;
@@ -5546,6 +5564,9 @@ static int context_minimize(Context *context) {
                 if (minimal_size_by_fs_name(p->format) != UINT64_MAX)
                         fsz = MAX(minimal_size_by_fs_name(p->format), fsz);
 
+                log_info("Minimal partition size of %s filesystem of partition %s is %s",
+                         p->format, strna(hint), FORMAT_BYTES(fsz));
+
                 d = loop_device_unref(d);
 
                 /* Erase the previous filesystem first. */
index bfaa4d1b55b311aeed66f5ccee1e265f4f331ee4..16d2fb651fca2faea6822eaef1231e71e20c8a83 100644 (file)
@@ -479,6 +479,13 @@ int make_filesystem(
         if (extra_mkfs_args && strv_extend_strv(&argv, extra_mkfs_args, false) < 0)
                 return log_oom();
 
+        if (DEBUG_LOGGING) {
+                _cleanup_free_ char *j = NULL;
+
+                j = strv_join(argv, " ");
+                log_debug("Executing mkfs command: %s", strna(j));
+        }
+
         r = safe_fork_full(
                         "(mkfs)",
                         stdio_fds,