From: Jakub Radtke <jakub.radtke@xxxxxxxxx> 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 <jakub.radtke@xxxxxxxxx> Change-Id: Icaced458f4a1dd7777fce60660b749301c8496e8 --- super-intel.c | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/super-intel.c b/super-intel.c index edb1c60e..eb5d39b9 100644 --- a/super-intel.c +++ b/super-intel.c @@ -9537,6 +9537,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) @@ -9961,7 +9994,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; } -- 2.26.2