提交 1b30e66f 编写于 作者: N NeilBrown

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: NNeilBrown <neilb@suse.de>
上级 4af1a041
...@@ -3242,11 +3242,13 @@ safe_delay_store(struct mddev *mddev, const char *cbuf, size_t len) ...@@ -3242,11 +3242,13 @@ safe_delay_store(struct mddev *mddev, const char *cbuf, size_t len)
mddev->safemode_delay = 0; mddev->safemode_delay = 0;
else { else {
unsigned long old_delay = mddev->safemode_delay; unsigned long old_delay = mddev->safemode_delay;
mddev->safemode_delay = (msec*HZ)/1000; unsigned long new_delay = (msec*HZ)/1000;
if (mddev->safemode_delay == 0)
mddev->safemode_delay = 1; if (new_delay == 0)
if (mddev->safemode_delay < old_delay || old_delay == 0) new_delay = 1;
md_safemode_timeout((unsigned long)mddev); mddev->safemode_delay = new_delay;
if (new_delay < old_delay || old_delay == 0)
mod_timer(&mddev->safemode_timer, jiffies+1);
} }
return len; return len;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册