Commit ab4c1424 authored by Andi Kleen's avatar Andi Kleen Committed by Alasdair G Kergon

dm: support barriers on simple devices

Implement barrier support for single device DM devices

This patch implements barrier support in DM for the common case of dm linear
just remapping a single underlying device. In this case we can safely
pass the barrier through because there can be no reordering between
devices.

 NB. Any DM device might cease to support barriers if it gets
     reconfigured so code must continue to allow for a possible
     -EOPNOTSUPP on every barrier bio submitted.  - agk
Signed-off-by: default avatarAndi Kleen <ak@suse.de>
Signed-off-by: default avatarMikulas Patocka <mpatocka@redhat.com>
Signed-off-by: default avatarAlasdair G Kergon <agk@redhat.com>
parent 7d76345d
...@@ -142,6 +142,7 @@ static struct target_type linear_target = { ...@@ -142,6 +142,7 @@ static struct target_type linear_target = {
.status = linear_status, .status = linear_status,
.ioctl = linear_ioctl, .ioctl = linear_ioctl,
.merge = linear_merge, .merge = linear_merge,
.features = DM_TARGET_SUPPORTS_BARRIERS,
}; };
int __init dm_linear_init(void) int __init dm_linear_init(void)
......
...@@ -38,6 +38,8 @@ struct dm_table { ...@@ -38,6 +38,8 @@ struct dm_table {
sector_t *highs; sector_t *highs;
struct dm_target *targets; struct dm_target *targets;
unsigned barriers_supported:1;
/* /*
* Indicates the rw permissions for the new logical * Indicates the rw permissions for the new logical
* device. This should be a combination of FMODE_READ * device. This should be a combination of FMODE_READ
...@@ -227,6 +229,7 @@ int dm_table_create(struct dm_table **result, fmode_t mode, ...@@ -227,6 +229,7 @@ int dm_table_create(struct dm_table **result, fmode_t mode,
INIT_LIST_HEAD(&t->devices); INIT_LIST_HEAD(&t->devices);
atomic_set(&t->holders, 1); atomic_set(&t->holders, 1);
t->barriers_supported = 1;
if (!num_targets) if (!num_targets)
num_targets = KEYS_PER_NODE; num_targets = KEYS_PER_NODE;
...@@ -728,6 +731,10 @@ int dm_table_add_target(struct dm_table *t, const char *type, ...@@ -728,6 +731,10 @@ int dm_table_add_target(struct dm_table *t, const char *type,
/* FIXME: the plan is to combine high here and then have /* FIXME: the plan is to combine high here and then have
* the merge fn apply the target level restrictions. */ * the merge fn apply the target level restrictions. */
combine_restrictions_low(&t->limits, &tgt->limits); combine_restrictions_low(&t->limits, &tgt->limits);
if (!(tgt->type->features & DM_TARGET_SUPPORTS_BARRIERS))
t->barriers_supported = 0;
return 0; return 0;
bad: bad:
...@@ -772,6 +779,12 @@ int dm_table_complete(struct dm_table *t) ...@@ -772,6 +779,12 @@ int dm_table_complete(struct dm_table *t)
check_for_valid_limits(&t->limits); check_for_valid_limits(&t->limits);
/*
* We only support barriers if there is exactly one underlying device.
*/
if (!list_is_singular(&t->devices))
t->barriers_supported = 0;
/* how many indexes will the btree have ? */ /* how many indexes will the btree have ? */
leaf_nodes = dm_div_up(t->num_targets, KEYS_PER_NODE); leaf_nodes = dm_div_up(t->num_targets, KEYS_PER_NODE);
t->depth = 1 + int_log(leaf_nodes, CHILDREN_PER_NODE); t->depth = 1 + int_log(leaf_nodes, CHILDREN_PER_NODE);
...@@ -986,6 +999,12 @@ struct mapped_device *dm_table_get_md(struct dm_table *t) ...@@ -986,6 +999,12 @@ struct mapped_device *dm_table_get_md(struct dm_table *t)
return t->md; return t->md;
} }
int dm_table_barrier_ok(struct dm_table *t)
{
return t->barriers_supported;
}
EXPORT_SYMBOL(dm_table_barrier_ok);
EXPORT_SYMBOL(dm_vcalloc); EXPORT_SYMBOL(dm_vcalloc);
EXPORT_SYMBOL(dm_get_device); EXPORT_SYMBOL(dm_get_device);
EXPORT_SYMBOL(dm_put_device); EXPORT_SYMBOL(dm_put_device);
......
...@@ -835,7 +835,11 @@ static int __split_bio(struct mapped_device *md, struct bio *bio) ...@@ -835,7 +835,11 @@ static int __split_bio(struct mapped_device *md, struct bio *bio)
ci.map = dm_get_table(md); ci.map = dm_get_table(md);
if (unlikely(!ci.map)) if (unlikely(!ci.map))
return -EIO; return -EIO;
if (unlikely(bio_barrier(bio) && !dm_table_barrier_ok(ci.map))) {
dm_table_put(ci.map);
bio_endio(bio, -EOPNOTSUPP);
return 0;
}
ci.md = md; ci.md = md;
ci.bio = bio; ci.bio = bio;
ci.io = alloc_io(md); ci.io = alloc_io(md);
...@@ -919,15 +923,6 @@ static int dm_request(struct request_queue *q, struct bio *bio) ...@@ -919,15 +923,6 @@ static int dm_request(struct request_queue *q, struct bio *bio)
struct mapped_device *md = q->queuedata; struct mapped_device *md = q->queuedata;
int cpu; int cpu;
/*
* There is no use in forwarding any barrier request since we can't
* guarantee it is (or can be) handled by the targets correctly.
*/
if (unlikely(bio_barrier(bio))) {
bio_endio(bio, -EOPNOTSUPP);
return 0;
}
down_read(&md->io_lock); down_read(&md->io_lock);
cpu = part_stat_lock(); cpu = part_stat_lock();
......
...@@ -51,6 +51,7 @@ int dm_table_any_congested(struct dm_table *t, int bdi_bits); ...@@ -51,6 +51,7 @@ int dm_table_any_congested(struct dm_table *t, int bdi_bits);
* To check the return value from dm_table_find_target(). * To check the return value from dm_table_find_target().
*/ */
#define dm_target_is_valid(t) ((t)->table) #define dm_target_is_valid(t) ((t)->table)
int dm_table_barrier_ok(struct dm_table *t);
/*----------------------------------------------------------------- /*-----------------------------------------------------------------
* A registry of target types. * A registry of target types.
......
...@@ -112,7 +112,14 @@ void dm_put_device(struct dm_target *ti, struct dm_dev *d); ...@@ -112,7 +112,14 @@ void dm_put_device(struct dm_target *ti, struct dm_dev *d);
/* /*
* Information about a target type * Information about a target type
*/ */
/*
* Target features
*/
#define DM_TARGET_SUPPORTS_BARRIERS 0x00000001
struct target_type { struct target_type {
uint64_t features;
const char *name; const char *name;
struct module *module; struct module *module;
unsigned version[3]; unsigned version[3];
......
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