]> git.neil.brown.name Git - md.git/commitdiff
md-cluster: Defer MD reloading to mddev->thread
authorGuoqing Jiang <gqjiang@suse.com>
Sun, 20 Dec 2015 23:51:00 +0000 (10:51 +1100)
committerNeilBrown <neilb@suse.com>
Wed, 6 Jan 2016 00:39:10 +0000 (11:39 +1100)
Reloading of superblock must be performed under reconfig_mutex. However,
this cannot be done with md_reload_sb because it would deadlock with
the message DLM lock. So, we defer it in md_check_recovery() which is
executed by mddev->thread.

This introduces a new flag, MD_RELOAD_SB, which if set, will reload the
superblock. And good_device_nr is also added to 'struct mddev' which is
used to get the num of the good device within cluster raid.

Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
Signed-off-by: Guoqing Jiang <gqjiang@suse.com>
Signed-off-by: NeilBrown <neilb@suse.com>
drivers/md/md-cluster.c
drivers/md/md.c
drivers/md/md.h

index db9375f501aba880ab50c7d1b41573cb7b6a05a8..b659ef7b8daff4e57440f12112dc23a1276a6e9f 100644 (file)
@@ -432,8 +432,10 @@ static void process_add_new_disk(struct mddev *mddev, struct cluster_msg *cmsg)
 static void process_metadata_update(struct mddev *mddev, struct cluster_msg *msg)
 {
        struct md_cluster_info *cinfo = mddev->cluster_info;
-       md_reload_sb(mddev, le32_to_cpu(msg->raid_slot));
+       mddev->good_device_nr = le32_to_cpu(msg->raid_slot);
+       set_bit(MD_RELOAD_SB, &mddev->flags);
        dlm_lock_sync(cinfo->no_new_dev_lockres, DLM_LOCK_CR);
+       md_wakeup_thread(mddev->thread);
 }
 
 static void process_remove_disk(struct mddev *mddev, struct cluster_msg *msg)
index 495d8aa0a0d252bb7b7a75355d1c8286c622f2dd..504ce5d068ce6cc0ece3a3c2ee71d2948174f24a 100644 (file)
@@ -8286,6 +8286,7 @@ void md_check_recovery(struct mddev *mddev)
                (mddev->flags & MD_UPDATE_SB_FLAGS & ~ (1<<MD_CHANGE_PENDING)) ||
                test_bit(MD_RECOVERY_NEEDED, &mddev->recovery) ||
                test_bit(MD_RECOVERY_DONE, &mddev->recovery) ||
+               test_bit(MD_RELOAD_SB, &mddev->flags) ||
                (mddev->external == 0 && mddev->safemode == 1) ||
                (mddev->safemode == 2 && ! atomic_read(&mddev->writes_pending)
                 && !mddev->in_sync && mddev->recovery_cp == MaxSector)
@@ -8334,6 +8335,9 @@ void md_check_recovery(struct mddev *mddev)
                                                rdev->raid_disk < 0)
                                        md_kick_rdev_from_array(rdev);
                        }
+
+                       if (test_and_clear_bit(MD_RELOAD_SB, &mddev->flags))
+                               md_reload_sb(mddev, mddev->good_device_nr);
                }
 
                if (!mddev->external) {
index f7b17aef837d723c1bb8798f00e2c1458c096e99..8817e623258ac6c7bc2f27fb604093faccff232b 100644 (file)
@@ -235,6 +235,9 @@ struct mddev {
                                 */
 #define MD_JOURNAL_CLEAN 5     /* A raid with journal is already clean */
 #define MD_HAS_JOURNAL 6       /* The raid array has journal feature set */
+#define MD_RELOAD_SB   7       /* Reload the superblock because another node
+                                * updated it.
+                                */
 
        int                             suspended;
        atomic_t                        active_io;
@@ -465,6 +468,7 @@ struct mddev {
        struct work_struct event_work;  /* used by dm to report failure event */
        void (*sync_super)(struct mddev *mddev, struct md_rdev *rdev);
        struct md_cluster_info          *cluster_info;
+       unsigned int                    good_device_nr; /* good device num within cluster raid */
 };
 
 static inline int __must_check mddev_lock(struct mddev *mddev)