Also, when userspace writes 'active', clear all mddev->flags to satisfy md_write_start (the other bits do not matter to external-metadata arrays). Signed-off-by: Dan Williams <dan.j.williams@xxxxxxxxx> --- drivers/md/md.c | 19 +++++++++++++++---- 1 files changed, 15 insertions(+), 4 deletions(-) diff --git a/drivers/md/md.c b/drivers/md/md.c index 6859bcd..ad53035 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -2664,7 +2664,7 @@ array_state_store(mddev_t *mddev, const char *buf, size_t len) if (mddev->pers) { restart_array(mddev); if (mddev->external) - clear_bit(MD_CHANGE_CLEAN, &mddev->flags); + mddev->flags = 0; wake_up(&mddev->sb_wait); err = 0; } else { @@ -5413,9 +5413,14 @@ void md_write_start(mddev_t *mddev, struct bio *bi) if (mddev->in_sync) { mddev->in_sync = 0; set_bit(MD_CHANGE_CLEAN, &mddev->flags); + spin_unlock_irq(&mddev->write_lock); + + /* notify userspace to handle clean->dirty */ + if (mddev->external) + sysfs_notify(&mddev->kobj, NULL, "array_state"); md_wakeup_thread(mddev->thread); - } - spin_unlock_irq(&mddev->write_lock); + } else + spin_unlock_irq(&mddev->write_lock); } wait_event(mddev->sb_wait, mddev->flags==0); } @@ -5451,7 +5456,13 @@ void md_allow_write(mddev_t *mddev) mddev->safemode == 0) mddev->safemode = 1; spin_unlock_irq(&mddev->write_lock); - md_update_sb(mddev, 0); + + /* wait for the dirty state to be recorded in the metadata */ + if (mddev->external) { + sysfs_notify(&mddev->kobj, NULL, "array_state"); + wait_event(mddev->sb_wait, mddev->flags == 0); + } else + md_update_sb(mddev, 0); } else spin_unlock_irq(&mddev->write_lock); } -- To unsubscribe from this list: send the line "unsubscribe linux-raid" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html