[GIT PULL REQUEST] one last md update for 4.1

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[GIT PULL REQUEST] one last md update for 4.1

NeilBrown

Hasn't been a good cycle for md has it :-(
This pull request includes the fix for the hang I mentioned in my last
pull request, and another little bug.
4.2 should be much quieter

Thanks,
NeilBrown



The following changes since commit c65b99f046843d2455aa231747b5a07a999a9f3d:

  Linux 4.1-rc6 (2015-05-31 19:01:07 -0700)

are available in the git repository at:

  git://neil.brown.name/md tags/md/4.1-rc7-fixes

for you to fetch changes up to ea358cd0d2c634ff1379a1392edcdf2289f31e13:

  md: make sure MD_RECOVERY_DONE is clear before starting recovery/resync (2015-06-12 20:16:33 +1000)

----------------------------------------------------------------
Three more md fixes for 4.1

The main issue fixed here is a rare race which can result in two reshape
threads running at once, which doesn't end well.
Also a minor issue with a write to a sysfs file returning the wrong value.
Backports to 4.0-stable are indicated.

----------------------------------------------------------------
NeilBrown (3):
      md: don't return 0 from array_state_store
      md: Close race when setting 'action' to 'idle'.
      md: make sure MD_RECOVERY_DONE is clear before starting recovery/resync

 drivers/md/md.c     | 14 ++++++++------
 drivers/md/raid10.c |  1 +
 drivers/md/raid5.c  |  1 +
 3 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/md/md.c b/drivers/md/md.c
index 27506302eb7a..4dbed4a67aaf 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -3834,7 +3834,7 @@ array_state_store(struct mddev *mddev, const char *buf, size_t len)
  err = -EBUSY;
  }
  spin_unlock(&mddev->lock);
- return err;
+ return err ?: len;
  }
  err = mddev_lock(mddev);
  if (err)
@@ -4217,13 +4217,14 @@ action_store(struct mddev *mddev, const char *page, size_t len)
  set_bit(MD_RECOVERY_FROZEN, &mddev->recovery);
  else
  clear_bit(MD_RECOVERY_FROZEN, &mddev->recovery);
- flush_workqueue(md_misc_wq);
- if (mddev->sync_thread) {
- set_bit(MD_RECOVERY_INTR, &mddev->recovery);
- if (mddev_lock(mddev) == 0) {
+ if (test_bit(MD_RECOVERY_RUNNING, &mddev->recovery) &&
+    mddev_lock(mddev) == 0) {
+ flush_workqueue(md_misc_wq);
+ if (mddev->sync_thread) {
+ set_bit(MD_RECOVERY_INTR, &mddev->recovery);
  md_reap_sync_thread(mddev);
- mddev_unlock(mddev);
  }
+ mddev_unlock(mddev);
  }
  } else if (test_bit(MD_RECOVERY_RUNNING, &mddev->recovery) ||
    test_bit(MD_RECOVERY_NEEDED, &mddev->recovery))
@@ -8261,6 +8262,7 @@ void md_reap_sync_thread(struct mddev *mddev)
  if (mddev_is_clustered(mddev))
  md_cluster_ops->metadata_update_finish(mddev);
  clear_bit(MD_RECOVERY_RUNNING, &mddev->recovery);
+ clear_bit(MD_RECOVERY_DONE, &mddev->recovery);
  clear_bit(MD_RECOVERY_SYNC, &mddev->recovery);
  clear_bit(MD_RECOVERY_RESHAPE, &mddev->recovery);
  clear_bit(MD_RECOVERY_REQUESTED, &mddev->recovery);
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index e793ab6b3570..f55c3f35b746 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -4156,6 +4156,7 @@ static int raid10_start_reshape(struct mddev *mddev)
 
  clear_bit(MD_RECOVERY_SYNC, &mddev->recovery);
  clear_bit(MD_RECOVERY_CHECK, &mddev->recovery);
+ clear_bit(MD_RECOVERY_DONE, &mddev->recovery);
  set_bit(MD_RECOVERY_RESHAPE, &mddev->recovery);
  set_bit(MD_RECOVERY_RUNNING, &mddev->recovery);
 
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 553d54b87052..b6793d2e051f 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -7354,6 +7354,7 @@ static int raid5_start_reshape(struct mddev *mddev)
 
  clear_bit(MD_RECOVERY_SYNC, &mddev->recovery);
  clear_bit(MD_RECOVERY_CHECK, &mddev->recovery);
+ clear_bit(MD_RECOVERY_DONE, &mddev->recovery);
  set_bit(MD_RECOVERY_RESHAPE, &mddev->recovery);
  set_bit(MD_RECOVERY_RUNNING, &mddev->recovery);
  mddev->sync_thread = md_register_thread(md_do_sync, mddev,

attachment0 (828 bytes) Download Attachment