diff options
author | NeilBrown <neilb@suse.de> | 2014-12-15 04:57:00 +0300 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2015-02-06 01:32:56 +0300 |
commit | 1b30e66f5acc6bf22fff49d4093cf17454f914b7 (patch) | |
tree | e3aeca2941489abe8ab201fb6b44ccbdf8393fbf /drivers/md | |
parent | 4af1a04176bdb4688aa14f6c10d1d5131c036a9d (diff) | |
download | linux-1b30e66f5acc6bf22fff49d4093cf17454f914b7.tar.xz |
md: minor cleanup in safe_delay_store.
There isn't really much room for races with ->safemode_delay.
But as I am trying to clean up any racy code and will soon
be removing reconfig_mutex protection from most _store()
functions:
- only set mddev->safemode_delay once, to ensure no code
can see an intermediate value
- use safemode_timer to call md_safemode_timeout() rather than
calling it directly, to ensure it never races with itself.
Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'drivers/md')
-rw-r--r-- | drivers/md/md.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c index 5a949166dac0..0f9bc9a02a1b 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -3242,11 +3242,13 @@ safe_delay_store(struct mddev *mddev, const char *cbuf, size_t len) mddev->safemode_delay = 0; else { unsigned long old_delay = mddev->safemode_delay; - mddev->safemode_delay = (msec*HZ)/1000; - if (mddev->safemode_delay == 0) - mddev->safemode_delay = 1; - if (mddev->safemode_delay < old_delay || old_delay == 0) - md_safemode_timeout((unsigned long)mddev); + unsigned long new_delay = (msec*HZ)/1000; + + if (new_delay == 0) + new_delay = 1; + mddev->safemode_delay = new_delay; + if (new_delay < old_delay || old_delay == 0) + mod_timer(&mddev->safemode_timer, jiffies+1); } return len; } |