Commit 6dafab6b1383e912cd252fa809570b484eb6e0dc

Authored by NeilBrown
1 parent e5c86471f9

md: make sure metadata is updated when spares are activated or removed.

It isn't always necessary to update the metadata when spares are
removed as the presence-or-not of a spare isn't really important to
the integrity of an array.
Also activating a spare doesn't always require updating the metadata
as the update on 'recovery-completed' is usually sufficient.

However the introduction of 'replacement' devices have made these
transitions sometimes more important.  For example the 'Replacement'
flag isn't cleared until the original device is removed, so we need
to ensure a metadata update after that 'spare' is removed.

So set MD_CHANGE_DEVS whenever a spare is activated or removed, to
complement the current situation where it is set when a spare is added
or a device is failed (or a number of other less common situations).

This is suitable for -stable as out-of-data metadata could lead
to data corruption.
This is only relevant for 3.3 and later 9when 'replacement' as
introduced.

Cc: stable@vger.kernel.org
Signed-off-by: NeilBrown <neilb@suse.de>

Showing 1 changed file with 5 additions and 1 deletions Side-by-side Diff

... ... @@ -7619,6 +7619,8 @@
7619 7619 }
7620 7620 }
7621 7621 }
  7622 + if (removed)
  7623 + set_bit(MD_CHANGE_DEVS, &mddev->flags);
7622 7624 return spares;
7623 7625 }
7624 7626  
7625 7627  
... ... @@ -7632,9 +7634,11 @@
7632 7634 !test_bit(MD_RECOVERY_REQUESTED, &mddev->recovery)) {
7633 7635 /* success...*/
7634 7636 /* activate any spares */
7635   - if (mddev->pers->spare_active(mddev))
  7637 + if (mddev->pers->spare_active(mddev)) {
7636 7638 sysfs_notify(&mddev->kobj, NULL,
7637 7639 "degraded");
  7640 + set_bit(MD_CHANGE_DEVS, &mddev->flags);
  7641 + }
7638 7642 }
7639 7643 if (test_bit(MD_RECOVERY_RESHAPE, &mddev->recovery) &&
7640 7644 mddev->pers->finish_reshape)