Message ID | 20190425070300.3388-2-hch@lst.de (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [1/2] bcache: clean up do_btree_node_write a bit | expand |
On 4/25/19 9:02 AM, Christoph Hellwig wrote: > Use a variable containing the buffer address instead of the to be > removed integer iterator from bio_for_each_segment_all. > > Suggested-by: Matthew Wilcox <willy@infradead.org> > Signed-off-by: Christoph Hellwig <hch@lst.de> > --- > drivers/md/bcache/btree.c | 9 +++++---- > 1 file changed, 5 insertions(+), 4 deletions(-) > > diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c > index b139858b0802..3a9f8ed437de 100644 > --- a/drivers/md/bcache/btree.c > +++ b/drivers/md/bcache/btree.c > @@ -431,12 +431,13 @@ static void do_btree_node_write(struct btree *b) > if (!bch_bio_alloc_pages(b->bio, __GFP_NOWARN|GFP_NOWAIT)) { > int j; > struct bio_vec *bv; > - void *base = (void *) ((unsigned long) i & ~(PAGE_SIZE - 1)); > + void *addr = (void *) ((unsigned long) i & ~(PAGE_SIZE - 1)); > struct bvec_iter_all iter_all; > > - bio_for_each_segment_all(bv, b->bio, j, iter_all) > - memcpy(page_address(bv->bv_page), > - base + j * PAGE_SIZE, PAGE_SIZE); > + bio_for_each_segment_all(bv, b->bio, j, iter_all) { > + memcpy(page_address(bv->bv_page), addr, PAGE_SIZE); > + addr += PAGE_SIZE; > + } > > bch_submit_bbio(b->bio, b->c, &k.key, 0); > > Reviewed-by: Hannes Reinecke <hare@suse.com> Cheers, Hannes
On 2019/4/25 3:02 下午, Christoph Hellwig wrote: > Use a variable containing the buffer address instead of the to be > removed integer iterator from bio_for_each_segment_all. > > Suggested-by: Matthew Wilcox <willy@infradead.org> > Signed-off-by: Christoph Hellwig <hch@lst.de> Acked-by: Coly Li <colyli@suse.de> Thanks. Coly Li > --- > drivers/md/bcache/btree.c | 9 +++++---- > 1 file changed, 5 insertions(+), 4 deletions(-) > > diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c > index b139858b0802..3a9f8ed437de 100644 > --- a/drivers/md/bcache/btree.c > +++ b/drivers/md/bcache/btree.c > @@ -431,12 +431,13 @@ static void do_btree_node_write(struct btree *b) > if (!bch_bio_alloc_pages(b->bio, __GFP_NOWARN|GFP_NOWAIT)) { > int j; > struct bio_vec *bv; > - void *base = (void *) ((unsigned long) i & ~(PAGE_SIZE - 1)); > + void *addr = (void *) ((unsigned long) i & ~(PAGE_SIZE - 1)); > struct bvec_iter_all iter_all; > > - bio_for_each_segment_all(bv, b->bio, j, iter_all) > - memcpy(page_address(bv->bv_page), > - base + j * PAGE_SIZE, PAGE_SIZE); > + bio_for_each_segment_all(bv, b->bio, j, iter_all) { > + memcpy(page_address(bv->bv_page), addr, PAGE_SIZE); > + addr += PAGE_SIZE; > + } > > bch_submit_bbio(b->bio, b->c, &k.key, 0); > >
diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c index b139858b0802..3a9f8ed437de 100644 --- a/drivers/md/bcache/btree.c +++ b/drivers/md/bcache/btree.c @@ -431,12 +431,13 @@ static void do_btree_node_write(struct btree *b) if (!bch_bio_alloc_pages(b->bio, __GFP_NOWARN|GFP_NOWAIT)) { int j; struct bio_vec *bv; - void *base = (void *) ((unsigned long) i & ~(PAGE_SIZE - 1)); + void *addr = (void *) ((unsigned long) i & ~(PAGE_SIZE - 1)); struct bvec_iter_all iter_all; - bio_for_each_segment_all(bv, b->bio, j, iter_all) - memcpy(page_address(bv->bv_page), - base + j * PAGE_SIZE, PAGE_SIZE); + bio_for_each_segment_all(bv, b->bio, j, iter_all) { + memcpy(page_address(bv->bv_page), addr, PAGE_SIZE); + addr += PAGE_SIZE; + } bch_submit_bbio(b->bio, b->c, &k.key, 0);
Use a variable containing the buffer address instead of the to be removed integer iterator from bio_for_each_segment_all. Suggested-by: Matthew Wilcox <willy@infradead.org> Signed-off-by: Christoph Hellwig <hch@lst.de> --- drivers/md/bcache/btree.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)