From 7b8650c5fb5a970d0da4e837c415aa781a9d5e2e Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Tue, 8 Oct 1996 18:41:11 +0000 Subject: (store_ileave_create, store_concat_create): Add common backend flags from children to parent's flags. (stripe_set_flags, stripe_clear_flags): New functions. --- libstore/stripe.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 53 insertions(+), 2 deletions(-) (limited to 'libstore') diff --git a/libstore/stripe.c b/libstore/stripe.c index 4dab198f..9db2b8bb 100644 --- a/libstore/stripe.c +++ b/libstore/stripe.c @@ -59,6 +59,50 @@ stripe_write (struct store *store, store_write (stripe, addr_adj (addr, store, stripe), buf, len, amount); } +error_t +stripe_set_flags (struct store *store, int flags) +{ + int i; + error_t err = 0; + int old_flags[store->num_children]; + + for (i = 0; i < store->num_children && !err; i++) + { + old_flags[i] = store->children[i]->flags; + err = store_set_flags (store->children[i], flags); + } + + if (err) + while (i > 0) + store_clear_flags (store->children[--i], flags & ~old_flags[i]); + else + store->flags |= flags; + + return err; +} + +error_t +stripe_clear_flags (struct store *store, int flags) +{ + int i; + error_t err = 0; + int old_flags[store->num_children]; + + for (i = 0; i < store->num_children && !err; i++) + { + old_flags[i] = store->children[i]->flags; + err = store_clear_flags (store->children[i], flags); + } + + if (err) + while (i > 0) + store_set_flags (store->children[--i], flags & ~old_flags[i]); + else + store->flags &= ~flags; + + return err; +} + error_t stripe_remap (struct store *source, const struct store_run *runs, size_t num_runs, @@ -168,6 +212,7 @@ store_ileave_create (struct store *const *stripes, size_t num_stripes, error_t err; off_t block_size = 1, min_end = 0; struct store_run runs[num_stripes]; + int common_flags = STORE_BACKEND_FLAGS; /* Find a common block size. */ for (i = 0; i < num_stripes; i++) @@ -194,9 +239,12 @@ store_ileave_create (struct store *const *stripes, size_t num_stripes, else if (min_end > end) /* Only use as much space as the smallest stripe has. */ min_end = end; + + common_flags &= stripes[i]->flags; } - *store = _make_store (&store_ileave_class, MACH_PORT_NULL, flags, block_size, + *store = _make_store (&store_ileave_class, MACH_PORT_NULL, + common_flags | flags, block_size, runs, num_stripes, min_end); if (! *store) return ENOMEM; @@ -221,6 +269,7 @@ store_concat_create (struct store * const *stores, size_t num_stores, size_t i; error_t err; off_t block_size = 1; + int common_flags = STORE_BACKEND_FLAGS; struct store_run runs[num_stores]; /* Find a common block size. */ @@ -231,9 +280,11 @@ store_concat_create (struct store * const *stores, size_t num_stores, { runs[i].start = 0; runs[i].length = stores[i]->end; + common_flags &= stores[i]->flags; } - *store = _make_store (&store_concat_class, MACH_PORT_NULL, flags, block_size, + *store = _make_store (&store_concat_class, MACH_PORT_NULL, + flags | common_flags, block_size, runs, num_stores * 2, 0); if (! *store) return ENOMEM; -- cgit v1.2.3