md: raid1: move 'offset' out of loop
authorMing Lei <tom.leiming@gmail.com>
Thu, 16 Mar 2017 16:12:30 +0000 (00:12 +0800)
committerShaohua Li <shli@fb.com>
Fri, 24 Mar 2017 17:41:37 +0000 (10:41 -0700)
The 'offset' local variable can't be changed inside the loop, so
move it out.

Signed-off-by: Ming Lei <tom.leiming@gmail.com>
Signed-off-by: Shaohua Li <shli@fb.com>
drivers/md/raid1.c

index d27b84666884168896980335019147f956c41da6..64bf2005f082a997d4a4bd781e52cb325993dd42 100644 (file)
@@ -1294,6 +1294,7 @@ static void raid1_write_request(struct mddev *mddev, struct bio *bio)
        int first_clone;
        int sectors_handled;
        int max_sectors;
+       sector_t offset;
 
        /*
         * Register the new request and wait if the reconstruction
@@ -1439,13 +1440,13 @@ static void raid1_write_request(struct mddev *mddev, struct bio *bio)
        atomic_set(&r1_bio->behind_remaining, 0);
 
        first_clone = 1;
+
+       offset = r1_bio->sector - bio->bi_iter.bi_sector;
        for (i = 0; i < disks; i++) {
                struct bio *mbio = NULL;
-               sector_t offset;
                if (!r1_bio->bios[i])
                        continue;
 
-               offset = r1_bio->sector - bio->bi_iter.bi_sector;
 
                if (first_clone) {
                        /* do behind I/O ?