author | Chris Kirby <Chris.Kirby@oracle.com> |
Thu, 10 Jun 2010 15:46:47 -0600 | |
changeset 12605 | 6790e683d5a5 |
parent 11958 | 575ffe1e978d |
child 13570 | 3411fd5f1589 |
permissions | -rw-r--r-- |
789 | 1 |
/* |
2 |
* CDDL HEADER START |
|
3 |
* |
|
4 |
* The contents of this file are subject to the terms of the |
|
1544 | 5 |
* Common Development and Distribution License (the "License"). |
6 |
* You may not use this file except in compliance with the License. |
|
789 | 7 |
* |
8 |
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE |
|
9 |
* or http://www.opensolaris.org/os/licensing. |
|
10 |
* See the License for the specific language governing permissions |
|
11 |
* and limitations under the License. |
|
12 |
* |
|
13 |
* When distributing Covered Code, include this CDDL HEADER in each |
|
14 |
* file and include the License file at usr/src/OPENSOLARIS.LICENSE. |
|
15 |
* If applicable, add the following below this CDDL HEADER, with the |
|
16 |
* fields enclosed by brackets "[]" replaced with your own identifying |
|
17 |
* information: Portions Copyright [yyyy] [name of copyright owner] |
|
18 |
* |
|
19 |
* CDDL HEADER END |
|
20 |
*/ |
|
21 |
/* |
|
11958
575ffe1e978d
6923585 deadlock while booting OpenSolaris build 132 from mirrored rpool with removed submirror
George Wilson <George.Wilson@Sun.COM>
parents:
9846
diff
changeset
|
22 |
* Copyright 2010 Sun Microsystems, Inc. All rights reserved. |
789 | 23 |
* Use is subject to license terms. |
24 |
*/ |
|
25 |
||
26 |
#include <sys/zfs_context.h> |
|
27 |
#include <sys/spa.h> |
|
28 |
#include <sys/vdev_impl.h> |
|
29 |
#include <sys/zio.h> |
|
30 |
#include <sys/fs/zfs.h> |
|
31 |
||
32 |
/* |
|
33 |
* Virtual device vector for the pool's root vdev. |
|
34 |
*/ |
|
35 |
||
1775
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
36 |
/* |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
37 |
* We should be able to tolerate one failure with absolutely no damage |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
38 |
* to our metadata. Two failures will take out space maps, a bunch of |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
39 |
* indirect block trees, meta dnodes, dnodes, etc. Probably not a happy |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
40 |
* place to live. When we get smarter, we can liberalize this policy. |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
41 |
* e.g. If we haven't lost two consecutive top-level vdevs, then we are |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
42 |
* probably fine. Adding bean counters during alloc/free can make this |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
43 |
* future guesswork more accurate. |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
44 |
*/ |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
45 |
static int |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
46 |
too_many_errors(vdev_t *vd, int numerrors) |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
47 |
{ |
5329 | 48 |
ASSERT3U(numerrors, <=, vd->vdev_children); |
6976
cae5f06df471
PSARC 2008/388 Short circuit for vdev probe failure
eschrock
parents:
5329
diff
changeset
|
49 |
return (numerrors > 0); |
1775
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
50 |
} |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
51 |
|
789 | 52 |
static int |
53 |
vdev_root_open(vdev_t *vd, uint64_t *asize, uint64_t *ashift) |
|
54 |
{ |
|
55 |
int lasterror = 0; |
|
1775
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
56 |
int numerrors = 0; |
789 | 57 |
|
58 |
if (vd->vdev_children == 0) { |
|
59 |
vd->vdev_stat.vs_aux = VDEV_AUX_BAD_LABEL; |
|
60 |
return (EINVAL); |
|
61 |
} |
|
62 |
||
9846
6527c7b4a92e
6566744 vdev_open() should be done in parallel
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7754
diff
changeset
|
63 |
vdev_open_children(vd); |
789 | 64 |
|
9846
6527c7b4a92e
6566744 vdev_open() should be done in parallel
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7754
diff
changeset
|
65 |
for (int c = 0; c < vd->vdev_children; c++) { |
6527c7b4a92e
6566744 vdev_open() should be done in parallel
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7754
diff
changeset
|
66 |
vdev_t *cvd = vd->vdev_child[c]; |
6527c7b4a92e
6566744 vdev_open() should be done in parallel
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7754
diff
changeset
|
67 |
|
6527c7b4a92e
6566744 vdev_open() should be done in parallel
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7754
diff
changeset
|
68 |
if (cvd->vdev_open_error && !cvd->vdev_islog) { |
6527c7b4a92e
6566744 vdev_open() should be done in parallel
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7754
diff
changeset
|
69 |
lasterror = cvd->vdev_open_error; |
1775
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
70 |
numerrors++; |
789 | 71 |
} |
72 |
} |
|
73 |
||
6976
cae5f06df471
PSARC 2008/388 Short circuit for vdev probe failure
eschrock
parents:
5329
diff
changeset
|
74 |
if (too_many_errors(vd, numerrors)) { |
cae5f06df471
PSARC 2008/388 Short circuit for vdev probe failure
eschrock
parents:
5329
diff
changeset
|
75 |
vd->vdev_stat.vs_aux = VDEV_AUX_NO_REPLICAS; |
cae5f06df471
PSARC 2008/388 Short circuit for vdev probe failure
eschrock
parents:
5329
diff
changeset
|
76 |
return (lasterror); |
1775
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
77 |
} |
789 | 78 |
|
1732 | 79 |
*asize = 0; |
80 |
*ashift = 0; |
|
81 |
||
1775
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
82 |
return (0); |
789 | 83 |
} |
84 |
||
85 |
static void |
|
86 |
vdev_root_close(vdev_t *vd) |
|
87 |
{ |
|
9846
6527c7b4a92e
6566744 vdev_open() should be done in parallel
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7754
diff
changeset
|
88 |
for (int c = 0; c < vd->vdev_children; c++) |
789 | 89 |
vdev_close(vd->vdev_child[c]); |
90 |
} |
|
91 |
||
92 |
static void |
|
93 |
vdev_root_state_change(vdev_t *vd, int faulted, int degraded) |
|
94 |
{ |
|
6976
cae5f06df471
PSARC 2008/388 Short circuit for vdev probe failure
eschrock
parents:
5329
diff
changeset
|
95 |
if (too_many_errors(vd, faulted)) { |
cae5f06df471
PSARC 2008/388 Short circuit for vdev probe failure
eschrock
parents:
5329
diff
changeset
|
96 |
vdev_set_state(vd, B_FALSE, VDEV_STATE_CANT_OPEN, |
cae5f06df471
PSARC 2008/388 Short circuit for vdev probe failure
eschrock
parents:
5329
diff
changeset
|
97 |
VDEV_AUX_NO_REPLICAS); |
5329 | 98 |
} else if (degraded) { |
1544 | 99 |
vdev_set_state(vd, B_FALSE, VDEV_STATE_DEGRADED, VDEV_AUX_NONE); |
5329 | 100 |
} else { |
1544 | 101 |
vdev_set_state(vd, B_FALSE, VDEV_STATE_HEALTHY, VDEV_AUX_NONE); |
5329 | 102 |
} |
789 | 103 |
} |
104 |
||
105 |
vdev_ops_t vdev_root_ops = { |
|
106 |
vdev_root_open, |
|
107 |
vdev_root_close, |
|
108 |
vdev_default_asize, |
|
109 |
NULL, /* io_start - not applicable to the root */ |
|
110 |
NULL, /* io_done - not applicable to the root */ |
|
111 |
vdev_root_state_change, |
|
11958
575ffe1e978d
6923585 deadlock while booting OpenSolaris build 132 from mirrored rpool with removed submirror
George Wilson <George.Wilson@Sun.COM>
parents:
9846
diff
changeset
|
112 |
NULL, |
575ffe1e978d
6923585 deadlock while booting OpenSolaris build 132 from mirrored rpool with removed submirror
George Wilson <George.Wilson@Sun.COM>
parents:
9846
diff
changeset
|
113 |
NULL, |
789 | 114 |
VDEV_TYPE_ROOT, /* name of this vdev type */ |
115 |
B_FALSE /* not a leaf vdev */ |
|
116 |
}; |