提交 55a62eef 编写于 作者: A Alasdair G Kergon

dm: rename request variables to bios

Use 'bio' in the name of variables and functions that deal with
bios rather than 'request' to avoid confusion with the normal
block layer use of 'request'.

No functional changes.
Signed-off-by: NAlasdair G Kergon <agk@redhat.com>
上级 bd2a49b8
......@@ -1637,7 +1637,7 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
if (opt_params == 1 && opt_string &&
!strcasecmp(opt_string, "allow_discards"))
ti->num_discard_requests = 1;
ti->num_discard_bios = 1;
else if (opt_params) {
ret = -EINVAL;
ti->error = "Invalid feature arguments";
......@@ -1665,7 +1665,7 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
goto bad;
}
ti->num_flush_requests = 1;
ti->num_flush_bios = 1;
ti->discard_zeroes_data_unsupported = true;
return 0;
......@@ -1726,7 +1726,7 @@ static void crypt_status(struct dm_target *ti, status_type_t type,
DMEMIT(" %llu %s %llu", (unsigned long long)cc->iv_offset,
cc->dev->name, (unsigned long long)cc->start);
if (ti->num_discard_requests)
if (ti->num_discard_bios)
DMEMIT(" 1 allow_discards");
break;
......
......@@ -198,8 +198,8 @@ static int delay_ctr(struct dm_target *ti, unsigned int argc, char **argv)
mutex_init(&dc->timer_lock);
atomic_set(&dc->may_delay, 1);
ti->num_flush_requests = 1;
ti->num_discard_requests = 1;
ti->num_flush_bios = 1;
ti->num_discard_bios = 1;
ti->private = dc;
return 0;
......
......@@ -216,8 +216,8 @@ static int flakey_ctr(struct dm_target *ti, unsigned int argc, char **argv)
goto bad;
}
ti->num_flush_requests = 1;
ti->num_discard_requests = 1;
ti->num_flush_bios = 1;
ti->num_discard_bios = 1;
ti->per_bio_data_size = sizeof(struct per_bio_data);
ti->private = fc;
return 0;
......
......@@ -53,9 +53,9 @@ static int linear_ctr(struct dm_target *ti, unsigned int argc, char **argv)
goto bad;
}
ti->num_flush_requests = 1;
ti->num_discard_requests = 1;
ti->num_write_same_requests = 1;
ti->num_flush_bios = 1;
ti->num_discard_bios = 1;
ti->num_write_same_bios = 1;
ti->private = lc;
return 0;
......
......@@ -905,8 +905,8 @@ static int multipath_ctr(struct dm_target *ti, unsigned int argc,
goto bad;
}
ti->num_flush_requests = 1;
ti->num_discard_requests = 1;
ti->num_flush_bios = 1;
ti->num_discard_bios = 1;
return 0;
......
......@@ -1151,7 +1151,7 @@ static int raid_ctr(struct dm_target *ti, unsigned argc, char **argv)
INIT_WORK(&rs->md.event_work, do_table_event);
ti->private = rs;
ti->num_flush_requests = 1;
ti->num_flush_bios = 1;
mutex_lock(&rs->md.reconfig_mutex);
ret = md_run(&rs->md);
......
......@@ -1072,8 +1072,8 @@ static int mirror_ctr(struct dm_target *ti, unsigned int argc, char **argv)
if (r)
goto err_free_context;
ti->num_flush_requests = 1;
ti->num_discard_requests = 1;
ti->num_flush_bios = 1;
ti->num_discard_bios = 1;
ti->per_bio_data_size = sizeof(struct dm_raid1_bio_record);
ti->discard_zeroes_data_unsupported = true;
......
......@@ -1037,7 +1037,7 @@ static int snapshot_ctr(struct dm_target *ti, unsigned int argc, char **argv)
int i;
int r = -EINVAL;
char *origin_path, *cow_path;
unsigned args_used, num_flush_requests = 1;
unsigned args_used, num_flush_bios = 1;
fmode_t origin_mode = FMODE_READ;
if (argc != 4) {
......@@ -1047,7 +1047,7 @@ static int snapshot_ctr(struct dm_target *ti, unsigned int argc, char **argv)
}
if (dm_target_is_snapshot_merge(ti)) {
num_flush_requests = 2;
num_flush_bios = 2;
origin_mode = FMODE_WRITE;
}
......@@ -1127,7 +1127,7 @@ static int snapshot_ctr(struct dm_target *ti, unsigned int argc, char **argv)
spin_lock_init(&s->tracked_chunk_lock);
ti->private = s;
ti->num_flush_requests = num_flush_requests;
ti->num_flush_bios = num_flush_bios;
ti->per_bio_data_size = sizeof(struct dm_snap_tracked_chunk);
/* Add snapshot to the list of snapshots for this origin */
......@@ -1691,7 +1691,7 @@ static int snapshot_merge_map(struct dm_target *ti, struct bio *bio)
init_tracked_chunk(bio);
if (bio->bi_rw & REQ_FLUSH) {
if (!dm_bio_get_target_request_nr(bio))
if (!dm_bio_get_target_bio_nr(bio))
bio->bi_bdev = s->origin->bdev;
else
bio->bi_bdev = s->cow->bdev;
......@@ -2102,7 +2102,7 @@ static int origin_ctr(struct dm_target *ti, unsigned int argc, char **argv)
}
ti->private = dev;
ti->num_flush_requests = 1;
ti->num_flush_bios = 1;
return 0;
}
......
......@@ -160,9 +160,9 @@ static int stripe_ctr(struct dm_target *ti, unsigned int argc, char **argv)
if (r)
return r;
ti->num_flush_requests = stripes;
ti->num_discard_requests = stripes;
ti->num_write_same_requests = stripes;
ti->num_flush_bios = stripes;
ti->num_discard_bios = stripes;
ti->num_write_same_bios = stripes;
sc->chunk_size = chunk_size;
if (chunk_size & (chunk_size - 1))
......@@ -276,19 +276,19 @@ static int stripe_map(struct dm_target *ti, struct bio *bio)
{
struct stripe_c *sc = ti->private;
uint32_t stripe;
unsigned target_request_nr;
unsigned target_bio_nr;
if (bio->bi_rw & REQ_FLUSH) {
target_request_nr = dm_bio_get_target_request_nr(bio);
BUG_ON(target_request_nr >= sc->stripes);
bio->bi_bdev = sc->stripe[target_request_nr].dev->bdev;
target_bio_nr = dm_bio_get_target_bio_nr(bio);
BUG_ON(target_bio_nr >= sc->stripes);
bio->bi_bdev = sc->stripe[target_bio_nr].dev->bdev;
return DM_MAPIO_REMAPPED;
}
if (unlikely(bio->bi_rw & REQ_DISCARD) ||
unlikely(bio->bi_rw & REQ_WRITE_SAME)) {
target_request_nr = dm_bio_get_target_request_nr(bio);
BUG_ON(target_request_nr >= sc->stripes);
return stripe_map_range(sc, bio, target_request_nr);
target_bio_nr = dm_bio_get_target_bio_nr(bio);
BUG_ON(target_bio_nr >= sc->stripes);
return stripe_map_range(sc, bio, target_bio_nr);
}
stripe_map_sector(sc, bio->bi_sector, &stripe, &bio->bi_sector);
......
......@@ -822,8 +822,8 @@ int dm_table_add_target(struct dm_table *t, const char *type,
t->highs[t->num_targets++] = tgt->begin + tgt->len - 1;
if (!tgt->num_discard_requests && tgt->discards_supported)
DMWARN("%s: %s: ignoring discards_supported because num_discard_requests is zero.",
if (!tgt->num_discard_bios && tgt->discards_supported)
DMWARN("%s: %s: ignoring discards_supported because num_discard_bios is zero.",
dm_device_name(t->md), type);
return 0;
......@@ -1359,7 +1359,7 @@ static bool dm_table_supports_flush(struct dm_table *t, unsigned flush)
while (i < dm_table_get_num_targets(t)) {
ti = dm_table_get_target(t, i++);
if (!ti->num_flush_requests)
if (!ti->num_flush_bios)
continue;
if (ti->flush_supported)
......@@ -1438,7 +1438,7 @@ static bool dm_table_supports_write_same(struct dm_table *t)
while (i < dm_table_get_num_targets(t)) {
ti = dm_table_get_target(t, i++);
if (!ti->num_write_same_requests)
if (!ti->num_write_same_bios)
return false;
if (!ti->type->iterate_devices ||
......@@ -1656,7 +1656,7 @@ bool dm_table_supports_discards(struct dm_table *t)
while (i < dm_table_get_num_targets(t)) {
ti = dm_table_get_target(t, i++);
if (!ti->num_discard_requests)
if (!ti->num_discard_bios)
continue;
if (ti->discards_supported)
......
......@@ -116,7 +116,7 @@ static int io_err_ctr(struct dm_target *tt, unsigned int argc, char **args)
/*
* Return error for discards instead of -EOPNOTSUPP
*/
tt->num_discard_requests = 1;
tt->num_discard_bios = 1;
return 0;
}
......
......@@ -1944,7 +1944,7 @@ static int pool_ctr(struct dm_target *ti, unsigned argc, char **argv)
pt->data_dev = data_dev;
pt->low_water_blocks = low_water_blocks;
pt->adjusted_pf = pt->requested_pf = pf;
ti->num_flush_requests = 1;
ti->num_flush_bios = 1;
/*
* Only need to enable discards if the pool should pass
......@@ -1952,7 +1952,7 @@ static int pool_ctr(struct dm_target *ti, unsigned argc, char **argv)
* processing will cause mappings to be removed from the btree.
*/
if (pf.discard_enabled && pf.discard_passdown) {
ti->num_discard_requests = 1;
ti->num_discard_bios = 1;
/*
* Setting 'discards_supported' circumvents the normal
......@@ -2593,17 +2593,17 @@ static int thin_ctr(struct dm_target *ti, unsigned argc, char **argv)
if (r)
goto bad_thin_open;
ti->num_flush_requests = 1;
ti->num_flush_bios = 1;
ti->flush_supported = true;
ti->per_bio_data_size = sizeof(struct dm_thin_endio_hook);
/* In case the pool supports discards, pass them on. */
if (tc->pool->pf.discard_enabled) {
ti->discards_supported = true;
ti->num_discard_requests = 1;
ti->num_discard_bios = 1;
ti->discard_zeroes_data_unsupported = true;
/* Discard requests must be split on a block boundary */
ti->split_discard_requests = true;
/* Discard bios must be split on a block boundary */
ti->split_discard_bios = true;
}
dm_put(pool_md);
......
......@@ -25,7 +25,7 @@ static int zero_ctr(struct dm_target *ti, unsigned int argc, char **argv)
/*
* Silently drop discards, avoiding -EOPNOTSUPP.
*/
ti->num_discard_requests = 1;
ti->num_discard_bios = 1;
return 0;
}
......
......@@ -1103,7 +1103,7 @@ static void clone_bio(struct dm_target_io *tio, struct bio *bio,
static struct dm_target_io *alloc_tio(struct clone_info *ci,
struct dm_target *ti, int nr_iovecs,
unsigned target_request_nr)
unsigned target_bio_nr)
{
struct dm_target_io *tio;
struct bio *clone;
......@@ -1114,15 +1114,15 @@ static struct dm_target_io *alloc_tio(struct clone_info *ci,
tio->io = ci->io;
tio->ti = ti;
memset(&tio->info, 0, sizeof(tio->info));
tio->target_request_nr = target_request_nr;
tio->target_bio_nr = target_bio_nr;
return tio;
}
static void __issue_target_request(struct clone_info *ci, struct dm_target *ti,
unsigned request_nr, sector_t len)
unsigned target_bio_nr, sector_t len)
{
struct dm_target_io *tio = alloc_tio(ci, ti, ci->bio->bi_max_vecs, request_nr);
struct dm_target_io *tio = alloc_tio(ci, ti, ci->bio->bi_max_vecs, target_bio_nr);
struct bio *clone = &tio->clone;
/*
......@@ -1137,13 +1137,13 @@ static void __issue_target_request(struct clone_info *ci, struct dm_target *ti,
__map_bio(tio);
}
static void __issue_target_requests(struct clone_info *ci, struct dm_target *ti,
unsigned num_requests, sector_t len)
static void __issue_target_bios(struct clone_info *ci, struct dm_target *ti,
unsigned num_bios, sector_t len)
{
unsigned request_nr;
unsigned target_bio_nr;
for (request_nr = 0; request_nr < num_requests; request_nr++)
__issue_target_request(ci, ti, request_nr, len);
for (target_bio_nr = 0; target_bio_nr < num_bios; target_bio_nr++)
__issue_target_request(ci, ti, target_bio_nr, len);
}
static int __clone_and_map_empty_flush(struct clone_info *ci)
......@@ -1153,7 +1153,7 @@ static int __clone_and_map_empty_flush(struct clone_info *ci)
BUG_ON(bio_has_data(ci->bio));
while ((ti = dm_table_get_target(ci->map, target_nr++)))
__issue_target_requests(ci, ti, ti->num_flush_requests, 0);
__issue_target_bios(ci, ti, ti->num_flush_bios, 0);
return 0;
}
......@@ -1173,32 +1173,32 @@ static void __clone_and_map_simple(struct clone_info *ci, struct dm_target *ti)
ci->sector_count = 0;
}
typedef unsigned (*get_num_requests_fn)(struct dm_target *ti);
typedef unsigned (*get_num_bios_fn)(struct dm_target *ti);
static unsigned get_num_discard_requests(struct dm_target *ti)
static unsigned get_num_discard_bios(struct dm_target *ti)
{
return ti->num_discard_requests;
return ti->num_discard_bios;
}
static unsigned get_num_write_same_requests(struct dm_target *ti)
static unsigned get_num_write_same_bios(struct dm_target *ti)
{
return ti->num_write_same_requests;
return ti->num_write_same_bios;
}
typedef bool (*is_split_required_fn)(struct dm_target *ti);
static bool is_split_required_for_discard(struct dm_target *ti)
{
return ti->split_discard_requests;
return ti->split_discard_bios;
}
static int __clone_and_map_changing_extent_only(struct clone_info *ci,
get_num_requests_fn get_num_requests,
get_num_bios_fn get_num_bios,
is_split_required_fn is_split_required)
{
struct dm_target *ti;
sector_t len;
unsigned num_requests;
unsigned num_bios;
do {
ti = dm_table_find_target(ci->map, ci->sector);
......@@ -1211,8 +1211,8 @@ static int __clone_and_map_changing_extent_only(struct clone_info *ci,
* reconfiguration might also have changed that since the
* check was performed.
*/
num_requests = get_num_requests ? get_num_requests(ti) : 0;
if (!num_requests)
num_bios = get_num_bios ? get_num_bios(ti) : 0;
if (!num_bios)
return -EOPNOTSUPP;
if (is_split_required && !is_split_required(ti))
......@@ -1220,7 +1220,7 @@ static int __clone_and_map_changing_extent_only(struct clone_info *ci,
else
len = min(ci->sector_count, max_io_len(ci->sector, ti));
__issue_target_requests(ci, ti, num_requests, len);
__issue_target_bios(ci, ti, num_bios, len);
ci->sector += len;
} while (ci->sector_count -= len);
......@@ -1230,13 +1230,13 @@ static int __clone_and_map_changing_extent_only(struct clone_info *ci,
static int __clone_and_map_discard(struct clone_info *ci)
{
return __clone_and_map_changing_extent_only(ci, get_num_discard_requests,
return __clone_and_map_changing_extent_only(ci, get_num_discard_bios,
is_split_required_for_discard);
}
static int __clone_and_map_write_same(struct clone_info *ci)
{
return __clone_and_map_changing_extent_only(ci, get_num_write_same_requests, NULL);
return __clone_and_map_changing_extent_only(ci, get_num_write_same_bios, NULL);
}
static int __clone_and_map(struct clone_info *ci)
......
......@@ -187,26 +187,26 @@ struct dm_target {
uint32_t max_io_len;
/*
* A number of zero-length barrier requests that will be submitted
* A number of zero-length barrier bios that will be submitted
* to the target for the purpose of flushing cache.
*
* The request number can be accessed with dm_bio_get_target_request_nr.
* It is a responsibility of the target driver to remap these requests
* The bio number can be accessed with dm_bio_get_target_bio_nr.
* It is a responsibility of the target driver to remap these bios
* to the real underlying devices.
*/
unsigned num_flush_requests;
unsigned num_flush_bios;
/*
* The number of discard requests that will be submitted to the target.
* The request number can be accessed with dm_bio_get_target_request_nr.
* The number of discard bios that will be submitted to the target.
* The bio number can be accessed with dm_bio_get_target_bio_nr.
*/
unsigned num_discard_requests;
unsigned num_discard_bios;
/*
* The number of WRITE SAME requests that will be submitted to the target.
* The request number can be accessed with dm_bio_get_target_request_nr.
* The number of WRITE SAME bios that will be submitted to the target.
* The bio number can be accessed with dm_bio_get_target_bio_nr.
*/
unsigned num_write_same_requests;
unsigned num_write_same_bios;
/*
* The minimum number of extra bytes allocated in each bio for the
......@@ -233,10 +233,10 @@ struct dm_target {
bool discards_supported:1;
/*
* Set if the target required discard request to be split
* Set if the target required discard bios to be split
* on max_io_len boundary.
*/
bool split_discard_requests:1;
bool split_discard_bios:1;
/*
* Set if this target does not return zeroes on discarded blocks.
......@@ -261,7 +261,7 @@ struct dm_target_io {
struct dm_io *io;
struct dm_target *ti;
union map_info info;
unsigned target_request_nr;
unsigned target_bio_nr;
struct bio clone;
};
......@@ -275,9 +275,9 @@ static inline struct bio *dm_bio_from_per_bio_data(void *data, size_t data_size)
return (struct bio *)((char *)data + data_size + offsetof(struct dm_target_io, clone));
}
static inline unsigned dm_bio_get_target_request_nr(const struct bio *bio)
static inline unsigned dm_bio_get_target_bio_nr(const struct bio *bio)
{
return container_of(bio, struct dm_target_io, clone)->target_request_nr;
return container_of(bio, struct dm_target_io, clone)->target_bio_nr;
}
int dm_register_target(struct target_type *t);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册