Commit 14fe594d authored by Alasdair G Kergon's avatar Alasdair G Kergon

dm: rename bio cloning functions

Rename functions involved in splitting and cloning bios.

The sequence of functions is now:
  (1) __split_and_process* - entry point that selects the processing strategy
  (2) __send* - prepare the details for each bio needed and loop through them
  (3) __clone_and_map* - creates a clone and maps it
Signed-off-by: default avatarAlasdair G Kergon <agk@redhat.com>
parent 55a62eef
...@@ -1061,9 +1061,9 @@ static void clone_bio_integrity(struct bio *bio, struct bio *clone, ...@@ -1061,9 +1061,9 @@ static void clone_bio_integrity(struct bio *bio, struct bio *clone,
/* /*
* Creates a little bio that just does part of a bvec. * Creates a little bio that just does part of a bvec.
*/ */
static void split_bvec(struct dm_target_io *tio, struct bio *bio, static void clone_split_bio(struct dm_target_io *tio, struct bio *bio,
sector_t sector, unsigned short idx, unsigned int offset, sector_t sector, unsigned short idx,
unsigned int len) unsigned offset, unsigned len)
{ {
struct bio *clone = &tio->clone; struct bio *clone = &tio->clone;
struct bio_vec *bv = bio->bi_io_vec + idx; struct bio_vec *bv = bio->bi_io_vec + idx;
...@@ -1119,8 +1119,9 @@ static struct dm_target_io *alloc_tio(struct clone_info *ci, ...@@ -1119,8 +1119,9 @@ static struct dm_target_io *alloc_tio(struct clone_info *ci,
return tio; return tio;
} }
static void __issue_target_request(struct clone_info *ci, struct dm_target *ti, static void __clone_and_map_simple_bio(struct clone_info *ci,
unsigned target_bio_nr, sector_t len) struct dm_target *ti,
unsigned target_bio_nr, sector_t 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, ci->bio->bi_max_vecs, target_bio_nr);
struct bio *clone = &tio->clone; struct bio *clone = &tio->clone;
...@@ -1137,31 +1138,29 @@ static void __issue_target_request(struct clone_info *ci, struct dm_target *ti, ...@@ -1137,31 +1138,29 @@ static void __issue_target_request(struct clone_info *ci, struct dm_target *ti,
__map_bio(tio); __map_bio(tio);
} }
static void __issue_target_bios(struct clone_info *ci, struct dm_target *ti, static void __send_duplicate_bios(struct clone_info *ci, struct dm_target *ti,
unsigned num_bios, sector_t len) unsigned num_bios, sector_t len)
{ {
unsigned target_bio_nr; unsigned target_bio_nr;
for (target_bio_nr = 0; target_bio_nr < num_bios; target_bio_nr++) for (target_bio_nr = 0; target_bio_nr < num_bios; target_bio_nr++)
__issue_target_request(ci, ti, target_bio_nr, len); __clone_and_map_simple_bio(ci, ti, target_bio_nr, len);
} }
static int __clone_and_map_empty_flush(struct clone_info *ci) static int __send_empty_flush(struct clone_info *ci)
{ {
unsigned target_nr = 0; unsigned target_nr = 0;
struct dm_target *ti; struct dm_target *ti;
BUG_ON(bio_has_data(ci->bio)); BUG_ON(bio_has_data(ci->bio));
while ((ti = dm_table_get_target(ci->map, target_nr++))) while ((ti = dm_table_get_target(ci->map, target_nr++)))
__issue_target_bios(ci, ti, ti->num_flush_bios, 0); __send_duplicate_bios(ci, ti, ti->num_flush_bios, 0);
return 0; return 0;
} }
/* static void __clone_and_map_data_bio(struct clone_info *ci,
* Perform all io with a single clone. struct dm_target *ti)
*/
static void __clone_and_map_simple(struct clone_info *ci, struct dm_target *ti)
{ {
struct bio *bio = ci->bio; struct bio *bio = ci->bio;
struct dm_target_io *tio; struct dm_target_io *tio;
...@@ -1192,9 +1191,9 @@ static bool is_split_required_for_discard(struct dm_target *ti) ...@@ -1192,9 +1191,9 @@ static bool is_split_required_for_discard(struct dm_target *ti)
return ti->split_discard_bios; return ti->split_discard_bios;
} }
static int __clone_and_map_changing_extent_only(struct clone_info *ci, static int __send_changing_extent_only(struct clone_info *ci,
get_num_bios_fn get_num_bios, get_num_bios_fn get_num_bios,
is_split_required_fn is_split_required) is_split_required_fn is_split_required)
{ {
struct dm_target *ti; struct dm_target *ti;
sector_t len; sector_t len;
...@@ -1220,7 +1219,7 @@ static int __clone_and_map_changing_extent_only(struct clone_info *ci, ...@@ -1220,7 +1219,7 @@ static int __clone_and_map_changing_extent_only(struct clone_info *ci,
else else
len = min(ci->sector_count, max_io_len(ci->sector, ti)); len = min(ci->sector_count, max_io_len(ci->sector, ti));
__issue_target_bios(ci, ti, num_bios, len); __send_duplicate_bios(ci, ti, num_bios, len);
ci->sector += len; ci->sector += len;
} while (ci->sector_count -= len); } while (ci->sector_count -= len);
...@@ -1228,18 +1227,18 @@ static int __clone_and_map_changing_extent_only(struct clone_info *ci, ...@@ -1228,18 +1227,18 @@ static int __clone_and_map_changing_extent_only(struct clone_info *ci,
return 0; return 0;
} }
static int __clone_and_map_discard(struct clone_info *ci) static int __send_discard(struct clone_info *ci)
{ {
return __clone_and_map_changing_extent_only(ci, get_num_discard_bios, return __send_changing_extent_only(ci, get_num_discard_bios,
is_split_required_for_discard); is_split_required_for_discard);
} }
static int __clone_and_map_write_same(struct clone_info *ci) static int __send_write_same(struct clone_info *ci)
{ {
return __clone_and_map_changing_extent_only(ci, get_num_write_same_bios, NULL); return __send_changing_extent_only(ci, get_num_write_same_bios, NULL);
} }
static int __clone_and_map(struct clone_info *ci) static int __split_and_process_non_flush(struct clone_info *ci)
{ {
struct bio *bio = ci->bio; struct bio *bio = ci->bio;
struct dm_target *ti; struct dm_target *ti;
...@@ -1247,9 +1246,9 @@ static int __clone_and_map(struct clone_info *ci) ...@@ -1247,9 +1246,9 @@ static int __clone_and_map(struct clone_info *ci)
struct dm_target_io *tio; struct dm_target_io *tio;
if (unlikely(bio->bi_rw & REQ_DISCARD)) if (unlikely(bio->bi_rw & REQ_DISCARD))
return __clone_and_map_discard(ci); return __send_discard(ci);
else if (unlikely(bio->bi_rw & REQ_WRITE_SAME)) else if (unlikely(bio->bi_rw & REQ_WRITE_SAME))
return __clone_and_map_write_same(ci); return __send_write_same(ci);
ti = dm_table_find_target(ci->map, ci->sector); ti = dm_table_find_target(ci->map, ci->sector);
if (!dm_target_is_valid(ti)) if (!dm_target_is_valid(ti))
...@@ -1262,7 +1261,7 @@ static int __clone_and_map(struct clone_info *ci) ...@@ -1262,7 +1261,7 @@ static int __clone_and_map(struct clone_info *ci)
* Optimise for the simple case where we can do all of * Optimise for the simple case where we can do all of
* the remaining io with a single clone. * the remaining io with a single clone.
*/ */
__clone_and_map_simple(ci, ti); __clone_and_map_data_bio(ci, ti);
} else if (to_sector(bio->bi_io_vec[ci->idx].bv_len) <= max) { } else if (to_sector(bio->bi_io_vec[ci->idx].bv_len) <= max) {
/* /*
...@@ -1311,8 +1310,8 @@ static int __clone_and_map(struct clone_info *ci) ...@@ -1311,8 +1310,8 @@ static int __clone_and_map(struct clone_info *ci)
len = min(remaining, max); len = min(remaining, max);
tio = alloc_tio(ci, ti, 1, 0); tio = alloc_tio(ci, ti, 1, 0);
split_bvec(tio, bio, ci->sector, ci->idx, clone_split_bio(tio, bio, ci->sector, ci->idx,
bv->bv_offset + offset, len); bv->bv_offset + offset, len);
__map_bio(tio); __map_bio(tio);
...@@ -1328,7 +1327,7 @@ static int __clone_and_map(struct clone_info *ci) ...@@ -1328,7 +1327,7 @@ static int __clone_and_map(struct clone_info *ci)
} }
/* /*
* Split the bio into several clones and submit it to targets. * Entry point to split a bio into clones and submit them to the targets.
*/ */
static void __split_and_process_bio(struct mapped_device *md, struct bio *bio) static void __split_and_process_bio(struct mapped_device *md, struct bio *bio)
{ {
...@@ -1356,13 +1355,13 @@ static void __split_and_process_bio(struct mapped_device *md, struct bio *bio) ...@@ -1356,13 +1355,13 @@ static void __split_and_process_bio(struct mapped_device *md, struct bio *bio)
if (bio->bi_rw & REQ_FLUSH) { if (bio->bi_rw & REQ_FLUSH) {
ci.bio = &ci.md->flush_bio; ci.bio = &ci.md->flush_bio;
ci.sector_count = 0; ci.sector_count = 0;
error = __clone_and_map_empty_flush(&ci); error = __send_empty_flush(&ci);
/* dec_pending submits any data associated with flush */ /* dec_pending submits any data associated with flush */
} else { } else {
ci.bio = bio; ci.bio = bio;
ci.sector_count = bio_sectors(bio); ci.sector_count = bio_sectors(bio);
while (ci.sector_count && !error) while (ci.sector_count && !error)
error = __clone_and_map(&ci); error = __split_and_process_non_flush(&ci);
} }
/* drop the extra reference count */ /* drop the extra reference count */
......
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