Commit 5037108a authored by Mikulas Patocka's avatar Mikulas Patocka Committed by Alasdair G Kergon

dm: always allow one page in dm_merge_bvec

Some callers assume they can always add at least one page to an empty bio,
so dm_merge_bvec should not return 0 in this case: we'll reject the I/O
later after the bio is submitted.
Signed-off-by: default avatarMikulas Patocka <mpatocka@redhat.com>
Signed-off-by: default avatarAlasdair G Kergon <agk@redhat.com>
parent d3a47e82
...@@ -837,10 +837,10 @@ static int dm_merge_bvec(struct request_queue *q, ...@@ -837,10 +837,10 @@ static int dm_merge_bvec(struct request_queue *q,
struct dm_table *map = dm_get_table(md); struct dm_table *map = dm_get_table(md);
struct dm_target *ti; struct dm_target *ti;
sector_t max_sectors; sector_t max_sectors;
int max_size; int max_size = 0;
if (unlikely(!map)) if (unlikely(!map))
return 0; goto out;
ti = dm_table_find_target(map, bvm->bi_sector); ti = dm_table_find_target(map, bvm->bi_sector);
...@@ -861,14 +861,15 @@ static int dm_merge_bvec(struct request_queue *q, ...@@ -861,14 +861,15 @@ static int dm_merge_bvec(struct request_queue *q,
if (max_size && ti->type->merge) if (max_size && ti->type->merge)
max_size = ti->type->merge(ti, bvm, biovec, max_size); max_size = ti->type->merge(ti, bvm, biovec, max_size);
dm_table_put(map);
out:
/* /*
* Always allow an entire first page * Always allow an entire first page
*/ */
if (max_size <= biovec->bv_len && !(bvm->bi_size >> SECTOR_SHIFT)) if (max_size <= biovec->bv_len && !(bvm->bi_size >> SECTOR_SHIFT))
max_size = biovec->bv_len; max_size = biovec->bv_len;
dm_table_put(map);
return max_size; return max_size;
} }
......
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