]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
repart: do not enforce 10M min size for immutable file systems by default
authorLennart Poettering <lennart@poettering.net>
Tue, 15 Jul 2025 12:06:08 +0000 (14:06 +0200)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 15 Jul 2025 13:58:27 +0000 (22:58 +0900)
src/repart/repart.c

index 352384bfc0d3216194efc44dd6e320b773b94542..181555ce3871b389fb56ef029b021f6f66edbbe9 100644 (file)
@@ -955,7 +955,7 @@ static uint64_t partition_fstype_min_size(const Context *c, const Partition *p)
 }
 
 static uint64_t partition_min_size(const Context *context, const Partition *p) {
-        uint64_t sz, override_min;
+        uint64_t sz;
 
         assert(context);
         assert(p);
@@ -997,9 +997,17 @@ static uint64_t partition_min_size(const Context *context, const Partition *p) {
                         sz = d;
         }
 
-        override_min = p->suppressing ? MAX(p->size_min, p->suppressing->size_min) : p->size_min;
+        uint64_t min_size = p->size_min;
+        if (p->suppressing && (min_size == UINT64_MAX || p->suppressing->size_min > min_size))
+                min_size = p->suppressing->size_min;
+
+        /* Default to 10M min size, except if the file system is read-only, in which case let's not enforce a
+         * minimum size, because even if we wanted to we couldn't take possession of the extra space
+         * allocated. */
+        if (min_size == UINT64_MAX)
+                min_size = (p->format && fstype_is_ro(p->format)) || p->verity != VERITY_OFF ? 1 : DEFAULT_MIN_SIZE;
 
-        return MAX(round_up_size(override_min != UINT64_MAX ? override_min : DEFAULT_MIN_SIZE, context->grain_size), sz);
+        return MAX(round_up_size(min_size, context->grain_size), sz);
 }
 
 static uint64_t partition_max_size(const Context *context, const Partition *p) {