diff options
author | Luca Boccassi <bluca@debian.org> | 2022-11-22 16:24:54 +0000 |
---|---|---|
committer | Luca Boccassi <luca.boccassi@gmail.com> | 2022-11-23 01:33:26 +0100 |
commit | 0dce448bbc97c861520c287b01d632b887442925 (patch) | |
tree | 5fbbf8abfcb75eb5ef99a2f23a610067997cbf35 /src/partition | |
parent | da403fd38ad56797cceef6986868f3a598dacb99 (diff) | |
download | systemd-0dce448bbc97c861520c287b01d632b887442925.tar.gz |
repart: respect --discard=no also for block devices
It's only used to avoid BLKDISCARD on individual partitions at the moment.
It can take a lot of time to run on very slow devices, so avoid it for
them too.
Diffstat (limited to 'src/partition')
-rw-r--r-- | src/partition/repart.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/partition/repart.c b/src/partition/repart.c index 5beba69f3f..e23a0c3350 100644 --- a/src/partition/repart.c +++ b/src/partition/repart.c @@ -4618,13 +4618,15 @@ static int context_write_partition_table( log_info("Wiped block device."); - r = context_discard_range(context, 0, context->total); - if (r == -EOPNOTSUPP) - log_info("Storage does not support discard, not discarding entire block device data."); - else if (r < 0) - return log_error_errno(r, "Failed to discard entire block device: %m"); - else if (r > 0) - log_info("Discarded entire block device."); + if (arg_discard) { + r = context_discard_range(context, 0, context->total); + if (r == -EOPNOTSUPP) + log_info("Storage does not support discard, not discarding entire block device data."); + else if (r < 0) + return log_error_errno(r, "Failed to discard entire block device: %m"); + else if (r > 0) + log_info("Discarded entire block device."); + } } r = fdisk_get_partitions(context->fdisk_context, &original_table); |