diff options
author | NeilBrown <neilb@suse.de> | 2011-12-22 18:17:54 -0500 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2011-12-22 18:17:54 -0500 |
commit | 69335ef3bc5b766f34db2d688be1d35313138bca (patch) | |
tree | dcd87ffc4c97540d374a20de7380368e3679ac3b /drivers/md/raid10.h | |
parent | 3a6de2924af602f9c1b5a5154438c37f2d712dfa (diff) |
md/raid10: prepare data structures for handling replacement.
Allow each slot in the RAID10 to have 2 devices, the want_replacement
and the replacement.
Also an r10bio to have 2 bios, and for resync/recovery allocate the
second bio if there are any replacement devices.
Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'drivers/md/raid10.h')
-rw-r--r-- | drivers/md/raid10.h | 61 |
1 files changed, 37 insertions, 24 deletions
diff --git a/drivers/md/raid10.h b/drivers/md/raid10.h index 7facfdf841f4..7c615613c381 100644 --- a/drivers/md/raid10.h +++ b/drivers/md/raid10.h | |||
@@ -2,7 +2,7 @@ | |||
2 | #define _RAID10_H | 2 | #define _RAID10_H |
3 | 3 | ||
4 | struct mirror_info { | 4 | struct mirror_info { |
5 | struct md_rdev *rdev; | 5 | struct md_rdev *rdev, *replacement; |
6 | sector_t head_position; | 6 | sector_t head_position; |
7 | int recovery_disabled; /* matches | 7 | int recovery_disabled; /* matches |
8 | * mddev->recovery_disabled | 8 | * mddev->recovery_disabled |
@@ -18,12 +18,13 @@ struct r10conf { | |||
18 | spinlock_t device_lock; | 18 | spinlock_t device_lock; |
19 | 19 | ||
20 | /* geometry */ | 20 | /* geometry */ |
21 | int near_copies; /* number of copies laid out raid0 style */ | 21 | int near_copies; /* number of copies laid out |
22 | * raid0 style */ | ||
22 | int far_copies; /* number of copies laid out | 23 | int far_copies; /* number of copies laid out |
23 | * at large strides across drives | 24 | * at large strides across drives |
24 | */ | 25 | */ |
25 | int far_offset; /* far_copies are offset by 1 stripe | 26 | int far_offset; /* far_copies are offset by 1 |
26 | * instead of many | 27 | * stripe instead of many |
27 | */ | 28 | */ |
28 | int copies; /* near_copies * far_copies. | 29 | int copies; /* near_copies * far_copies. |
29 | * must be <= raid_disks | 30 | * must be <= raid_disks |
@@ -34,10 +35,11 @@ struct r10conf { | |||
34 | * 1 stripe. | 35 | * 1 stripe. |
35 | */ | 36 | */ |
36 | 37 | ||
37 | sector_t dev_sectors; /* temp copy of mddev->dev_sectors */ | 38 | sector_t dev_sectors; /* temp copy of |
39 | * mddev->dev_sectors */ | ||
38 | 40 | ||
39 | int chunk_shift; /* shift from chunks to sectors */ | 41 | int chunk_shift; /* shift from chunks to sectors */ |
40 | sector_t chunk_mask; | 42 | sector_t chunk_mask; |
41 | 43 | ||
42 | struct list_head retry_list; | 44 | struct list_head retry_list; |
43 | /* queue pending writes and submit them on unplug */ | 45 | /* queue pending writes and submit them on unplug */ |
@@ -45,20 +47,22 @@ struct r10conf { | |||
45 | int pending_count; | 47 | int pending_count; |
46 | 48 | ||
47 | spinlock_t resync_lock; | 49 | spinlock_t resync_lock; |
48 | int nr_pending; | 50 | int nr_pending; |
49 | int nr_waiting; | 51 | int nr_waiting; |
50 | int nr_queued; | 52 | int nr_queued; |
51 | int barrier; | 53 | int barrier; |
52 | sector_t next_resync; | 54 | sector_t next_resync; |
53 | int fullsync; /* set to 1 if a full sync is needed, | 55 | int fullsync; /* set to 1 if a full sync is needed, |
54 | * (fresh device added). | 56 | * (fresh device added). |
55 | * Cleared when a sync completes. | 57 | * Cleared when a sync completes. |
56 | */ | 58 | */ |
57 | 59 | int have_replacement; /* There is at least one | |
60 | * replacement device. | ||
61 | */ | ||
58 | wait_queue_head_t wait_barrier; | 62 | wait_queue_head_t wait_barrier; |
59 | 63 | ||
60 | mempool_t *r10bio_pool; | 64 | mempool_t *r10bio_pool; |
61 | mempool_t *r10buf_pool; | 65 | mempool_t *r10buf_pool; |
62 | struct page *tmppage; | 66 | struct page *tmppage; |
63 | 67 | ||
64 | /* When taking over an array from a different personality, we store | 68 | /* When taking over an array from a different personality, we store |
@@ -98,11 +102,18 @@ struct r10bio { | |||
98 | * When resyncing we also use one for each copy. | 102 | * When resyncing we also use one for each copy. |
99 | * When reconstructing, we use 2 bios, one for read, one for write. | 103 | * When reconstructing, we use 2 bios, one for read, one for write. |
100 | * We choose the number when they are allocated. | 104 | * We choose the number when they are allocated. |
105 | * We sometimes need an extra bio to write to the replacement. | ||
101 | */ | 106 | */ |
102 | struct { | 107 | struct { |
103 | struct bio *bio; | 108 | struct bio *bio; |
104 | sector_t addr; | 109 | union { |
105 | int devnum; | 110 | struct bio *repl_bio; /* used for resync and |
111 | * writes */ | ||
112 | struct md_rdev *rdev; /* used for reads | ||
113 | * (read_slot >= 0) */ | ||
114 | }; | ||
115 | sector_t addr; | ||
116 | int devnum; | ||
106 | } devs[0]; | 117 | } devs[0]; |
107 | }; | 118 | }; |
108 | 119 | ||
@@ -121,17 +132,19 @@ struct r10bio { | |||
121 | #define BIO_SPECIAL(bio) ((unsigned long)bio <= 2) | 132 | #define BIO_SPECIAL(bio) ((unsigned long)bio <= 2) |
122 | 133 | ||
123 | /* bits for r10bio.state */ | 134 | /* bits for r10bio.state */ |
124 | #define R10BIO_Uptodate 0 | 135 | enum r10bio_state { |
125 | #define R10BIO_IsSync 1 | 136 | R10BIO_Uptodate, |
126 | #define R10BIO_IsRecover 2 | 137 | R10BIO_IsSync, |
127 | #define R10BIO_Degraded 3 | 138 | R10BIO_IsRecover, |
139 | R10BIO_Degraded, | ||
128 | /* Set ReadError on bios that experience a read error | 140 | /* Set ReadError on bios that experience a read error |
129 | * so that raid10d knows what to do with them. | 141 | * so that raid10d knows what to do with them. |
130 | */ | 142 | */ |
131 | #define R10BIO_ReadError 4 | 143 | R10BIO_ReadError, |
132 | /* If a write for this request means we can clear some | 144 | /* If a write for this request means we can clear some |
133 | * known-bad-block records, we set this flag. | 145 | * known-bad-block records, we set this flag. |
134 | */ | 146 | */ |
135 | #define R10BIO_MadeGood 5 | 147 | R10BIO_MadeGood, |
136 | #define R10BIO_WriteError 6 | 148 | R10BIO_WriteError, |
149 | }; | ||
137 | #endif | 150 | #endif |