From ccfc09f79b8d7ba15798a2b6f76545bb7fa3681e Mon Sep 17 00:00:00 2001 From: Peter Rajnoha Date: Fri, 30 Oct 2015 12:02:29 +0100 Subject: [PATCH] metadata: format_text: also count with calculated mda size of 0 When checking minimum mda size, make sure the mda_size after alignment and calculation is more than 0 - if there's no place for an MDA at the end of the disk, the _text_pv_add_metadata_area does not try to add it there and it returns (because we already have the MDA at the start of the disk at least). --- lib/format_text/format-text.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/format_text/format-text.c b/lib/format_text/format-text.c index 29e9bd2a7..d4f2c89fb 100644 --- a/lib/format_text/format-text.c +++ b/lib/format_text/format-text.c @@ -2241,13 +2241,13 @@ static int _text_pv_add_metadata_area(const struct format_type *fmt, FMTu64 ").", pv_dev_name(pv), mda_size, limit_name, limit); - if (mda_size < MDA_SIZE_MIN) { - log_error("Metadata area size too small. " - "It must be at least %u bytes.", MDA_SIZE_MIN); - goto bad; - } - if (mda_size) { + if (mda_size < MDA_SIZE_MIN) { + log_error("Metadata area size too small: %" PRIu64" bytes. " + "It must be at least %u bytes.", mda_size, MDA_SIZE_MIN); + goto bad; + } + /* Wipe metadata area with zeroes. */ if (!dev_set((struct device *) pv->dev, mda_start, (size_t) ((mda_size > wipe_size) ? -- 2.43.5