On Tue, Jan 27, 2004 at 08:57:46PM +0100, Christophe Saout wrote: > So, why not removing set_default_limits and leaving the restriction > values at zero and add a function that replaces allo remaining > restrictions that are still zero with the default restrictions when the > table polulation completed after all targets are added? I mean something like that: (don't consider this a serious patch, just to show what I mean) If a target decides to leave the target limits alone (zero) it will not modify the restrictions of the table. If the table only consists of such targets the table restrictions will be set to the "default fallback limits". If there are, let's call them "dummy targets" _and_ real targets the default fallback limits won't get applied. Something like a table that contains a linear target backed by one of your scsi devices and an error target. --- linux.orig/drvers/md/dm-table.c 2004-01-20 16:51:47.000000000 +0100 +++ linux/drvers/md/dm-table.c 2004-01-27 21:03:01.577802264 +0100 @@ -637,14 +637,20 @@ return 0; } -static void set_default_limits(struct io_restrictions *rs) +static void check_for_valid_limits(struct io_restrictions *rs) { - rs->max_sectors = MAX_SECTORS; - rs->max_phys_segments = MAX_PHYS_SEGMENTS; - rs->max_hw_segments = MAX_HW_SEGMENTS; - rs->hardsect_size = 1 << SECTOR_SHIFT; - rs->max_segment_size = MAX_SEGMENT_SIZE; - rs->seg_boundary_mask = -1; + if (!rs->max_sectors) + rs->max_sectors = MAX_SECTORS; + if (!rs->max_phys_segments) + rs->max_phys_segments = MAX_PHYS_SEGMENTS; + if (!rs->max_hw_segments) + rs->max_hw_segments = MAX_HW_SEGMENTS; + if (!rs->hardsect_size) + rs->hardsect_size = 1 << SECTOR_SHIFT; + if (!rs->max_segment_size) + rs->max_segment_size = MAX_SEGMENT_SIZE; + if (!rs->seg_boundary_mask) + rs->seg_boundary_mask = -1; } int dm_table_add_target(struct dm_table *t, const char *type, @@ -659,7 +665,6 @@ tgt = t->targets + t->num_targets; memset(tgt, 0, sizeof(*tgt)); - set_default_limits(&tgt->limits); if (!len) { tgt->error = "zero-length target"; @@ -753,6 +758,8 @@ int r = 0; unsigned int leaf_nodes; + check_for_valid_limits(&t->limits); + /* how many indexes will the btree have ? */ leaf_nodes = dm_div_up(t->num_targets, KEYS_PER_NODE); t->depth = 1 + int_log(leaf_nodes, CHILDREN_PER_NODE);