From 5f13fb0a738aba5bd199b561cfc4bd2df9cd1eb7 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Tue, 15 Aug 2023 12:09:31 +0200 Subject: [PATCH 1/3] repart: Put function call closer to its error handling --- 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 7621d32a53..a9d5526700 100644 --- a/src/partition/repart.c +++ b/src/partition/repart.c @@ -2243,8 +2243,8 @@ static int context_load_partition_table(Context *context) { return log_oom(); if (arg_sector_size > 0) { - r = fdisk_save_user_sector_size(c, /* phy= */ 0, arg_sector_size); fs_secsz = arg_sector_size; + r = fdisk_save_user_sector_size(c, /* phy= */ 0, arg_sector_size); } else { uint32_t ssz; struct stat st; From b1110c81d8e943a8895a8a07ba84986a74b0943c Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Tue, 15 Aug 2023 12:10:14 +0200 Subject: [PATCH 2/3] mkfs-util: Don't set MKE2FS_DEVICE_PHYS_SECTSIZE We only care about the logical sector size and if the physical sector size isn't set and we're operating on a file, mke2fs will default the physical sector size to the logical block size anyway. This change makes sure that if we're operating on a block device and set an explicit logical sector size, that doesn't affect the physical sector size. --- src/shared/mkfs-util.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/shared/mkfs-util.c b/src/shared/mkfs-util.c index 3111bc0acc..b936a4733f 100644 --- a/src/shared/mkfs-util.c +++ b/src/shared/mkfs-util.c @@ -432,14 +432,13 @@ int make_filesystem( if (quiet && strv_extend(&argv, "-q") < 0) return log_oom(); - if (sector_size > 0) - FOREACH_STRING(s, "MKE2FS_DEVICE_SECTSIZE", "MKE2FS_DEVICE_PHYS_SECTSIZE") { - if (strv_extend(&env, s) < 0) + if (sector_size > 0) { + if (strv_extend(&env, "MKE2FS_DEVICE_SECTSIZE") < 0) return log_oom(); - if (strv_extendf(&env, "%"PRIu64, sector_size) < 0) - return log_oom(); - } + if (strv_extendf(&env, "%"PRIu64, sector_size) < 0) + return log_oom(); + } } else if (streq(fstype, "btrfs")) { argv = strv_new(mkfs, From 7bc6c028968942643eb7176d77f7347626cdd3be Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Tue, 15 Aug 2023 12:58:28 +0200 Subject: [PATCH 3/3] repart: Massage the minimize for XFS a bit A 1.5 multiplier doesn't seem to be sufficient for XFS as seen in mkosi CI. Let's increase it to 2 for XFS to hopefully get better results. --- src/partition/repart.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/partition/repart.c b/src/partition/repart.c index a9d5526700..4eced612b9 100644 --- a/src/partition/repart.c +++ b/src/partition/repart.c @@ -6107,7 +6107,8 @@ static int context_minimize(Context *context) { /* Massage the size a bit because just going by actual data used in the sparse file isn't * fool-proof. */ - fsz = round_up_size(fsz + (fsz / 2), context->grain_size); + uint64_t heuristic = streq(p->format, "xfs") ? fsz : fsz / 2; + fsz = round_up_size(fsz + heuristic, context->grain_size); if (minimal_size_by_fs_name(p->format) != UINT64_MAX) fsz = MAX(minimal_size_by_fs_name(p->format), fsz);