Commit 3a3a5ddb7a0f43c3dd0f98673f3d930a456725f8

Authored by NeilBrown
1 parent da5cabf80e

Update recovery_offset even when external metadata is used.

The update of ->recovery_offset in sync_sbs is appropriate even then external
metadata is in use.  However sync_sbs is only called when native
metadata is used.

So move that update in to the top of md_update_sb (which is the only
caller of sync_sbs) before the test on ->external.

This moves the update out of ->write_lock protection, but those fields
only need ->reconfig_mutex protection which they still have.

Also move the test on ->persistent up to where ->external is set as
for metadata update purposes they are the same.

Clear MD_CHANGE_DEVS and MD_CHANGE_CLEAN as they can only be confusing
if ->external is set or ->persistent isn't.

Finally move the update of ->utime down as it is only relevent (like
the ->events update) for native metadata.

Signed-off-by: NeilBrown <neilb@suse.de>
Reported-by: "Kwolek, Adam" <adam.kwolek@intel.com>

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

... ... @@ -2136,17 +2136,7 @@
2136 2136 * with the rest of the array)
2137 2137 */
2138 2138 mdk_rdev_t *rdev;
2139   -
2140   - /* First make sure individual recovery_offsets are correct */
2141 2139 list_for_each_entry(rdev, &mddev->disks, same_set) {
2142   - if (rdev->raid_disk >= 0 &&
2143   - mddev->delta_disks >= 0 &&
2144   - !test_bit(In_sync, &rdev->flags) &&
2145   - mddev->curr_resync_completed > rdev->recovery_offset)
2146   - rdev->recovery_offset = mddev->curr_resync_completed;
2147   -
2148   - }
2149   - list_for_each_entry(rdev, &mddev->disks, same_set) {
2150 2140 if (rdev->sb_events == mddev->events ||
2151 2141 (nospares &&
2152 2142 rdev->raid_disk < 0 &&
2153 2143  
2154 2144  
... ... @@ -2167,12 +2157,27 @@
2167 2157 int sync_req;
2168 2158 int nospares = 0;
2169 2159  
2170   - mddev->utime = get_seconds();
2171   - if (mddev->external)
2172   - return;
2173 2160 repeat:
  2161 + /* First make sure individual recovery_offsets are correct */
  2162 + list_for_each_entry(rdev, &mddev->disks, same_set) {
  2163 + if (rdev->raid_disk >= 0 &&
  2164 + mddev->delta_disks >= 0 &&
  2165 + !test_bit(In_sync, &rdev->flags) &&
  2166 + mddev->curr_resync_completed > rdev->recovery_offset)
  2167 + rdev->recovery_offset = mddev->curr_resync_completed;
  2168 +
  2169 + }
  2170 + if (mddev->external || !mddev->persistent) {
  2171 + clear_bit(MD_CHANGE_DEVS, &mddev->flags);
  2172 + clear_bit(MD_CHANGE_CLEAN, &mddev->flags);
  2173 + wake_up(&mddev->sb_wait);
  2174 + return;
  2175 + }
  2176 +
2174 2177 spin_lock_irq(&mddev->write_lock);
2175 2178  
  2179 + mddev->utime = get_seconds();
  2180 +
2176 2181 set_bit(MD_CHANGE_PENDING, &mddev->flags);
2177 2182 if (test_and_clear_bit(MD_CHANGE_DEVS, &mddev->flags))
2178 2183 force_change = 1;
... ... @@ -2220,19 +2225,6 @@
2220 2225 */
2221 2226 MD_BUG();
2222 2227 mddev->events --;
2223   - }
2224   -
2225   - /*
2226   - * do not write anything to disk if using
2227   - * nonpersistent superblocks
2228   - */
2229   - if (!mddev->persistent) {
2230   - if (!mddev->external)
2231   - clear_bit(MD_CHANGE_PENDING, &mddev->flags);
2232   -
2233   - spin_unlock_irq(&mddev->write_lock);
2234   - wake_up(&mddev->sb_wait);
2235   - return;
2236 2228 }
2237 2229 sync_sbs(mddev, nospares);
2238 2230 spin_unlock_irq(&mddev->write_lock);