Commit 99778273 authored by Junichi Nomura's avatar Junichi Nomura Committed by Mike Snitzer

dm: remove nr_iovecs parameter from alloc_tio()

alloc_tio() uses bio_alloc_bioset() to allocate a clone-bio for a bio.
alloc_tio() takes the number of bvecs to allocate for the clone-bio.
However, with v3.14's immutable biovec changes DM now uses
__bio_clone_fast() and no longer needs to allocate bvecs.

In practice, the 'nr_iovecs' passed to alloc_tio() is always effectively
0.  __clone_and_map_simple_bio() looked like it was passing non-zero
nr_iovecs, but its value was always within the range of inline bvecs and
no allocation actually happened.  If allocation happened, the BUG_ON() in
__bio_clone_fast() would've triggered.

Remove the nr_iovecs parameter from alloc_tio() to prevent possible
future bio_alloc_bioset() mis-use of a new bioset interface that will no
longer allow bvecs to be allocated.

Also fix extra whitespace before the __bio_clone_fast() call in
__clone_and_map_simple_bio().
Signed-off-by: default avatarJun'ichi Nomura <j-nomura@ce.jp.nec.com>
Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
parent d8f429e1
...@@ -1249,13 +1249,13 @@ static void clone_bio(struct dm_target_io *tio, struct bio *bio, ...@@ -1249,13 +1249,13 @@ static void clone_bio(struct dm_target_io *tio, struct bio *bio,
} }
static struct dm_target_io *alloc_tio(struct clone_info *ci, static struct dm_target_io *alloc_tio(struct clone_info *ci,
struct dm_target *ti, int nr_iovecs, struct dm_target *ti,
unsigned target_bio_nr) unsigned target_bio_nr)
{ {
struct dm_target_io *tio; struct dm_target_io *tio;
struct bio *clone; struct bio *clone;
clone = bio_alloc_bioset(GFP_NOIO, nr_iovecs, ci->md->bs); clone = bio_alloc_bioset(GFP_NOIO, 0, ci->md->bs);
tio = container_of(clone, struct dm_target_io, clone); tio = container_of(clone, struct dm_target_io, clone);
tio->io = ci->io; tio->io = ci->io;
...@@ -1269,16 +1269,11 @@ static void __clone_and_map_simple_bio(struct clone_info *ci, ...@@ -1269,16 +1269,11 @@ static void __clone_and_map_simple_bio(struct clone_info *ci,
struct dm_target *ti, struct dm_target *ti,
unsigned target_bio_nr, unsigned *len) unsigned target_bio_nr, unsigned *len)
{ {
struct dm_target_io *tio = alloc_tio(ci, ti, ci->bio->bi_max_vecs, target_bio_nr); struct dm_target_io *tio = alloc_tio(ci, ti, target_bio_nr);
struct bio *clone = &tio->clone; struct bio *clone = &tio->clone;
tio->len_ptr = len; tio->len_ptr = len;
/*
* Discard requests require the bio's inline iovecs be initialized.
* ci->bio->bi_max_vecs is BIO_INLINE_VECS anyway, for both flush
* and discard, so no need for concern about wasted bvec allocations.
*/
__bio_clone_fast(clone, ci->bio); __bio_clone_fast(clone, ci->bio);
if (len) if (len)
bio_setup_sector(clone, ci->sector, *len); bio_setup_sector(clone, ci->sector, *len);
...@@ -1322,7 +1317,7 @@ static void __clone_and_map_data_bio(struct clone_info *ci, struct dm_target *ti ...@@ -1322,7 +1317,7 @@ static void __clone_and_map_data_bio(struct clone_info *ci, struct dm_target *ti
num_target_bios = ti->num_write_bios(ti, bio); num_target_bios = ti->num_write_bios(ti, bio);
for (target_bio_nr = 0; target_bio_nr < num_target_bios; target_bio_nr++) { for (target_bio_nr = 0; target_bio_nr < num_target_bios; target_bio_nr++) {
tio = alloc_tio(ci, ti, 0, target_bio_nr); tio = alloc_tio(ci, ti, target_bio_nr);
tio->len_ptr = len; tio->len_ptr = len;
clone_bio(tio, bio, sector, *len); clone_bio(tio, bio, sector, *len);
__map_bio(tio); __map_bio(tio);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment