mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-01-22 22:03:43 +03:00
repart: if now minimal size is specified, default to 10M
Prompted by this discussion: https://lists.freedesktop.org/archives/systemd-devel/2020-June/044669.html
This commit is contained in:
parent
e031166e15
commit
fb08381c14
@ -292,7 +292,8 @@
|
||||
<varname>SizeMaxBytes=</varname>) otherwise. If the backing device does not provide enough space to
|
||||
fulfill the constraints placing the partition will fail. For partitions that shall be created,
|
||||
depending on the setting of <varname>Priority=</varname> (see above) the partition might be dropped
|
||||
and the placing algorithm restarted. By default no size constraints are set.</para></listitem>
|
||||
and the placing algorithm restarted. By default a minimum size constraint of 10M and no maximum size
|
||||
constraint is set.</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
|
@ -49,6 +49,12 @@
|
||||
#include "terminal-util.h"
|
||||
#include "utf8.h"
|
||||
|
||||
/* If not configured otherwise use a minimal partition size of 10M */
|
||||
#define DEFAULT_MIN_SIZE (10*1024*1024)
|
||||
|
||||
/* Hard lower limit for new partition sizes */
|
||||
#define HARD_MIN_SIZE 4096
|
||||
|
||||
/* Note: When growing and placing new partitions we always align to 4K sector size. It's how newer hard disks
|
||||
* are designed, and if everything is aligned to that performance is best. And for older hard disks with 512B
|
||||
* sector size devices were generally assumed to have an even number of sectors, hence at the worst we'll
|
||||
@ -322,7 +328,9 @@ static uint64_t partition_min_size(const Partition *p) {
|
||||
|
||||
/* Calculate the disk space we really need at minimum for this partition. If the partition already
|
||||
* exists the current size is what we really need. If it doesn't exist yet refuse to allocate less
|
||||
* than 4K. */
|
||||
* than 4K.
|
||||
*
|
||||
* DEFAULT_MIN_SIZE is the default SizeMin= we configure if nothing else is specified. */
|
||||
|
||||
if (PARTITION_IS_FOREIGN(p)) {
|
||||
/* Don't allow changing size of partitions not managed by us */
|
||||
@ -330,11 +338,8 @@ static uint64_t partition_min_size(const Partition *p) {
|
||||
return p->current_size;
|
||||
}
|
||||
|
||||
sz = p->current_size != UINT64_MAX ? p->current_size : 4096;
|
||||
if (p->size_min != UINT64_MAX)
|
||||
return MAX(p->size_min, sz);
|
||||
|
||||
return sz;
|
||||
sz = p->current_size != UINT64_MAX ? p->current_size : HARD_MIN_SIZE;
|
||||
return MAX(p->size_min == UINT64_MAX ? DEFAULT_MIN_SIZE : p->size_min, sz);
|
||||
}
|
||||
|
||||
static uint64_t partition_max_size(const Partition *p) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user