diff options
author | NeilBrown <neilb@suse.de> | 2011-12-08 05:49:46 +0100 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2011-12-08 05:49:46 +0100 |
commit | af8a24347f966ab9fae6b0f127d1fbc9d6932d3a (patch) | |
tree | 903afdae95dc11444707410d784ad857dfb887c9 /drivers/lguest | |
parent | md: refine interpretation of "hold_active == UNTIL_IOCTL". (diff) | |
download | linux-af8a24347f966ab9fae6b0f127d1fbc9d6932d3a.tar.xz linux-af8a24347f966ab9fae6b0f127d1fbc9d6932d3a.zip |
md: take a reference to mddev during sysfs access.
When we are accessing an mddev via sysfs we know that the
mddev cannot disappear because it has an embedded kobj which
is refcounted by sysfs.
And we also take the mddev_lock.
However this is not enough.
The final mddev_put could have been called and the
mddev_delayed_delete is waiting for sysfs to let go so it can destroy
the kobj and mddev.
In this state there are a lot of changes that should not be attempted.
To to guard against this we:
- initialise mddev->all_mddevs in on last put so the state can be
easily detected.
- in md_attr_show and md_attr_store, check ->all_mddevs under
all_mddevs_lock and mddev_get the mddev if it still appears to
be active.
This means that if we get to sysfs as the mddev is being deleted we
will get -EBUSY.
rdev_attr_store and rdev_attr_show are similar but already have
sufficient protection. They check that rdev->mddev still points to
mddev after taking mddev_lock. As this is cleared before delayed
removal which can only be requested under the mddev_lock, this
ensure the rdev and mddev are still alive.
Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'drivers/lguest')
0 files changed, 0 insertions, 0 deletions