From 22163eb51b682afe969f9381d56315dade874ec1 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 19 Mar 2021 22:25:09 +0100 Subject: [PATCH] repart: handle DISCARD failing with EBUSY gracefully --- src/partition/repart.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/partition/repart.c b/src/partition/repart.c index ac6e4e7f86..351b3d1b5e 100644 --- a/src/partition/repart.c +++ b/src/partition/repart.c @@ -2269,6 +2269,11 @@ static int context_discard_partition(Context *context, Partition *p) { log_info("Storage does not support discard, not discarding data in future partition %" PRIu64 ".", p->partno); return 0; } + if (r == -EBUSY) { + /* Let's handle this gracefully: https://bugzilla.kernel.org/show_bug.cgi?id=211167 */ + log_info("Block device is busy, not discarding partition %" PRIu64 " because it probably is mounted.", p->partno); + return 0; + } if (r == 0) { log_info("Partition %" PRIu64 " too short for discard, skipping.", p->partno); return 0; -- 2.25.1