]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
md/raid1: update next_resync under resync_lock.
authorNeilBrown <neilb@suse.de>
Wed, 10 Sep 2014 06:01:24 +0000 (16:01 +1000)
committerNeilBrown <neilb@suse.de>
Mon, 22 Sep 2014 01:26:01 +0000 (11:26 +1000)
raise_barrier() uses next_resync as part of its calculations, so it
really should be updated first, instead of afterwards.

next_resync is always used under resync_lock so update it under
resync lock to, just before it is used.  That is safest.

This could cause normal IO and resync IO to interact badly so
it suitable for -stable.

Fixes: 79ef3a8aa1cb1523cc231c9a90a278333c21f761
cc: stable@vger.kernel.org (v3.13+)
Signed-off-by: NeilBrown <neilb@suse.de>
drivers/md/raid1.c

index 3b14a495c4247382e56f15621f43fd4b544b84f6..acfccec9ea3ac6a2d804e6d1037a6568e2ed87ed 100644 (file)
@@ -827,7 +827,7 @@ static void flush_pending_writes(struct r1conf *conf)
  *    there is no normal IO happeing.  It must arrange to call
  *    lower_barrier when the particular background IO completes.
  */
-static void raise_barrier(struct r1conf *conf)
+static void raise_barrier(struct r1conf *conf, sector_t sector_nr)
 {
        spin_lock_irq(&conf->resync_lock);
 
@@ -837,6 +837,7 @@ static void raise_barrier(struct r1conf *conf)
 
        /* block any new IO from starting */
        conf->barrier++;
+       conf->next_resync = sector_nr;
 
        /* For these conditions we must wait:
         * A: while the array is in frozen state
@@ -2543,9 +2544,8 @@ static sector_t sync_request(struct mddev *mddev, sector_t sector_nr, int *skipp
 
        bitmap_cond_end_sync(mddev->bitmap, sector_nr);
        r1_bio = mempool_alloc(conf->r1buf_pool, GFP_NOIO);
-       raise_barrier(conf);
 
-       conf->next_resync = sector_nr;
+       raise_barrier(conf, sector_nr);
 
        rcu_read_lock();
        /*