summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorJoel Sing <jsing@cvs.openbsd.org>2010-02-13 22:10:02 +0000
committerJoel Sing <jsing@cvs.openbsd.org>2010-02-13 22:10:02 +0000
commit45b17beb19783d6d175539e9e6353c1cae72f4bf (patch)
tree40cf06e60b43803f064df163c295fd801c729f10 /sys/dev
parent51543d9246922e2a8d85c9f1f1ac38b77dd7a2f0 (diff)
Force chunks into correct order once metadata is attached. This prevents
chunks from being reordered on an existing volume. ok marco@
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/softraid.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/sys/dev/softraid.c b/sys/dev/softraid.c
index 4ef886d0f58..48504172bce 100644
--- a/sys/dev/softraid.c
+++ b/sys/dev/softraid.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: softraid.c,v 1.193 2010/02/13 21:23:36 jsing Exp $ */
+/* $OpenBSD: softraid.c,v 1.194 2010/02/13 22:10:01 jsing Exp $ */
/*
* Copyright (c) 2007, 2008, 2009 Marco Peereboom <marco@peereboom.us>
* Copyright (c) 2008 Chris Kuethe <ckuethe@openbsd.org>
@@ -212,7 +212,7 @@ sr_meta_attach(struct sr_discipline *sd, int chunk_no, int force)
{
struct sr_softc *sc = sd->sd_sc;
struct sr_chunk_head *cl;
- struct sr_chunk *ch_entry;
+ struct sr_chunk *ch_entry, *chunk1, *chunk2;
int rv = 1, i = 0;
DNPRINTF(SR_D_META, "%s: sr_meta_attach(%d)\n", DEVNAME(sc));
@@ -251,6 +251,27 @@ sr_meta_attach(struct sr_discipline *sd, int chunk_no, int force)
if (smd[sd->sd_meta_type].smd_attach(sd, force))
goto bad;
+ /* Force chunks into correct order now that metadata is attached. */
+ SLIST_FOREACH(ch_entry, cl, src_link)
+ SLIST_REMOVE(cl, ch_entry, sr_chunk, src_link);
+ for (i = 0; i < chunk_no; i++) {
+ ch_entry = sd->sd_vol.sv_chunks[i];
+ chunk2 = NULL;
+ SLIST_FOREACH(chunk1, cl, src_link) {
+ if (chunk1->src_meta.scmi.scm_chunk_id >
+ ch_entry->src_meta.scmi.scm_chunk_id)
+ break;
+ chunk2 = chunk1;
+ }
+ if (chunk2 == NULL)
+ SLIST_INSERT_HEAD(cl, ch_entry, src_link);
+ else
+ SLIST_INSERT_AFTER(chunk2, ch_entry, src_link);
+ }
+ i = 0;
+ SLIST_FOREACH(ch_entry, cl, src_link)
+ sd->sd_vol.sv_chunks[i++] = ch_entry;
+
rv = 0;
bad:
return (rv);
@@ -1374,6 +1395,8 @@ sr_meta_native_attach(struct sr_discipline *sd, int force)
if (md->ssdi.ssd_magic == SR_MAGIC) {
sr++;
+ ch_entry->src_meta.scmi.scm_chunk_id =
+ md->ssdi.ssd_chunk_id;
if (d == 0) {
bcopy(&md->ssdi.ssd_uuid, &uuid, sizeof uuid);
expected = md->ssdi.ssd_chunk_no;