diff options
author | David Teigland <teigland@redhat.com> | 2011-10-20 14:26:28 -0400 |
---|---|---|
committer | David Teigland <teigland@redhat.com> | 2012-01-04 09:55:57 -0500 |
commit | 757a42719635495779462514458bbfbf12a37dac (patch) | |
tree | be6ea155fc54c397cb57eb193b81824b37989e56 /fs/dlm/recover.c | |
parent | f95a34c66554235b70a681fcd9feebc195f7ec0e (diff) |
dlm: add node slots and generation
Slot numbers are assigned to nodes when they join the lockspace.
The slot number chosen is the minimum unused value starting at 1.
Once a node is assigned a slot, that slot number will not change
while the node remains a lockspace member. If the node leaves
and rejoins it can be assigned a new slot number.
A new generation number is also added to a lockspace. It is
set and incremented during each recovery along with the slot
collection/assignment.
The slot numbers will be passed to gfs2 which will use them as
journal id's.
Signed-off-by: David Teigland <teigland@redhat.com>
Diffstat (limited to 'fs/dlm/recover.c')
-rw-r--r-- | fs/dlm/recover.c | 64 |
1 files changed, 56 insertions, 8 deletions
diff --git a/fs/dlm/recover.c b/fs/dlm/recover.c index 81b239304495..34d5adf1fce7 100644 --- a/fs/dlm/recover.c +++ b/fs/dlm/recover.c | |||
@@ -85,14 +85,20 @@ uint32_t dlm_recover_status(struct dlm_ls *ls) | |||
85 | return status; | 85 | return status; |
86 | } | 86 | } |
87 | 87 | ||
88 | static void _set_recover_status(struct dlm_ls *ls, uint32_t status) | ||
89 | { | ||
90 | ls->ls_recover_status |= status; | ||
91 | } | ||
92 | |||
88 | void dlm_set_recover_status(struct dlm_ls *ls, uint32_t status) | 93 | void dlm_set_recover_status(struct dlm_ls *ls, uint32_t status) |
89 | { | 94 | { |
90 | spin_lock(&ls->ls_recover_lock); | 95 | spin_lock(&ls->ls_recover_lock); |
91 | ls->ls_recover_status |= status; | 96 | _set_recover_status(ls, status); |
92 | spin_unlock(&ls->ls_recover_lock); | 97 | spin_unlock(&ls->ls_recover_lock); |
93 | } | 98 | } |
94 | 99 | ||
95 | static int wait_status_all(struct dlm_ls *ls, uint32_t wait_status) | 100 | static int wait_status_all(struct dlm_ls *ls, uint32_t wait_status, |
101 | int save_slots) | ||
96 | { | 102 | { |
97 | struct dlm_rcom *rc = ls->ls_recover_buf; | 103 | struct dlm_rcom *rc = ls->ls_recover_buf; |
98 | struct dlm_member *memb; | 104 | struct dlm_member *memb; |
@@ -106,10 +112,13 @@ static int wait_status_all(struct dlm_ls *ls, uint32_t wait_status) | |||
106 | goto out; | 112 | goto out; |
107 | } | 113 | } |
108 | 114 | ||
109 | error = dlm_rcom_status(ls, memb->nodeid); | 115 | error = dlm_rcom_status(ls, memb->nodeid, 0); |
110 | if (error) | 116 | if (error) |
111 | goto out; | 117 | goto out; |
112 | 118 | ||
119 | if (save_slots) | ||
120 | dlm_slot_save(ls, rc, memb); | ||
121 | |||
113 | if (rc->rc_result & wait_status) | 122 | if (rc->rc_result & wait_status) |
114 | break; | 123 | break; |
115 | if (delay < 1000) | 124 | if (delay < 1000) |
@@ -121,7 +130,8 @@ static int wait_status_all(struct dlm_ls *ls, uint32_t wait_status) | |||
121 | return error; | 130 | return error; |
122 | } | 131 | } |
123 | 132 | ||
124 | static int wait_status_low(struct dlm_ls *ls, uint32_t wait_status) | 133 | static int wait_status_low(struct dlm_ls *ls, uint32_t wait_status, |
134 | uint32_t status_flags) | ||
125 | { | 135 | { |
126 | struct dlm_rcom *rc = ls->ls_recover_buf; | 136 | struct dlm_rcom *rc = ls->ls_recover_buf; |
127 | int error = 0, delay = 0, nodeid = ls->ls_low_nodeid; | 137 | int error = 0, delay = 0, nodeid = ls->ls_low_nodeid; |
@@ -132,7 +142,7 @@ static int wait_status_low(struct dlm_ls *ls, uint32_t wait_status) | |||
132 | goto out; | 142 | goto out; |
133 | } | 143 | } |
134 | 144 | ||
135 | error = dlm_rcom_status(ls, nodeid); | 145 | error = dlm_rcom_status(ls, nodeid, status_flags); |
136 | if (error) | 146 | if (error) |
137 | break; | 147 | break; |
138 | 148 | ||
@@ -152,18 +162,56 @@ static int wait_status(struct dlm_ls *ls, uint32_t status) | |||
152 | int error; | 162 | int error; |
153 | 163 | ||
154 | if (ls->ls_low_nodeid == dlm_our_nodeid()) { | 164 | if (ls->ls_low_nodeid == dlm_our_nodeid()) { |
155 | error = wait_status_all(ls, status); | 165 | error = wait_status_all(ls, status, 0); |
156 | if (!error) | 166 | if (!error) |
157 | dlm_set_recover_status(ls, status_all); | 167 | dlm_set_recover_status(ls, status_all); |
158 | } else | 168 | } else |
159 | error = wait_status_low(ls, status_all); | 169 | error = wait_status_low(ls, status_all, 0); |
160 | 170 | ||
161 | return error; | 171 | return error; |
162 | } | 172 | } |
163 | 173 | ||
164 | int dlm_recover_members_wait(struct dlm_ls *ls) | 174 | int dlm_recover_members_wait(struct dlm_ls *ls) |
165 | { | 175 | { |
166 | return wait_status(ls, DLM_RS_NODES); | 176 | struct dlm_member *memb; |
177 | struct dlm_slot *slots; | ||
178 | int num_slots, slots_size; | ||
179 | int error, rv; | ||
180 | uint32_t gen; | ||
181 | |||
182 | list_for_each_entry(memb, &ls->ls_nodes, list) { | ||
183 | memb->slot = -1; | ||
184 | memb->generation = 0; | ||
185 | } | ||
186 | |||
187 | if (ls->ls_low_nodeid == dlm_our_nodeid()) { | ||
188 | error = wait_status_all(ls, DLM_RS_NODES, 1); | ||
189 | if (error) | ||
190 | goto out; | ||
191 | |||
192 | /* slots array is sparse, slots_size may be > num_slots */ | ||
193 | |||
194 | rv = dlm_slots_assign(ls, &num_slots, &slots_size, &slots, &gen); | ||
195 | if (!rv) { | ||
196 | spin_lock(&ls->ls_recover_lock); | ||
197 | _set_recover_status(ls, DLM_RS_NODES_ALL); | ||
198 | ls->ls_num_slots = num_slots; | ||
199 | ls->ls_slots_size = slots_size; | ||
200 | ls->ls_slots = slots; | ||
201 | ls->ls_generation = gen; | ||
202 | spin_unlock(&ls->ls_recover_lock); | ||
203 | } else { | ||
204 | dlm_set_recover_status(ls, DLM_RS_NODES_ALL); | ||
205 | } | ||
206 | } else { | ||
207 | error = wait_status_low(ls, DLM_RS_NODES_ALL, DLM_RSF_NEED_SLOTS); | ||
208 | if (error) | ||
209 | goto out; | ||
210 | |||
211 | dlm_slots_copy_in(ls); | ||
212 | } | ||
213 | out: | ||
214 | return error; | ||
167 | } | 215 | } |
168 | 216 | ||
169 | int dlm_recover_directory_wait(struct dlm_ls *ls) | 217 | int dlm_recover_directory_wait(struct dlm_ls *ls) |