From: Lennart Poettering Date: Thu, 30 Jul 2020 20:22:21 +0000 (+0200) Subject: repart: wipe partition first, then discard X-Git-Tag: v247-rc1~369^2~8 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f0cb1b951caeec68d4c892c7d02e6829f6f95a48;p=thirdparty%2Fsystemd.git repart: wipe partition first, then discard Wiping means writing zero sectors to disk. Hence it's better to do this before we discard, so that the zeroes we use to overwrite are properly discarded. If we'd do it the other way round we'd discard the data and then reallocte it just to write zeroes. --- diff --git a/src/partition/repart.c b/src/partition/repart.c index e8d6302296f..cbb10f74757 100644 --- a/src/partition/repart.c +++ b/src/partition/repart.c @@ -2193,17 +2193,15 @@ static int context_wipe_and_discard(Context *context, bool from_scratch) { if (!p->allocated_to_area) continue; - if (!from_scratch) { - r = context_discard_partition(context, p); - if (r < 0) - return r; - } - r = context_wipe_partition(context, p); if (r < 0) return r; if (!from_scratch) { + r = context_discard_partition(context, p); + if (r < 0) + return r; + r = context_discard_gap_after(context, p); if (r < 0) return r;