1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-01-07 17:17:44 +03:00

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.

(cherry picked from commit 0dce448bbc)
(cherry picked from commit d5e3625a61)
This commit is contained in:
Luca Boccassi 2022-11-22 16:24:54 +00:00 committed by Zbigniew Jędrzejewski-Szmek
parent e802dcf8bb
commit fd5fe6d834

View File

@ -3489,13 +3489,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);