md/bitmap: protect clearing of ->bitmap by mddev->lock
authorNeilBrown <neilb@suse.de>
Mon, 15 Dec 2014 01:56:58 +0000 (12:56 +1100)
committerNeilBrown <neilb@suse.de>
Thu, 5 Feb 2015 22:32:55 +0000 (09:32 +1100)
This makes it safe to inspect the struct while holding only
the spinlock.

Signed-off-by: NeilBrown <neilb@suse.de>
drivers/md/bitmap.c
drivers/md/md.h

index 1695ee5f3ffc30b883c83c1926745ba22e48a7e1..3424b1915fc4a49098526670b792d0b39c8192ed 100644 (file)
@@ -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;
index e41559dccdc9a5f84adb3dc4ae6979b761ac6463..8770308a8052c4bcbae08adb89954372a4409864 100644 (file)
@@ -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 */