Skip to content

Commit

Permalink
md/bitmap: protect clearing of ->bitmap by mddev->lock
Browse files Browse the repository at this point in the history
This makes it safe to inspect the struct while holding only
the spinlock.

Signed-off-by: NeilBrown <neilb@suse.de>
  • Loading branch information
NeilBrown committed Feb 5, 2015
1 parent 36d091f commit 978a7a4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/md/bitmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1619,7 +1619,9 @@ void bitmap_destroy(struct mddev *mddev)
return;

mutex_lock(&mddev->bitmap_info.mutex);
spin_lock(&mddev->lock);
mddev->bitmap = NULL; /* disconnect from the md device */
spin_unlock(&mddev->lock);
mutex_unlock(&mddev->bitmap_info.mutex);
if (mddev->thread)
mddev->thread->timeout = MAX_SCHEDULE_TIMEOUT;
Expand Down
1 change: 1 addition & 0 deletions drivers/md/md.h
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@ struct mddev {
* clearing MD_CHANGE_*
* in_sync - and related safemode and MD_CHANGE changes
* pers (also protected by reconfig_mutex and pending IO).
* clearing ->bitmap
*/
spinlock_t lock;
wait_queue_head_t sb_wait; /* for waiting on superblock updates */
Expand Down

0 comments on commit 978a7a4

Please sign in to comment.