diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2008-01-25 02:08:26 -0500 |
---|---|---|
committer | David Teigland <teigland@redhat.com> | 2008-02-04 02:23:14 -0500 |
commit | 163a1859ec6c4c33547bf4613efabf52031566aa (patch) | |
tree | 04a6dc1c69f726c6686d2a731692fddfdf47d2f2 | |
parent | eef7d739c218cb2546cf95686db77de0d76e4122 (diff) |
dlm: do not byteswap rcom_lock
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: David Teigland <teigland@redhat.com>
-rw-r--r-- | fs/dlm/dlm_internal.h | 22 | ||||
-rw-r--r-- | fs/dlm/lock.c | 34 | ||||
-rw-r--r-- | fs/dlm/rcom.c | 14 | ||||
-rw-r--r-- | fs/dlm/util.c | 45 |
4 files changed, 39 insertions, 76 deletions
diff --git a/fs/dlm/dlm_internal.h b/fs/dlm/dlm_internal.h index 65499ceaa516..e73b988995f5 100644 --- a/fs/dlm/dlm_internal.h +++ b/fs/dlm/dlm_internal.h | |||
@@ -416,21 +416,21 @@ struct rcom_config { | |||
416 | }; | 416 | }; |
417 | 417 | ||
418 | struct rcom_lock { | 418 | struct rcom_lock { |
419 | uint32_t rl_ownpid; | 419 | __le32 rl_ownpid; |
420 | uint32_t rl_lkid; | 420 | __le32 rl_lkid; |
421 | uint32_t rl_remid; | 421 | __le32 rl_remid; |
422 | uint32_t rl_parent_lkid; | 422 | __le32 rl_parent_lkid; |
423 | uint32_t rl_parent_remid; | 423 | __le32 rl_parent_remid; |
424 | uint32_t rl_exflags; | 424 | __le32 rl_exflags; |
425 | uint32_t rl_flags; | 425 | __le32 rl_flags; |
426 | uint32_t rl_lvbseq; | 426 | __le32 rl_lvbseq; |
427 | int rl_result; | 427 | __le32 rl_result; |
428 | int8_t rl_rqmode; | 428 | int8_t rl_rqmode; |
429 | int8_t rl_grmode; | 429 | int8_t rl_grmode; |
430 | int8_t rl_status; | 430 | int8_t rl_status; |
431 | int8_t rl_asts; | 431 | int8_t rl_asts; |
432 | uint16_t rl_wait_type; | 432 | __le16 rl_wait_type; |
433 | uint16_t rl_namelen; | 433 | __le16 rl_namelen; |
434 | char rl_name[DLM_RESNAME_MAXLEN]; | 434 | char rl_name[DLM_RESNAME_MAXLEN]; |
435 | char rl_lvb[0]; | 435 | char rl_lvb[0]; |
436 | }; | 436 | }; |
diff --git a/fs/dlm/lock.c b/fs/dlm/lock.c index 2a28048252ed..75176b58ae04 100644 --- a/fs/dlm/lock.c +++ b/fs/dlm/lock.c | |||
@@ -4273,12 +4273,12 @@ static int receive_rcom_lock_args(struct dlm_ls *ls, struct dlm_lkb *lkb, | |||
4273 | int lvblen; | 4273 | int lvblen; |
4274 | 4274 | ||
4275 | lkb->lkb_nodeid = rc->rc_header.h_nodeid; | 4275 | lkb->lkb_nodeid = rc->rc_header.h_nodeid; |
4276 | lkb->lkb_ownpid = rl->rl_ownpid; | 4276 | lkb->lkb_ownpid = le32_to_cpu(rl->rl_ownpid); |
4277 | lkb->lkb_remid = rl->rl_lkid; | 4277 | lkb->lkb_remid = le32_to_cpu(rl->rl_lkid); |
4278 | lkb->lkb_exflags = rl->rl_exflags; | 4278 | lkb->lkb_exflags = le32_to_cpu(rl->rl_exflags); |
4279 | lkb->lkb_flags = rl->rl_flags & 0x0000FFFF; | 4279 | lkb->lkb_flags = le32_to_cpu(rl->rl_flags) & 0x0000FFFF; |
4280 | lkb->lkb_flags |= DLM_IFL_MSTCPY; | 4280 | lkb->lkb_flags |= DLM_IFL_MSTCPY; |
4281 | lkb->lkb_lvbseq = rl->rl_lvbseq; | 4281 | lkb->lkb_lvbseq = le32_to_cpu(rl->rl_lvbseq); |
4282 | lkb->lkb_rqmode = rl->rl_rqmode; | 4282 | lkb->lkb_rqmode = rl->rl_rqmode; |
4283 | lkb->lkb_grmode = rl->rl_grmode; | 4283 | lkb->lkb_grmode = rl->rl_grmode; |
4284 | /* don't set lkb_status because add_lkb wants to itself */ | 4284 | /* don't set lkb_status because add_lkb wants to itself */ |
@@ -4299,7 +4299,8 @@ static int receive_rcom_lock_args(struct dlm_ls *ls, struct dlm_lkb *lkb, | |||
4299 | The real granted mode of these converting locks cannot be determined | 4299 | The real granted mode of these converting locks cannot be determined |
4300 | until all locks have been rebuilt on the rsb (recover_conversion) */ | 4300 | until all locks have been rebuilt on the rsb (recover_conversion) */ |
4301 | 4301 | ||
4302 | if (rl->rl_wait_type == DLM_MSG_CONVERT && middle_conversion(lkb)) { | 4302 | if (rl->rl_wait_type == cpu_to_le16(DLM_MSG_CONVERT) && |
4303 | middle_conversion(lkb)) { | ||
4303 | rl->rl_status = DLM_LKSTS_CONVERT; | 4304 | rl->rl_status = DLM_LKSTS_CONVERT; |
4304 | lkb->lkb_grmode = DLM_LOCK_IV; | 4305 | lkb->lkb_grmode = DLM_LOCK_IV; |
4305 | rsb_set_flag(r, RSB_RECOVER_CONVERT); | 4306 | rsb_set_flag(r, RSB_RECOVER_CONVERT); |
@@ -4326,13 +4327,14 @@ int dlm_recover_master_copy(struct dlm_ls *ls, struct dlm_rcom *rc) | |||
4326 | goto out; | 4327 | goto out; |
4327 | } | 4328 | } |
4328 | 4329 | ||
4329 | error = find_rsb(ls, rl->rl_name, rl->rl_namelen, R_MASTER, &r); | 4330 | error = find_rsb(ls, rl->rl_name, le16_to_cpu(rl->rl_namelen), |
4331 | R_MASTER, &r); | ||
4330 | if (error) | 4332 | if (error) |
4331 | goto out; | 4333 | goto out; |
4332 | 4334 | ||
4333 | lock_rsb(r); | 4335 | lock_rsb(r); |
4334 | 4336 | ||
4335 | lkb = search_remid(r, rc->rc_header.h_nodeid, rl->rl_lkid); | 4337 | lkb = search_remid(r, rc->rc_header.h_nodeid, le32_to_cpu(rl->rl_lkid)); |
4336 | if (lkb) { | 4338 | if (lkb) { |
4337 | error = -EEXIST; | 4339 | error = -EEXIST; |
4338 | goto out_remid; | 4340 | goto out_remid; |
@@ -4355,15 +4357,16 @@ int dlm_recover_master_copy(struct dlm_ls *ls, struct dlm_rcom *rc) | |||
4355 | out_remid: | 4357 | out_remid: |
4356 | /* this is the new value returned to the lock holder for | 4358 | /* this is the new value returned to the lock holder for |
4357 | saving in its process-copy lkb */ | 4359 | saving in its process-copy lkb */ |
4358 | rl->rl_remid = lkb->lkb_id; | 4360 | rl->rl_remid = cpu_to_le32(lkb->lkb_id); |
4359 | 4361 | ||
4360 | out_unlock: | 4362 | out_unlock: |
4361 | unlock_rsb(r); | 4363 | unlock_rsb(r); |
4362 | put_rsb(r); | 4364 | put_rsb(r); |
4363 | out: | 4365 | out: |
4364 | if (error) | 4366 | if (error) |
4365 | log_debug(ls, "recover_master_copy %d %x", error, rl->rl_lkid); | 4367 | log_debug(ls, "recover_master_copy %d %x", error, |
4366 | rl->rl_result = error; | 4368 | le32_to_cpu(rl->rl_lkid)); |
4369 | rl->rl_result = cpu_to_le32(error); | ||
4367 | return error; | 4370 | return error; |
4368 | } | 4371 | } |
4369 | 4372 | ||
@@ -4374,15 +4377,16 @@ int dlm_recover_process_copy(struct dlm_ls *ls, struct dlm_rcom *rc) | |||
4374 | struct dlm_lkb *lkb; | 4377 | struct dlm_lkb *lkb; |
4375 | int error; | 4378 | int error; |
4376 | 4379 | ||
4377 | error = find_lkb(ls, rl->rl_lkid, &lkb); | 4380 | error = find_lkb(ls, le32_to_cpu(rl->rl_lkid), &lkb); |
4378 | if (error) { | 4381 | if (error) { |
4379 | log_error(ls, "recover_process_copy no lkid %x", rl->rl_lkid); | 4382 | log_error(ls, "recover_process_copy no lkid %x", |
4383 | le32_to_cpu(rl->rl_lkid)); | ||
4380 | return error; | 4384 | return error; |
4381 | } | 4385 | } |
4382 | 4386 | ||
4383 | DLM_ASSERT(is_process_copy(lkb), dlm_print_lkb(lkb);); | 4387 | DLM_ASSERT(is_process_copy(lkb), dlm_print_lkb(lkb);); |
4384 | 4388 | ||
4385 | error = rl->rl_result; | 4389 | error = le32_to_cpu(rl->rl_result); |
4386 | 4390 | ||
4387 | r = lkb->lkb_resource; | 4391 | r = lkb->lkb_resource; |
4388 | hold_rsb(r); | 4392 | hold_rsb(r); |
@@ -4401,7 +4405,7 @@ int dlm_recover_process_copy(struct dlm_ls *ls, struct dlm_rcom *rc) | |||
4401 | log_debug(ls, "master copy exists %x", lkb->lkb_id); | 4405 | log_debug(ls, "master copy exists %x", lkb->lkb_id); |
4402 | /* fall through */ | 4406 | /* fall through */ |
4403 | case 0: | 4407 | case 0: |
4404 | lkb->lkb_remid = rl->rl_remid; | 4408 | lkb->lkb_remid = le32_to_cpu(rl->rl_remid); |
4405 | break; | 4409 | break; |
4406 | default: | 4410 | default: |
4407 | log_error(ls, "dlm_recover_process_copy unknown error %d %x", | 4411 | log_error(ls, "dlm_recover_process_copy unknown error %d %x", |
diff --git a/fs/dlm/rcom.c b/fs/dlm/rcom.c index 026824cd3acb..86c1ab99208e 100644 --- a/fs/dlm/rcom.c +++ b/fs/dlm/rcom.c | |||
@@ -299,22 +299,22 @@ static void pack_rcom_lock(struct dlm_rsb *r, struct dlm_lkb *lkb, | |||
299 | { | 299 | { |
300 | memset(rl, 0, sizeof(*rl)); | 300 | memset(rl, 0, sizeof(*rl)); |
301 | 301 | ||
302 | rl->rl_ownpid = lkb->lkb_ownpid; | 302 | rl->rl_ownpid = cpu_to_le32(lkb->lkb_ownpid); |
303 | rl->rl_lkid = lkb->lkb_id; | 303 | rl->rl_lkid = cpu_to_le32(lkb->lkb_id); |
304 | rl->rl_exflags = lkb->lkb_exflags; | 304 | rl->rl_exflags = cpu_to_le32(lkb->lkb_exflags); |
305 | rl->rl_flags = lkb->lkb_flags; | 305 | rl->rl_flags = cpu_to_le32(lkb->lkb_flags); |
306 | rl->rl_lvbseq = lkb->lkb_lvbseq; | 306 | rl->rl_lvbseq = cpu_to_le32(lkb->lkb_lvbseq); |
307 | rl->rl_rqmode = lkb->lkb_rqmode; | 307 | rl->rl_rqmode = lkb->lkb_rqmode; |
308 | rl->rl_grmode = lkb->lkb_grmode; | 308 | rl->rl_grmode = lkb->lkb_grmode; |
309 | rl->rl_status = lkb->lkb_status; | 309 | rl->rl_status = lkb->lkb_status; |
310 | rl->rl_wait_type = lkb->lkb_wait_type; | 310 | rl->rl_wait_type = cpu_to_le16(lkb->lkb_wait_type); |
311 | 311 | ||
312 | if (lkb->lkb_bastaddr) | 312 | if (lkb->lkb_bastaddr) |
313 | rl->rl_asts |= AST_BAST; | 313 | rl->rl_asts |= AST_BAST; |
314 | if (lkb->lkb_astaddr) | 314 | if (lkb->lkb_astaddr) |
315 | rl->rl_asts |= AST_COMP; | 315 | rl->rl_asts |= AST_COMP; |
316 | 316 | ||
317 | rl->rl_namelen = r->res_length; | 317 | rl->rl_namelen = cpu_to_le16(r->res_length); |
318 | memcpy(rl->rl_name, r->res_name, r->res_length); | 318 | memcpy(rl->rl_name, r->res_name, r->res_length); |
319 | 319 | ||
320 | /* FIXME: might we have an lvb without DLM_LKF_VALBLK set ? | 320 | /* FIXME: might we have an lvb without DLM_LKF_VALBLK set ? |
diff --git a/fs/dlm/util.c b/fs/dlm/util.c index 4d9c1f4e1bd1..d3ed6da0b650 100644 --- a/fs/dlm/util.c +++ b/fs/dlm/util.c | |||
@@ -131,36 +131,6 @@ void dlm_message_in(struct dlm_message *ms) | |||
131 | ms->m_result = from_dlm_errno(le32_to_cpu(ms->m_result)); | 131 | ms->m_result = from_dlm_errno(le32_to_cpu(ms->m_result)); |
132 | } | 132 | } |
133 | 133 | ||
134 | static void rcom_lock_out(struct rcom_lock *rl) | ||
135 | { | ||
136 | rl->rl_ownpid = cpu_to_le32(rl->rl_ownpid); | ||
137 | rl->rl_lkid = cpu_to_le32(rl->rl_lkid); | ||
138 | rl->rl_remid = cpu_to_le32(rl->rl_remid); | ||
139 | rl->rl_parent_lkid = cpu_to_le32(rl->rl_parent_lkid); | ||
140 | rl->rl_parent_remid = cpu_to_le32(rl->rl_parent_remid); | ||
141 | rl->rl_exflags = cpu_to_le32(rl->rl_exflags); | ||
142 | rl->rl_flags = cpu_to_le32(rl->rl_flags); | ||
143 | rl->rl_lvbseq = cpu_to_le32(rl->rl_lvbseq); | ||
144 | rl->rl_result = cpu_to_le32(rl->rl_result); | ||
145 | rl->rl_wait_type = cpu_to_le16(rl->rl_wait_type); | ||
146 | rl->rl_namelen = cpu_to_le16(rl->rl_namelen); | ||
147 | } | ||
148 | |||
149 | static void rcom_lock_in(struct rcom_lock *rl) | ||
150 | { | ||
151 | rl->rl_ownpid = le32_to_cpu(rl->rl_ownpid); | ||
152 | rl->rl_lkid = le32_to_cpu(rl->rl_lkid); | ||
153 | rl->rl_remid = le32_to_cpu(rl->rl_remid); | ||
154 | rl->rl_parent_lkid = le32_to_cpu(rl->rl_parent_lkid); | ||
155 | rl->rl_parent_remid = le32_to_cpu(rl->rl_parent_remid); | ||
156 | rl->rl_exflags = le32_to_cpu(rl->rl_exflags); | ||
157 | rl->rl_flags = le32_to_cpu(rl->rl_flags); | ||
158 | rl->rl_lvbseq = le32_to_cpu(rl->rl_lvbseq); | ||
159 | rl->rl_result = le32_to_cpu(rl->rl_result); | ||
160 | rl->rl_wait_type = le16_to_cpu(rl->rl_wait_type); | ||
161 | rl->rl_namelen = le16_to_cpu(rl->rl_namelen); | ||
162 | } | ||
163 | |||
164 | static void rcom_config_out(struct rcom_config *rf) | 134 | static void rcom_config_out(struct rcom_config *rf) |
165 | { | 135 | { |
166 | rf->rf_lvblen = cpu_to_le32(rf->rf_lvblen); | 136 | rf->rf_lvblen = cpu_to_le32(rf->rf_lvblen); |
@@ -185,17 +155,12 @@ void dlm_rcom_out(struct dlm_rcom *rc) | |||
185 | rc->rc_seq = cpu_to_le64(rc->rc_seq); | 155 | rc->rc_seq = cpu_to_le64(rc->rc_seq); |
186 | rc->rc_seq_reply = cpu_to_le64(rc->rc_seq_reply); | 156 | rc->rc_seq_reply = cpu_to_le64(rc->rc_seq_reply); |
187 | 157 | ||
188 | if ((type == DLM_RCOM_LOCK) || (type == DLM_RCOM_LOCK_REPLY)) | 158 | if (type == DLM_RCOM_STATUS_REPLY) |
189 | rcom_lock_out((struct rcom_lock *) rc->rc_buf); | ||
190 | |||
191 | else if (type == DLM_RCOM_STATUS_REPLY) | ||
192 | rcom_config_out((struct rcom_config *) rc->rc_buf); | 159 | rcom_config_out((struct rcom_config *) rc->rc_buf); |
193 | } | 160 | } |
194 | 161 | ||
195 | void dlm_rcom_in(struct dlm_rcom *rc) | 162 | void dlm_rcom_in(struct dlm_rcom *rc) |
196 | { | 163 | { |
197 | int type; | ||
198 | |||
199 | header_in(&rc->rc_header); | 164 | header_in(&rc->rc_header); |
200 | 165 | ||
201 | rc->rc_type = le32_to_cpu(rc->rc_type); | 166 | rc->rc_type = le32_to_cpu(rc->rc_type); |
@@ -204,12 +169,6 @@ void dlm_rcom_in(struct dlm_rcom *rc) | |||
204 | rc->rc_seq = le64_to_cpu(rc->rc_seq); | 169 | rc->rc_seq = le64_to_cpu(rc->rc_seq); |
205 | rc->rc_seq_reply = le64_to_cpu(rc->rc_seq_reply); | 170 | rc->rc_seq_reply = le64_to_cpu(rc->rc_seq_reply); |
206 | 171 | ||
207 | type = rc->rc_type; | 172 | if (rc->rc_type == DLM_RCOM_STATUS_REPLY) |
208 | |||
209 | if ((type == DLM_RCOM_LOCK) || (type == DLM_RCOM_LOCK_REPLY)) | ||
210 | rcom_lock_in((struct rcom_lock *) rc->rc_buf); | ||
211 | |||
212 | else if (type == DLM_RCOM_STATUS_REPLY) | ||
213 | rcom_config_in((struct rcom_config *) rc->rc_buf); | 173 | rcom_config_in((struct rcom_config *) rc->rc_buf); |
214 | } | 174 | } |
215 | |||