md: raid10: retrieve page from preallocated resync page array
authorMing Lei <tom.leiming@gmail.com>
Thu, 16 Mar 2017 16:12:34 +0000 (00:12 +0800)
committerShaohua Li <shli@fb.com>
Fri, 24 Mar 2017 17:41:37 +0000 (10:41 -0700)
Now one page array is allocated for each resync bio, and we can
retrieve page from this table directly.

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

index 629ae45bb18e4248a25d72f16ed38bd8913e0056..827bb5bef53c7072cebdae176d9d533e730023cc 100644 (file)
@@ -2055,6 +2055,7 @@ static void sync_request_write(struct mddev *mddev, struct r10bio *r10_bio)
        int i, first;
        struct bio *tbio, *fbio;
        int vcnt;
+       struct page **tpages, **fpages;
 
        atomic_set(&r10_bio->remaining, 1);
 
@@ -2070,6 +2071,7 @@ static void sync_request_write(struct mddev *mddev, struct r10bio *r10_bio)
        fbio = r10_bio->devs[i].bio;
        fbio->bi_iter.bi_size = r10_bio->sectors << 9;
        fbio->bi_iter.bi_idx = 0;
+       fpages = get_resync_pages(fbio)->pages;
 
        vcnt = (r10_bio->sectors + (PAGE_SIZE >> 9) - 1) >> (PAGE_SHIFT - 9);
        /* now find blocks with errors */
@@ -2084,6 +2086,8 @@ static void sync_request_write(struct mddev *mddev, struct r10bio *r10_bio)
                        continue;
                if (i == first)
                        continue;
+
+               tpages = get_resync_pages(tbio)->pages;
                d = r10_bio->devs[i].devnum;
                rdev = conf->mirrors[d].rdev;
                if (!r10_bio->devs[i].bio->bi_error) {
@@ -2096,8 +2100,8 @@ static void sync_request_write(struct mddev *mddev, struct r10bio *r10_bio)
                                int len = PAGE_SIZE;
                                if (sectors < (len / 512))
                                        len = sectors * 512;
-                               if (memcmp(page_address(fbio->bi_io_vec[j].bv_page),
-                                          page_address(tbio->bi_io_vec[j].bv_page),
+                               if (memcmp(page_address(fpages[j]),
+                                          page_address(tpages[j]),
                                           len))
                                        break;
                                sectors -= len/512;
@@ -2195,6 +2199,7 @@ static void fix_recovery_read_error(struct r10bio *r10_bio)
        int idx = 0;
        int dr = r10_bio->devs[0].devnum;
        int dw = r10_bio->devs[1].devnum;
+       struct page **pages = get_resync_pages(bio)->pages;
 
        while (sectors) {
                int s = sectors;
@@ -2210,7 +2215,7 @@ static void fix_recovery_read_error(struct r10bio *r10_bio)
                ok = sync_page_io(rdev,
                                  addr,
                                  s << 9,
-                                 bio->bi_io_vec[idx].bv_page,
+                                 pages[idx],
                                  REQ_OP_READ, 0, false);
                if (ok) {
                        rdev = conf->mirrors[dw].rdev;
@@ -2218,7 +2223,7 @@ static void fix_recovery_read_error(struct r10bio *r10_bio)
                        ok = sync_page_io(rdev,
                                          addr,
                                          s << 9,
-                                         bio->bi_io_vec[idx].bv_page,
+                                         pages[idx],
                                          REQ_OP_WRITE, 0, false);
                        if (!ok) {
                                set_bit(WriteErrorSeen, &rdev->flags);