Message ID | 1478865957-25252-8-git-send-email-tom.leiming@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Fri, Nov 11, 2016 at 8:05 PM, Ming Lei <tom.leiming@gmail.com> wrote: > Firstly we have mature bvec/bio iterator helper for iterate each > page in one bio, not necessary to reinvent a wheel to do that. > > Secondly the coming multipage bvecs requires this patch. > > Also add comments about the direct access to bvec table. > > Signed-off-by: Ming Lei <tom.leiming@gmail.com> > --- > drivers/md/dm-io.c | 34 ++++++++++++++++++++++++---------- > 1 file changed, 24 insertions(+), 10 deletions(-) > > diff --git a/drivers/md/dm-io.c b/drivers/md/dm-io.c > index 0bf1a12e35fe..2ef573c220fc 100644 > --- a/drivers/md/dm-io.c > +++ b/drivers/md/dm-io.c > @@ -162,7 +162,10 @@ struct dpages { > struct page **p, unsigned long *len, unsigned *offset); > void (*next_page)(struct dpages *dp); > > - unsigned context_u; > + union { > + unsigned context_u; > + struct bvec_iter context_bi; > + }; > void *context_ptr; > > void *vma_invalidate_address; > @@ -204,25 +207,36 @@ static void list_dp_init(struct dpages *dp, struct page_list *pl, unsigned offse > static void bio_get_page(struct dpages *dp, struct page **p, > unsigned long *len, unsigned *offset) > { > - struct bio_vec *bvec = dp->context_ptr; > - *p = bvec->bv_page; > - *len = bvec->bv_len - dp->context_u; > - *offset = bvec->bv_offset + dp->context_u; > + struct bio_vec bv = bvec_iter_bvec((struct bio_vec *)dp->context_ptr, > + dp->context_bi); > + > + *p = bv.bv_page; > + *len = bv.bv_len; > + *offset = bv.bv_offset; > + > + /* avoid to figure out it in bio_next_page() again */ > + dp->context_bi.bi_sector = (sector_t)bv.bv_len; > } > > static void bio_next_page(struct dpages *dp) > { > - struct bio_vec *bvec = dp->context_ptr; > - dp->context_ptr = bvec + 1; > - dp->context_u = 0; > + unsigned int len = (unsigned int)dp->context_bi.bi_sector; > + > + bvec_iter_advance((struct bio_vec *)dp->context_ptr, > + &dp->context_bi, len); > } > > static void bio_dp_init(struct dpages *dp, struct bio *bio) > { > dp->get_page = bio_get_page; > dp->next_page = bio_next_page; > - dp->context_ptr = __bvec_iter_bvec(bio->bi_io_vec, bio->bi_iter); > - dp->context_u = bio->bi_iter.bi_bvec_done; > + > + /* > + * We just use bvec iterator to retrieve pages, so it is ok to > + * access the bvec table directly here > + */ > + dp->context_ptr = bio->bi_io_vec; > + dp->context_bi = bio->bi_iter; > } Hi Alasdair, Mike, Christoph and anyone, Could you give this one a review? From my test, it just works fine, and I believe it is a good cleanup. Thanks, Ming Lei -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
> Hi Alasdair, Mike, Christoph and anyone, > > Could you give this one a review? It looks nice, but I don't understand the code anywhere near well enough to review it. We'll need someone from the DM to look over it. -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Tue, Nov 15 2016 at 1:55pm -0500, Christoph Hellwig <hch@infradead.org> wrote: > > Hi Alasdair, Mike, Christoph and anyone, > > > > Could you give this one a review? > > It looks nice, but I don't understand the code anywhere near well > enough to review it. We'll need someone from the DM to look over it. I'll try to get to it this week. -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Fri, Nov 11 2016 at 7:05am -0500, Ming Lei <tom.leiming@gmail.com> wrote: > Firstly we have mature bvec/bio iterator helper for iterate each > page in one bio, not necessary to reinvent a wheel to do that. > > Secondly the coming multipage bvecs requires this patch. > > Also add comments about the direct access to bvec table. > > Signed-off-by: Ming Lei <tom.leiming@gmail.com> I've staged this for 4.10 -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Mon, Nov 21, 2016 at 10:49 PM, Mike Snitzer <snitzer@redhat.com> wrote: > On Fri, Nov 11 2016 at 7:05am -0500, > Ming Lei <tom.leiming@gmail.com> wrote: > >> Firstly we have mature bvec/bio iterator helper for iterate each >> page in one bio, not necessary to reinvent a wheel to do that. >> >> Secondly the coming multipage bvecs requires this patch. >> >> Also add comments about the direct access to bvec table. >> >> Signed-off-by: Ming Lei <tom.leiming@gmail.com> > > I've staged this for 4.10 Thanks Mike! -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jens, can you apply the non-dm patches? -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/drivers/md/dm-io.c b/drivers/md/dm-io.c index 0bf1a12e35fe..2ef573c220fc 100644 --- a/drivers/md/dm-io.c +++ b/drivers/md/dm-io.c @@ -162,7 +162,10 @@ struct dpages { struct page **p, unsigned long *len, unsigned *offset); void (*next_page)(struct dpages *dp); - unsigned context_u; + union { + unsigned context_u; + struct bvec_iter context_bi; + }; void *context_ptr; void *vma_invalidate_address; @@ -204,25 +207,36 @@ static void list_dp_init(struct dpages *dp, struct page_list *pl, unsigned offse static void bio_get_page(struct dpages *dp, struct page **p, unsigned long *len, unsigned *offset) { - struct bio_vec *bvec = dp->context_ptr; - *p = bvec->bv_page; - *len = bvec->bv_len - dp->context_u; - *offset = bvec->bv_offset + dp->context_u; + struct bio_vec bv = bvec_iter_bvec((struct bio_vec *)dp->context_ptr, + dp->context_bi); + + *p = bv.bv_page; + *len = bv.bv_len; + *offset = bv.bv_offset; + + /* avoid to figure out it in bio_next_page() again */ + dp->context_bi.bi_sector = (sector_t)bv.bv_len; } static void bio_next_page(struct dpages *dp) { - struct bio_vec *bvec = dp->context_ptr; - dp->context_ptr = bvec + 1; - dp->context_u = 0; + unsigned int len = (unsigned int)dp->context_bi.bi_sector; + + bvec_iter_advance((struct bio_vec *)dp->context_ptr, + &dp->context_bi, len); } static void bio_dp_init(struct dpages *dp, struct bio *bio) { dp->get_page = bio_get_page; dp->next_page = bio_next_page; - dp->context_ptr = __bvec_iter_bvec(bio->bi_io_vec, bio->bi_iter); - dp->context_u = bio->bi_iter.bi_bvec_done; + + /* + * We just use bvec iterator to retrieve pages, so it is ok to + * access the bvec table directly here + */ + dp->context_ptr = bio->bi_io_vec; + dp->context_bi = bio->bi_iter; } /*
Firstly we have mature bvec/bio iterator helper for iterate each page in one bio, not necessary to reinvent a wheel to do that. Secondly the coming multipage bvecs requires this patch. Also add comments about the direct access to bvec table. Signed-off-by: Ming Lei <tom.leiming@gmail.com> --- drivers/md/dm-io.c | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-)