summaryrefslogtreecommitdiffstats
path: root/drivers/md/raid1.c
diff options
context:
space:
mode:
authorMing Lei <tom.leiming@gmail.com>2017-03-17 00:12:25 +0800
committerShaohua Li <shli@fb.com>2017-03-24 10:41:36 -0700
commita7234234d0d6373d0510582ab632efbf73243403 (patch)
treeff7bc74918e852addc6769ff9a4f0043b021b787 /drivers/md/raid1.c
parent513e2faa0138462ce014e1b0e226ca45c83bc6c1 (diff)
downloadlinux-a7234234d0d6373d0510582ab632efbf73243403.tar.bz2
md: raid1: simplify r1buf_pool_free()
This patch gets each page's reference of each bio for resync, then r1buf_pool_free() gets simplified a lot. The same policy has been taken in raid10's buf pool allocation/free too. Signed-off-by: Ming Lei <tom.leiming@gmail.com> Signed-off-by: Shaohua Li <shli@fb.com>
Diffstat (limited to 'drivers/md/raid1.c')
-rw-r--r--drivers/md/raid1.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index c31f9e206148..7ee0911fba7d 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -142,10 +142,13 @@ static void * r1buf_pool_alloc(gfp_t gfp_flags, void *data)
}
/* If not user-requests, copy the page pointers to all bios */
if (!test_bit(MD_RECOVERY_REQUESTED, &pi->mddev->recovery)) {
- for (i=0; i<RESYNC_PAGES ; i++)
- for (j=1; j<pi->raid_disks; j++)
- r1_bio->bios[j]->bi_io_vec[i].bv_page =
+ for (i = 0; i< RESYNC_PAGES; i++)
+ for (j = 1; j < pi->raid_disks; j++) {
+ struct page *page =
r1_bio->bios[0]->bi_io_vec[i].bv_page;
+ get_page(page);
+ r1_bio->bios[j]->bi_io_vec[i].bv_page = page;
+ }
}
r1_bio->master_bio = NULL;
@@ -170,12 +173,8 @@ static void r1buf_pool_free(void *__r1_bio, void *data)
struct r1bio *r1bio = __r1_bio;
for (i = 0; i < RESYNC_PAGES; i++)
- for (j = pi->raid_disks; j-- ;) {
- if (j == 0 ||
- r1bio->bios[j]->bi_io_vec[i].bv_page !=
- r1bio->bios[0]->bi_io_vec[i].bv_page)
- safe_put_page(r1bio->bios[j]->bi_io_vec[i].bv_page);
- }
+ for (j = pi->raid_disks; j-- ;)
+ safe_put_page(r1bio->bios[j]->bi_io_vec[i].bv_page);
for (i=0 ; i < pi->raid_disks; i++)
bio_put(r1bio->bios[i]);