From: Jakub Radtke Date: Fri, 15 Jan 2021 05:46:57 +0000 (-0500) Subject: imsm: Adding a spare to an existing array with bitmap X-Git-Tag: mdadm-4.2-rc1~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=69d40de44b6b90c498323490b7310399a6833d0d;p=thirdparty%2Fmdadm.git imsm: Adding a spare to an existing array with bitmap When adding a spare to an existing array with bitmap, an additional initialization (adding bitmap header and preparing the bitmap area) is required. Signed-off-by: Jakub Radtke Signed-off-by: Jes Sorensen --- diff --git a/super-intel.c b/super-intel.c index 455bdd26..4284ddea 100644 --- a/super-intel.c +++ b/super-intel.c @@ -9526,6 +9526,39 @@ static int apply_size_change_update(struct imsm_update_size_change *u, return ret_val; } +static int prepare_spare_to_activate(struct supertype *st, + struct imsm_update_activate_spare *u) +{ + struct intel_super *super = st->sb; + int prev_current_vol = super->current_vol; + struct active_array *a; + int ret = 1; + + for (a = st->arrays; a; a = a->next) + /* + * Additional initialization (adding bitmap header, filling + * the bitmap area with '1's to force initial rebuild for a whole + * data-area) is required when adding the spare to the volume + * with write-intent bitmap. + */ + if (a->info.container_member == u->array && + a->info.consistency_policy == CONSISTENCY_POLICY_BITMAP) { + struct dl *dl; + + for (dl = super->disks; dl; dl = dl->next) + if (dl == u->dl) + break; + if (!dl) + break; + + super->current_vol = u->array; + if (st->ss->write_bitmap(st, dl->fd, NoUpdate)) + ret = 0; + super->current_vol = prev_current_vol; + } + return ret; +} + static int apply_update_activate_spare(struct imsm_update_activate_spare *u, struct intel_super *super, struct active_array *active_array) @@ -9950,7 +9983,9 @@ static void imsm_process_update(struct supertype *st, } case update_activate_spare: { struct imsm_update_activate_spare *u = (void *) update->buf; - if (apply_update_activate_spare(u, super, st->arrays)) + + if (prepare_spare_to_activate(st, u) && + apply_update_activate_spare(u, super, st->arrays)) super->updates_pending++; break; }