Message ID | 1488296503-4987-6-git-send-email-tom.leiming@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Tue, Feb 28, 2017 at 11:41:35PM +0800, Ming Lei wrote: > 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. We are going to delete the code, this simplify isn't really required. > > Signed-off-by: Ming Lei <tom.leiming@gmail.com> > --- > drivers/md/raid1.c | 15 +++++++-------- > 1 file changed, 7 insertions(+), 8 deletions(-) > > diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c > index 25c9172db639..c442b4657e2f 100644 > --- a/drivers/md/raid1.c > +++ b/drivers/md/raid1.c > @@ -139,9 +139,12 @@ 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 (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; > @@ -166,12 +169,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]); > > -- > 2.7.4 >
Hi Shaohua, On Wed, Mar 1, 2017 at 7:31 AM, Shaohua Li <shli@kernel.org> wrote: > On Tue, Feb 28, 2017 at 11:41:35PM +0800, Ming Lei wrote: >> 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. > > We are going to delete the code, this simplify isn't really required. Could you explain it a bit? Or I can put this patch into this patchset if you can provide one? Thanks, Ming Lei
On Thu, Mar 02, 2017 at 10:11:54AM +0800, Ming Lei wrote: > Hi Shaohua, > > On Wed, Mar 1, 2017 at 7:31 AM, Shaohua Li <shli@kernel.org> wrote: > > On Tue, Feb 28, 2017 at 11:41:35PM +0800, Ming Lei wrote: > >> 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. > > > > We are going to delete the code, this simplify isn't really required. > > Could you explain it a bit? Or I can put this patch into this patchset if you > can provide one? I mean you will replace the code soon, with the resync_pages stuff. So I thought this isn't really required. Thanks, Shaohua
On Fri, Mar 3, 2017 at 1:49 AM, Shaohua Li <shli@kernel.org> wrote: > On Thu, Mar 02, 2017 at 10:11:54AM +0800, Ming Lei wrote: >> Hi Shaohua, >> >> On Wed, Mar 1, 2017 at 7:31 AM, Shaohua Li <shli@kernel.org> wrote: >> > On Tue, Feb 28, 2017 at 11:41:35PM +0800, Ming Lei wrote: >> >> 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. >> > >> > We are going to delete the code, this simplify isn't really required. >> >> Could you explain it a bit? Or I can put this patch into this patchset if you >> can provide one? > > I mean you will replace the code soon, with the resync_pages stuff. So I > thought this isn't really required. OK, one benefit of this patch is to make the following one easier to review, but not a big deal, I may merge this into the following patch. Thanks, Ming Lei
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index 25c9172db639..c442b4657e2f 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -139,9 +139,12 @@ 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 (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; @@ -166,12 +169,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]);
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> --- drivers/md/raid1.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)