Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

dlm: use __le types for dlm messages

This patch changes to use __le types directly in the dlm message
structure which is casted at the right dlm message buffer positions.

The main goal what is reached here is to remove sparse warnings
regarding to host to little byte order conversion or vice versa. Leaving
those sparse issues ignored and always do it in out/in functionality
tends to leave it unknown in which byte order the variable is being
handled.

Signed-off-by: Alexander Aring <aahringo@redhat.com>
Signed-off-by: David Teigland <teigland@redhat.com>

authored by

Alexander Aring and committed by
David Teigland
00e99ccd 2f9dbeda

+174 -205
+18 -18
fs/dlm/dlm_internal.h
··· 409 409 410 410 struct dlm_message { 411 411 struct dlm_header m_header; 412 - uint32_t m_type; /* DLM_MSG_ */ 413 - uint32_t m_nodeid; 414 - uint32_t m_pid; 415 - uint32_t m_lkid; /* lkid on sender */ 416 - uint32_t m_remid; /* lkid on receiver */ 417 - uint32_t m_parent_lkid; 418 - uint32_t m_parent_remid; 419 - uint32_t m_exflags; 420 - uint32_t m_sbflags; 421 - uint32_t m_flags; 422 - uint32_t m_lvbseq; 423 - uint32_t m_hash; 424 - int m_status; 425 - int m_grmode; 426 - int m_rqmode; 427 - int m_bastmode; 428 - int m_asts; 429 - int m_result; /* 0 or -EXXX */ 412 + __le32 m_type; /* DLM_MSG_ */ 413 + __le32 m_nodeid; 414 + __le32 m_pid; 415 + __le32 m_lkid; /* lkid on sender */ 416 + __le32 m_remid; /* lkid on receiver */ 417 + __le32 m_parent_lkid; 418 + __le32 m_parent_remid; 419 + __le32 m_exflags; 420 + __le32 m_sbflags; 421 + __le32 m_flags; 422 + __le32 m_lvbseq; 423 + __le32 m_hash; 424 + __le32 m_status; 425 + __le32 m_grmode; 426 + __le32 m_rqmode; 427 + __le32 m_bastmode; 428 + __le32 m_asts; 429 + __le32 m_result; /* 0 or -EXXX */ 430 430 char m_extra[]; /* name or lvb */ 431 431 }; 432 432
+143 -133
fs/dlm/lock.c
··· 1617 1617 struct dlm_ls *ls = lkb->lkb_resource->res_ls; 1618 1618 int error; 1619 1619 1620 - if (ms->m_flags != DLM_IFL_STUB_MS) 1620 + if (ms->m_flags != cpu_to_le32(DLM_IFL_STUB_MS)) 1621 1621 mutex_lock(&ls->ls_waiters_mutex); 1622 - error = _remove_from_waiters(lkb, ms->m_type, ms); 1623 - if (ms->m_flags != DLM_IFL_STUB_MS) 1622 + error = _remove_from_waiters(lkb, le32_to_cpu(ms->m_type), ms); 1623 + if (ms->m_flags != cpu_to_le32(DLM_IFL_STUB_MS)) 1624 1624 mutex_unlock(&ls->ls_waiters_mutex); 1625 1625 return error; 1626 1626 } ··· 2051 2051 if (len > r->res_ls->ls_lvblen) 2052 2052 len = r->res_ls->ls_lvblen; 2053 2053 memcpy(lkb->lkb_lvbptr, ms->m_extra, len); 2054 - lkb->lkb_lvbseq = ms->m_lvbseq; 2054 + lkb->lkb_lvbseq = le32_to_cpu(ms->m_lvbseq); 2055 2055 } 2056 2056 } 2057 2057 ··· 2182 2182 2183 2183 static void munge_altmode(struct dlm_lkb *lkb, struct dlm_message *ms) 2184 2184 { 2185 - if (ms->m_type != DLM_MSG_REQUEST_REPLY && 2186 - ms->m_type != DLM_MSG_GRANT) { 2185 + if (ms->m_type != cpu_to_le32(DLM_MSG_REQUEST_REPLY) && 2186 + ms->m_type != cpu_to_le32(DLM_MSG_GRANT)) { 2187 2187 log_print("munge_altmode %x invalid reply type %d", 2188 - lkb->lkb_id, ms->m_type); 2188 + lkb->lkb_id, le32_to_cpu(ms->m_type)); 2189 2189 return; 2190 2190 } 2191 2191 ··· 3570 3570 ms->m_header.h_length = cpu_to_le16(mb_len); 3571 3571 ms->m_header.h_cmd = DLM_MSG; 3572 3572 3573 - ms->m_type = mstype; 3573 + ms->m_type = cpu_to_le32(mstype); 3574 3574 3575 3575 *mh_ret = mh; 3576 3576 *ms_ret = ms; ··· 3609 3609 3610 3610 static int send_message(struct dlm_mhandle *mh, struct dlm_message *ms) 3611 3611 { 3612 - dlm_message_out(ms); 3613 3612 dlm_midcomms_commit_mhandle(mh); 3614 3613 return 0; 3615 3614 } ··· 3616 3617 static void send_args(struct dlm_rsb *r, struct dlm_lkb *lkb, 3617 3618 struct dlm_message *ms) 3618 3619 { 3619 - ms->m_nodeid = lkb->lkb_nodeid; 3620 - ms->m_pid = lkb->lkb_ownpid; 3621 - ms->m_lkid = lkb->lkb_id; 3622 - ms->m_remid = lkb->lkb_remid; 3623 - ms->m_exflags = lkb->lkb_exflags; 3624 - ms->m_sbflags = lkb->lkb_sbflags; 3625 - ms->m_flags = lkb->lkb_flags; 3626 - ms->m_lvbseq = lkb->lkb_lvbseq; 3627 - ms->m_status = lkb->lkb_status; 3628 - ms->m_grmode = lkb->lkb_grmode; 3629 - ms->m_rqmode = lkb->lkb_rqmode; 3630 - ms->m_hash = r->res_hash; 3620 + ms->m_nodeid = cpu_to_le32(lkb->lkb_nodeid); 3621 + ms->m_pid = cpu_to_le32(lkb->lkb_ownpid); 3622 + ms->m_lkid = cpu_to_le32(lkb->lkb_id); 3623 + ms->m_remid = cpu_to_le32(lkb->lkb_remid); 3624 + ms->m_exflags = cpu_to_le32(lkb->lkb_exflags); 3625 + ms->m_sbflags = cpu_to_le32(lkb->lkb_sbflags); 3626 + ms->m_flags = cpu_to_le32(lkb->lkb_flags); 3627 + ms->m_lvbseq = cpu_to_le32(lkb->lkb_lvbseq); 3628 + ms->m_status = cpu_to_le32(lkb->lkb_status); 3629 + ms->m_grmode = cpu_to_le32(lkb->lkb_grmode); 3630 + ms->m_rqmode = cpu_to_le32(lkb->lkb_rqmode); 3631 + ms->m_hash = cpu_to_le32(r->res_hash); 3631 3632 3632 3633 /* m_result and m_bastmode are set from function args, 3633 3634 not from lkb fields */ 3634 3635 3635 3636 if (lkb->lkb_bastfn) 3636 - ms->m_asts |= DLM_CB_BAST; 3637 + ms->m_asts |= cpu_to_le32(DLM_CB_BAST); 3637 3638 if (lkb->lkb_astfn) 3638 - ms->m_asts |= DLM_CB_CAST; 3639 + ms->m_asts |= cpu_to_le32(DLM_CB_CAST); 3639 3640 3640 3641 /* compare with switch in create_message; send_remove() doesn't 3641 3642 use send_args() */ 3642 3643 3643 3644 switch (ms->m_type) { 3644 - case DLM_MSG_REQUEST: 3645 - case DLM_MSG_LOOKUP: 3645 + case cpu_to_le32(DLM_MSG_REQUEST): 3646 + case cpu_to_le32(DLM_MSG_LOOKUP): 3646 3647 memcpy(ms->m_extra, r->res_name, r->res_length); 3647 3648 break; 3648 - case DLM_MSG_CONVERT: 3649 - case DLM_MSG_UNLOCK: 3650 - case DLM_MSG_REQUEST_REPLY: 3651 - case DLM_MSG_CONVERT_REPLY: 3652 - case DLM_MSG_GRANT: 3649 + case cpu_to_le32(DLM_MSG_CONVERT): 3650 + case cpu_to_le32(DLM_MSG_UNLOCK): 3651 + case cpu_to_le32(DLM_MSG_REQUEST_REPLY): 3652 + case cpu_to_le32(DLM_MSG_CONVERT_REPLY): 3653 + case cpu_to_le32(DLM_MSG_GRANT): 3653 3654 if (!lkb->lkb_lvbptr) 3654 3655 break; 3655 3656 memcpy(ms->m_extra, lkb->lkb_lvbptr, r->res_ls->ls_lvblen); ··· 3699 3700 /* down conversions go without a reply from the master */ 3700 3701 if (!error && down_conversion(lkb)) { 3701 3702 remove_from_waiters(lkb, DLM_MSG_CONVERT_REPLY); 3702 - r->res_ls->ls_stub_ms.m_flags = DLM_IFL_STUB_MS; 3703 - r->res_ls->ls_stub_ms.m_type = DLM_MSG_CONVERT_REPLY; 3703 + r->res_ls->ls_stub_ms.m_flags = cpu_to_le32(DLM_IFL_STUB_MS); 3704 + r->res_ls->ls_stub_ms.m_type = cpu_to_le32(DLM_MSG_CONVERT_REPLY); 3704 3705 r->res_ls->ls_stub_ms.m_result = 0; 3705 3706 __receive_convert_reply(r, lkb, &r->res_ls->ls_stub_ms); 3706 3707 } ··· 3757 3758 3758 3759 send_args(r, lkb, ms); 3759 3760 3760 - ms->m_bastmode = mode; 3761 + ms->m_bastmode = cpu_to_le32(mode); 3761 3762 3762 3763 error = send_message(mh, ms); 3763 3764 out: ··· 3805 3806 goto out; 3806 3807 3807 3808 memcpy(ms->m_extra, r->res_name, r->res_length); 3808 - ms->m_hash = r->res_hash; 3809 + ms->m_hash = cpu_to_le32(r->res_hash); 3809 3810 3810 3811 error = send_message(mh, ms); 3811 3812 out: ··· 3827 3828 3828 3829 send_args(r, lkb, ms); 3829 3830 3830 - ms->m_result = rv; 3831 + ms->m_result = cpu_to_le32(to_dlm_errno(rv)); 3831 3832 3832 3833 error = send_message(mh, ms); 3833 3834 out: ··· 3867 3868 goto out; 3868 3869 3869 3870 ms->m_lkid = ms_in->m_lkid; 3870 - ms->m_result = rv; 3871 - ms->m_nodeid = ret_nodeid; 3871 + ms->m_result = cpu_to_le32(to_dlm_errno(rv)); 3872 + ms->m_nodeid = cpu_to_le32(ret_nodeid); 3872 3873 3873 3874 error = send_message(mh, ms); 3874 3875 out: ··· 3881 3882 3882 3883 static void receive_flags(struct dlm_lkb *lkb, struct dlm_message *ms) 3883 3884 { 3884 - lkb->lkb_exflags = ms->m_exflags; 3885 - lkb->lkb_sbflags = ms->m_sbflags; 3885 + lkb->lkb_exflags = le32_to_cpu(ms->m_exflags); 3886 + lkb->lkb_sbflags = le32_to_cpu(ms->m_sbflags); 3886 3887 lkb->lkb_flags = (lkb->lkb_flags & 0xFFFF0000) | 3887 - (ms->m_flags & 0x0000FFFF); 3888 + (le32_to_cpu(ms->m_flags) & 0x0000FFFF); 3888 3889 } 3889 3890 3890 3891 static void receive_flags_reply(struct dlm_lkb *lkb, struct dlm_message *ms) 3891 3892 { 3892 - if (ms->m_flags == DLM_IFL_STUB_MS) 3893 + if (ms->m_flags == cpu_to_le32(DLM_IFL_STUB_MS)) 3893 3894 return; 3894 3895 3895 - lkb->lkb_sbflags = ms->m_sbflags; 3896 + lkb->lkb_sbflags = le32_to_cpu(ms->m_sbflags); 3896 3897 lkb->lkb_flags = (lkb->lkb_flags & 0xFFFF0000) | 3897 - (ms->m_flags & 0x0000FFFF); 3898 + (le32_to_cpu(ms->m_flags) & 0x0000FFFF); 3898 3899 } 3899 3900 3900 3901 static int receive_extralen(struct dlm_message *ms) ··· 3935 3936 struct dlm_message *ms) 3936 3937 { 3937 3938 lkb->lkb_nodeid = le32_to_cpu(ms->m_header.h_nodeid); 3938 - lkb->lkb_ownpid = ms->m_pid; 3939 - lkb->lkb_remid = ms->m_lkid; 3939 + lkb->lkb_ownpid = le32_to_cpu(ms->m_pid); 3940 + lkb->lkb_remid = le32_to_cpu(ms->m_lkid); 3940 3941 lkb->lkb_grmode = DLM_LOCK_IV; 3941 - lkb->lkb_rqmode = ms->m_rqmode; 3942 + lkb->lkb_rqmode = le32_to_cpu(ms->m_rqmode); 3942 3943 3943 - lkb->lkb_bastfn = (ms->m_asts & DLM_CB_BAST) ? &fake_bastfn : NULL; 3944 - lkb->lkb_astfn = (ms->m_asts & DLM_CB_CAST) ? &fake_astfn : NULL; 3944 + lkb->lkb_bastfn = (ms->m_asts & cpu_to_le32(DLM_CB_BAST)) ? &fake_bastfn : NULL; 3945 + lkb->lkb_astfn = (ms->m_asts & cpu_to_le32(DLM_CB_CAST)) ? &fake_astfn : NULL; 3945 3946 3946 3947 if (lkb->lkb_exflags & DLM_LKF_VALBLK) { 3947 3948 /* lkb was just created so there won't be an lvb yet */ ··· 3962 3963 if (receive_lvb(ls, lkb, ms)) 3963 3964 return -ENOMEM; 3964 3965 3965 - lkb->lkb_rqmode = ms->m_rqmode; 3966 - lkb->lkb_lvbseq = ms->m_lvbseq; 3966 + lkb->lkb_rqmode = le32_to_cpu(ms->m_rqmode); 3967 + lkb->lkb_lvbseq = le32_to_cpu(ms->m_lvbseq); 3967 3968 3968 3969 return 0; 3969 3970 } ··· 3983 3984 { 3984 3985 struct dlm_lkb *lkb = &ls->ls_stub_lkb; 3985 3986 lkb->lkb_nodeid = le32_to_cpu(ms->m_header.h_nodeid); 3986 - lkb->lkb_remid = ms->m_lkid; 3987 + lkb->lkb_remid = le32_to_cpu(ms->m_lkid); 3987 3988 } 3988 3989 3989 3990 /* This is called after the rsb is locked so that we can safely inspect ··· 3995 3996 int error = 0; 3996 3997 3997 3998 /* currently mixing of user/kernel locks are not supported */ 3998 - if (ms->m_flags & DLM_IFL_USER && ~lkb->lkb_flags & DLM_IFL_USER) { 3999 + if (ms->m_flags & cpu_to_le32(DLM_IFL_USER) && 4000 + ~lkb->lkb_flags & DLM_IFL_USER) { 3999 4001 log_error(lkb->lkb_resource->res_ls, 4000 4002 "got user dlm message for a kernel lock"); 4001 4003 error = -EINVAL; ··· 4004 4004 } 4005 4005 4006 4006 switch (ms->m_type) { 4007 - case DLM_MSG_CONVERT: 4008 - case DLM_MSG_UNLOCK: 4009 - case DLM_MSG_CANCEL: 4007 + case cpu_to_le32(DLM_MSG_CONVERT): 4008 + case cpu_to_le32(DLM_MSG_UNLOCK): 4009 + case cpu_to_le32(DLM_MSG_CANCEL): 4010 4010 if (!is_master_copy(lkb) || lkb->lkb_nodeid != from) 4011 4011 error = -EINVAL; 4012 4012 break; 4013 4013 4014 - case DLM_MSG_CONVERT_REPLY: 4015 - case DLM_MSG_UNLOCK_REPLY: 4016 - case DLM_MSG_CANCEL_REPLY: 4017 - case DLM_MSG_GRANT: 4018 - case DLM_MSG_BAST: 4014 + case cpu_to_le32(DLM_MSG_CONVERT_REPLY): 4015 + case cpu_to_le32(DLM_MSG_UNLOCK_REPLY): 4016 + case cpu_to_le32(DLM_MSG_CANCEL_REPLY): 4017 + case cpu_to_le32(DLM_MSG_GRANT): 4018 + case cpu_to_le32(DLM_MSG_BAST): 4019 4019 if (!is_process_copy(lkb) || lkb->lkb_nodeid != from) 4020 4020 error = -EINVAL; 4021 4021 break; 4022 4022 4023 - case DLM_MSG_REQUEST_REPLY: 4023 + case cpu_to_le32(DLM_MSG_REQUEST_REPLY): 4024 4024 if (!is_process_copy(lkb)) 4025 4025 error = -EINVAL; 4026 4026 else if (lkb->lkb_nodeid != -1 && lkb->lkb_nodeid != from) ··· 4035 4035 if (error) 4036 4036 log_error(lkb->lkb_resource->res_ls, 4037 4037 "ignore invalid message %d from %d %x %x %x %d", 4038 - ms->m_type, from, lkb->lkb_id, lkb->lkb_remid, 4039 - lkb->lkb_flags, lkb->lkb_nodeid); 4038 + le32_to_cpu(ms->m_type), from, lkb->lkb_id, 4039 + lkb->lkb_remid, lkb->lkb_flags, lkb->lkb_nodeid); 4040 4040 return error; 4041 4041 } 4042 4042 ··· 4089 4089 return; 4090 4090 4091 4091 memcpy(ms->m_extra, name, len); 4092 - ms->m_hash = hash; 4092 + ms->m_hash = cpu_to_le32(hash); 4093 4093 4094 4094 send_message(mh, ms); 4095 4095 ··· 4179 4179 4180 4180 if (error != -ENOTBLK) { 4181 4181 log_limit(ls, "receive_request %x from %d %d", 4182 - ms->m_lkid, from_nodeid, error); 4182 + le32_to_cpu(ms->m_lkid), from_nodeid, error); 4183 4183 } 4184 4184 4185 4185 if (namelen && error == -EBADR) { ··· 4198 4198 struct dlm_rsb *r; 4199 4199 int error, reply = 1; 4200 4200 4201 - error = find_lkb(ls, ms->m_remid, &lkb); 4201 + error = find_lkb(ls, le32_to_cpu(ms->m_remid), &lkb); 4202 4202 if (error) 4203 4203 goto fail; 4204 4204 4205 - if (lkb->lkb_remid != ms->m_lkid) { 4205 + if (lkb->lkb_remid != le32_to_cpu(ms->m_lkid)) { 4206 4206 log_error(ls, "receive_convert %x remid %x recover_seq %llu " 4207 4207 "remote %d %x", lkb->lkb_id, lkb->lkb_remid, 4208 4208 (unsigned long long)lkb->lkb_recover_seq, 4209 - le32_to_cpu(ms->m_header.h_nodeid), ms->m_lkid); 4209 + le32_to_cpu(ms->m_header.h_nodeid), 4210 + le32_to_cpu(ms->m_lkid)); 4210 4211 error = -ENOENT; 4211 4212 dlm_put_lkb(lkb); 4212 4213 goto fail; ··· 4254 4253 struct dlm_rsb *r; 4255 4254 int error; 4256 4255 4257 - error = find_lkb(ls, ms->m_remid, &lkb); 4256 + error = find_lkb(ls, le32_to_cpu(ms->m_remid), &lkb); 4258 4257 if (error) 4259 4258 goto fail; 4260 4259 4261 - if (lkb->lkb_remid != ms->m_lkid) { 4260 + if (lkb->lkb_remid != le32_to_cpu(ms->m_lkid)) { 4262 4261 log_error(ls, "receive_unlock %x remid %x remote %d %x", 4263 4262 lkb->lkb_id, lkb->lkb_remid, 4264 - le32_to_cpu(ms->m_header.h_nodeid), ms->m_lkid); 4263 + le32_to_cpu(ms->m_header.h_nodeid), 4264 + le32_to_cpu(ms->m_lkid)); 4265 4265 error = -ENOENT; 4266 4266 dlm_put_lkb(lkb); 4267 4267 goto fail; ··· 4306 4304 struct dlm_rsb *r; 4307 4305 int error; 4308 4306 4309 - error = find_lkb(ls, ms->m_remid, &lkb); 4307 + error = find_lkb(ls, le32_to_cpu(ms->m_remid), &lkb); 4310 4308 if (error) 4311 4309 goto fail; 4312 4310 ··· 4342 4340 struct dlm_rsb *r; 4343 4341 int error; 4344 4342 4345 - error = find_lkb(ls, ms->m_remid, &lkb); 4343 + error = find_lkb(ls, le32_to_cpu(ms->m_remid), &lkb); 4346 4344 if (error) 4347 4345 return error; 4348 4346 ··· 4373 4371 struct dlm_rsb *r; 4374 4372 int error; 4375 4373 4376 - error = find_lkb(ls, ms->m_remid, &lkb); 4374 + error = find_lkb(ls, le32_to_cpu(ms->m_remid), &lkb); 4377 4375 if (error) 4378 4376 return error; 4379 4377 ··· 4386 4384 if (error) 4387 4385 goto out; 4388 4386 4389 - queue_bast(r, lkb, ms->m_bastmode); 4390 - lkb->lkb_highbast = ms->m_bastmode; 4387 + queue_bast(r, lkb, le32_to_cpu(ms->m_bastmode)); 4388 + lkb->lkb_highbast = le32_to_cpu(ms->m_bastmode); 4391 4389 out: 4392 4390 unlock_rsb(r); 4393 4391 put_rsb(r); ··· 4432 4430 return; 4433 4431 } 4434 4432 4435 - dir_nodeid = dlm_hash2nodeid(ls, ms->m_hash); 4433 + dir_nodeid = dlm_hash2nodeid(ls, le32_to_cpu(ms->m_hash)); 4436 4434 if (dir_nodeid != dlm_our_nodeid()) { 4437 4435 log_error(ls, "receive_remove from %d bad nodeid %d", 4438 4436 from_nodeid, dir_nodeid); ··· 4505 4503 4506 4504 static void receive_purge(struct dlm_ls *ls, struct dlm_message *ms) 4507 4505 { 4508 - do_purge(ls, ms->m_nodeid, ms->m_pid); 4506 + do_purge(ls, le32_to_cpu(ms->m_nodeid), le32_to_cpu(ms->m_pid)); 4509 4507 } 4510 4508 4511 4509 static int receive_request_reply(struct dlm_ls *ls, struct dlm_message *ms) ··· 4515 4513 int error, mstype, result; 4516 4514 int from_nodeid = le32_to_cpu(ms->m_header.h_nodeid); 4517 4515 4518 - error = find_lkb(ls, ms->m_remid, &lkb); 4516 + error = find_lkb(ls, le32_to_cpu(ms->m_remid), &lkb); 4519 4517 if (error) 4520 4518 return error; 4521 4519 ··· 4531 4529 error = remove_from_waiters(lkb, DLM_MSG_REQUEST_REPLY); 4532 4530 if (error) { 4533 4531 log_error(ls, "receive_request_reply %x remote %d %x result %d", 4534 - lkb->lkb_id, from_nodeid, ms->m_lkid, ms->m_result); 4532 + lkb->lkb_id, from_nodeid, le32_to_cpu(ms->m_lkid), 4533 + from_dlm_errno(le32_to_cpu(ms->m_result))); 4535 4534 dlm_dump_rsb(r); 4536 4535 goto out; 4537 4536 } ··· 4546 4543 } 4547 4544 4548 4545 /* this is the value returned from do_request() on the master */ 4549 - result = ms->m_result; 4546 + result = from_dlm_errno(le32_to_cpu(ms->m_result)); 4550 4547 4551 4548 switch (result) { 4552 4549 case -EAGAIN: ··· 4560 4557 case 0: 4561 4558 /* request was queued or granted on remote master */ 4562 4559 receive_flags_reply(lkb, ms); 4563 - lkb->lkb_remid = ms->m_lkid; 4560 + lkb->lkb_remid = le32_to_cpu(ms->m_lkid); 4564 4561 if (is_altmode(lkb)) 4565 4562 munge_altmode(lkb, ms); 4566 4563 if (result) { ··· 4633 4630 struct dlm_message *ms) 4634 4631 { 4635 4632 /* this is the value returned from do_convert() on the master */ 4636 - switch (ms->m_result) { 4633 + switch (from_dlm_errno(le32_to_cpu(ms->m_result))) { 4637 4634 case -EAGAIN: 4638 4635 /* convert would block (be queued) on remote master */ 4639 4636 queue_cast(r, lkb, -EAGAIN); ··· 4667 4664 default: 4668 4665 log_error(r->res_ls, "receive_convert_reply %x remote %d %x %d", 4669 4666 lkb->lkb_id, le32_to_cpu(ms->m_header.h_nodeid), 4670 - ms->m_lkid, ms->m_result); 4667 + le32_to_cpu(ms->m_lkid), 4668 + from_dlm_errno(le32_to_cpu(ms->m_result))); 4671 4669 dlm_print_rsb(r); 4672 4670 dlm_print_lkb(lkb); 4673 4671 } ··· 4702 4698 struct dlm_lkb *lkb; 4703 4699 int error; 4704 4700 4705 - error = find_lkb(ls, ms->m_remid, &lkb); 4701 + error = find_lkb(ls, le32_to_cpu(ms->m_remid), &lkb); 4706 4702 if (error) 4707 4703 return error; 4708 4704 ··· 4730 4726 4731 4727 /* this is the value returned from do_unlock() on the master */ 4732 4728 4733 - switch (ms->m_result) { 4729 + switch (from_dlm_errno(le32_to_cpu(ms->m_result))) { 4734 4730 case -DLM_EUNLOCK: 4735 4731 receive_flags_reply(lkb, ms); 4736 4732 remove_lock_pc(r, lkb); ··· 4740 4736 break; 4741 4737 default: 4742 4738 log_error(r->res_ls, "receive_unlock_reply %x error %d", 4743 - lkb->lkb_id, ms->m_result); 4739 + lkb->lkb_id, from_dlm_errno(le32_to_cpu(ms->m_result))); 4744 4740 } 4745 4741 out: 4746 4742 unlock_rsb(r); ··· 4752 4748 struct dlm_lkb *lkb; 4753 4749 int error; 4754 4750 4755 - error = find_lkb(ls, ms->m_remid, &lkb); 4751 + error = find_lkb(ls, le32_to_cpu(ms->m_remid), &lkb); 4756 4752 if (error) 4757 4753 return error; 4758 4754 ··· 4780 4776 4781 4777 /* this is the value returned from do_cancel() on the master */ 4782 4778 4783 - switch (ms->m_result) { 4779 + switch (from_dlm_errno(le32_to_cpu(ms->m_result))) { 4784 4780 case -DLM_ECANCEL: 4785 4781 receive_flags_reply(lkb, ms); 4786 4782 revert_lock_pc(r, lkb); ··· 4790 4786 break; 4791 4787 default: 4792 4788 log_error(r->res_ls, "receive_cancel_reply %x error %d", 4793 - lkb->lkb_id, ms->m_result); 4789 + lkb->lkb_id, 4790 + from_dlm_errno(le32_to_cpu(ms->m_result))); 4794 4791 } 4795 4792 out: 4796 4793 unlock_rsb(r); ··· 4803 4798 struct dlm_lkb *lkb; 4804 4799 int error; 4805 4800 4806 - error = find_lkb(ls, ms->m_remid, &lkb); 4801 + error = find_lkb(ls, le32_to_cpu(ms->m_remid), &lkb); 4807 4802 if (error) 4808 4803 return error; 4809 4804 ··· 4819 4814 int error, ret_nodeid; 4820 4815 int do_lookup_list = 0; 4821 4816 4822 - error = find_lkb(ls, ms->m_lkid, &lkb); 4817 + error = find_lkb(ls, le32_to_cpu(ms->m_lkid), &lkb); 4823 4818 if (error) { 4824 - log_error(ls, "receive_lookup_reply no lkid %x", ms->m_lkid); 4819 + log_error(ls, "%s no lkid %x", __func__, 4820 + le32_to_cpu(ms->m_lkid)); 4825 4821 return; 4826 4822 } 4827 4823 ··· 4837 4831 if (error) 4838 4832 goto out; 4839 4833 4840 - ret_nodeid = ms->m_nodeid; 4834 + ret_nodeid = le32_to_cpu(ms->m_nodeid); 4841 4835 4842 4836 /* We sometimes receive a request from the dir node for this 4843 4837 rsb before we've received the dir node's loookup_reply for it. ··· 4898 4892 4899 4893 if (!dlm_is_member(ls, le32_to_cpu(ms->m_header.h_nodeid))) { 4900 4894 log_limit(ls, "receive %d from non-member %d %x %x %d", 4901 - ms->m_type, le32_to_cpu(ms->m_header.h_nodeid), 4902 - ms->m_lkid, ms->m_remid, ms->m_result); 4895 + le32_to_cpu(ms->m_type), 4896 + le32_to_cpu(ms->m_header.h_nodeid), 4897 + le32_to_cpu(ms->m_lkid), le32_to_cpu(ms->m_remid), 4898 + from_dlm_errno(le32_to_cpu(ms->m_result))); 4903 4899 return; 4904 4900 } 4905 4901 ··· 4909 4901 4910 4902 /* messages sent to a master node */ 4911 4903 4912 - case DLM_MSG_REQUEST: 4904 + case cpu_to_le32(DLM_MSG_REQUEST): 4913 4905 error = receive_request(ls, ms); 4914 4906 break; 4915 4907 4916 - case DLM_MSG_CONVERT: 4908 + case cpu_to_le32(DLM_MSG_CONVERT): 4917 4909 error = receive_convert(ls, ms); 4918 4910 break; 4919 4911 4920 - case DLM_MSG_UNLOCK: 4912 + case cpu_to_le32(DLM_MSG_UNLOCK): 4921 4913 error = receive_unlock(ls, ms); 4922 4914 break; 4923 4915 4924 - case DLM_MSG_CANCEL: 4916 + case cpu_to_le32(DLM_MSG_CANCEL): 4925 4917 noent = 1; 4926 4918 error = receive_cancel(ls, ms); 4927 4919 break; 4928 4920 4929 4921 /* messages sent from a master node (replies to above) */ 4930 4922 4931 - case DLM_MSG_REQUEST_REPLY: 4923 + case cpu_to_le32(DLM_MSG_REQUEST_REPLY): 4932 4924 error = receive_request_reply(ls, ms); 4933 4925 break; 4934 4926 4935 - case DLM_MSG_CONVERT_REPLY: 4927 + case cpu_to_le32(DLM_MSG_CONVERT_REPLY): 4936 4928 error = receive_convert_reply(ls, ms); 4937 4929 break; 4938 4930 4939 - case DLM_MSG_UNLOCK_REPLY: 4931 + case cpu_to_le32(DLM_MSG_UNLOCK_REPLY): 4940 4932 error = receive_unlock_reply(ls, ms); 4941 4933 break; 4942 4934 4943 - case DLM_MSG_CANCEL_REPLY: 4935 + case cpu_to_le32(DLM_MSG_CANCEL_REPLY): 4944 4936 error = receive_cancel_reply(ls, ms); 4945 4937 break; 4946 4938 4947 4939 /* messages sent from a master node (only two types of async msg) */ 4948 4940 4949 - case DLM_MSG_GRANT: 4941 + case cpu_to_le32(DLM_MSG_GRANT): 4950 4942 noent = 1; 4951 4943 error = receive_grant(ls, ms); 4952 4944 break; 4953 4945 4954 - case DLM_MSG_BAST: 4946 + case cpu_to_le32(DLM_MSG_BAST): 4955 4947 noent = 1; 4956 4948 error = receive_bast(ls, ms); 4957 4949 break; 4958 4950 4959 4951 /* messages sent to a dir node */ 4960 4952 4961 - case DLM_MSG_LOOKUP: 4953 + case cpu_to_le32(DLM_MSG_LOOKUP): 4962 4954 receive_lookup(ls, ms); 4963 4955 break; 4964 4956 4965 - case DLM_MSG_REMOVE: 4957 + case cpu_to_le32(DLM_MSG_REMOVE): 4966 4958 receive_remove(ls, ms); 4967 4959 break; 4968 4960 4969 4961 /* messages sent from a dir node (remove has no reply) */ 4970 4962 4971 - case DLM_MSG_LOOKUP_REPLY: 4963 + case cpu_to_le32(DLM_MSG_LOOKUP_REPLY): 4972 4964 receive_lookup_reply(ls, ms); 4973 4965 break; 4974 4966 4975 4967 /* other messages */ 4976 4968 4977 - case DLM_MSG_PURGE: 4969 + case cpu_to_le32(DLM_MSG_PURGE): 4978 4970 receive_purge(ls, ms); 4979 4971 break; 4980 4972 4981 4973 default: 4982 - log_error(ls, "unknown message type %d", ms->m_type); 4974 + log_error(ls, "unknown message type %d", 4975 + le32_to_cpu(ms->m_type)); 4983 4976 } 4984 4977 4985 4978 /* ··· 4996 4987 4997 4988 if (error == -ENOENT && noent) { 4998 4989 log_debug(ls, "receive %d no %x remote %d %x saved_seq %u", 4999 - ms->m_type, ms->m_remid, 4990 + le32_to_cpu(ms->m_type), le32_to_cpu(ms->m_remid), 5000 4991 le32_to_cpu(ms->m_header.h_nodeid), 5001 - ms->m_lkid, saved_seq); 4992 + le32_to_cpu(ms->m_lkid), saved_seq); 5002 4993 } else if (error == -ENOENT) { 5003 4994 log_error(ls, "receive %d no %x remote %d %x saved_seq %u", 5004 - ms->m_type, ms->m_remid, 4995 + le32_to_cpu(ms->m_type), le32_to_cpu(ms->m_remid), 5005 4996 le32_to_cpu(ms->m_header.h_nodeid), 5006 - ms->m_lkid, saved_seq); 4997 + le32_to_cpu(ms->m_lkid), saved_seq); 5007 4998 5008 - if (ms->m_type == DLM_MSG_CONVERT) 5009 - dlm_dump_rsb_hash(ls, ms->m_hash); 4999 + if (ms->m_type == cpu_to_le32(DLM_MSG_CONVERT)) 5000 + dlm_dump_rsb_hash(ls, le32_to_cpu(ms->m_hash)); 5010 5001 } 5011 5002 5012 5003 if (error == -EINVAL) { 5013 5004 log_error(ls, "receive %d inval from %d lkid %x remid %x " 5014 5005 "saved_seq %u", 5015 - ms->m_type, le32_to_cpu(ms->m_header.h_nodeid), 5016 - ms->m_lkid, ms->m_remid, saved_seq); 5006 + le32_to_cpu(ms->m_type), 5007 + le32_to_cpu(ms->m_header.h_nodeid), 5008 + le32_to_cpu(ms->m_lkid), le32_to_cpu(ms->m_remid), 5009 + saved_seq); 5017 5010 } 5018 5011 } 5019 5012 ··· 5036 5025 lockspace generation before we left. */ 5037 5026 if (!ls->ls_generation) { 5038 5027 log_limit(ls, "receive %d from %d ignore old gen", 5039 - ms->m_type, nodeid); 5028 + le32_to_cpu(ms->m_type), nodeid); 5040 5029 return; 5041 5030 } 5042 5031 ··· 5069 5058 5070 5059 switch (hd->h_cmd) { 5071 5060 case DLM_MSG: 5072 - dlm_message_in(&p->message); 5073 - type = p->message.m_type; 5061 + type = le32_to_cpu(p->message.m_type); 5074 5062 break; 5075 5063 case DLM_RCOM: 5076 5064 type = le32_to_cpu(p->rcom.rc_type); ··· 5119 5109 if (middle_conversion(lkb)) { 5120 5110 hold_lkb(lkb); 5121 5111 memset(ms_stub, 0, sizeof(struct dlm_message)); 5122 - ms_stub->m_flags = DLM_IFL_STUB_MS; 5123 - ms_stub->m_type = DLM_MSG_CONVERT_REPLY; 5124 - ms_stub->m_result = -EINPROGRESS; 5112 + ms_stub->m_flags = cpu_to_le32(DLM_IFL_STUB_MS); 5113 + ms_stub->m_type = cpu_to_le32(DLM_MSG_CONVERT_REPLY); 5114 + ms_stub->m_result = cpu_to_le32(to_dlm_errno(-EINPROGRESS)); 5125 5115 ms_stub->m_header.h_nodeid = cpu_to_le32(lkb->lkb_nodeid); 5126 5116 _receive_convert_reply(lkb, ms_stub); 5127 5117 ··· 5241 5231 case DLM_MSG_UNLOCK: 5242 5232 hold_lkb(lkb); 5243 5233 memset(ms_stub, 0, sizeof(struct dlm_message)); 5244 - ms_stub->m_flags = DLM_IFL_STUB_MS; 5245 - ms_stub->m_type = DLM_MSG_UNLOCK_REPLY; 5246 - ms_stub->m_result = stub_unlock_result; 5234 + ms_stub->m_flags = cpu_to_le32(DLM_IFL_STUB_MS); 5235 + ms_stub->m_type = cpu_to_le32(DLM_MSG_UNLOCK_REPLY); 5236 + ms_stub->m_result = cpu_to_le32(to_dlm_errno(stub_unlock_result)); 5247 5237 ms_stub->m_header.h_nodeid = cpu_to_le32(lkb->lkb_nodeid); 5248 5238 _receive_unlock_reply(lkb, ms_stub); 5249 5239 dlm_put_lkb(lkb); ··· 5252 5242 case DLM_MSG_CANCEL: 5253 5243 hold_lkb(lkb); 5254 5244 memset(ms_stub, 0, sizeof(struct dlm_message)); 5255 - ms_stub->m_flags = DLM_IFL_STUB_MS; 5256 - ms_stub->m_type = DLM_MSG_CANCEL_REPLY; 5257 - ms_stub->m_result = stub_cancel_result; 5245 + ms_stub->m_flags = cpu_to_le32(DLM_IFL_STUB_MS); 5246 + ms_stub->m_type = cpu_to_le32(DLM_MSG_CANCEL_REPLY); 5247 + ms_stub->m_result = cpu_to_le32(to_dlm_errno(stub_cancel_result)); 5258 5248 ms_stub->m_header.h_nodeid = cpu_to_le32(lkb->lkb_nodeid); 5259 5249 _receive_cancel_reply(lkb, ms_stub); 5260 5250 dlm_put_lkb(lkb); ··· 6326 6316 DLM_MSG_PURGE, &ms, &mh); 6327 6317 if (error) 6328 6318 return error; 6329 - ms->m_nodeid = nodeid; 6330 - ms->m_pid = pid; 6319 + ms->m_nodeid = cpu_to_le32(nodeid); 6320 + ms->m_pid = cpu_to_le32(pid); 6331 6321 6332 6322 return send_message(mh, ms); 6333 6323 }
+9 -6
fs/dlm/requestqueue.c
··· 14 14 #include "dir.h" 15 15 #include "config.h" 16 16 #include "requestqueue.h" 17 + #include "util.h" 17 18 18 19 struct rq_entry { 19 20 struct list_head list; ··· 84 83 85 84 log_limit(ls, "dlm_process_requestqueue msg %d from %d " 86 85 "lkid %x remid %x result %d seq %u", 87 - ms->m_type, le32_to_cpu(ms->m_header.h_nodeid), 88 - ms->m_lkid, ms->m_remid, ms->m_result, 86 + le32_to_cpu(ms->m_type), 87 + le32_to_cpu(ms->m_header.h_nodeid), 88 + le32_to_cpu(ms->m_lkid), le32_to_cpu(ms->m_remid), 89 + from_dlm_errno(le32_to_cpu(ms->m_result)), 89 90 e->recover_seq); 90 91 91 92 dlm_receive_message_saved(ls, &e->request, e->recover_seq); ··· 128 125 129 126 static int purge_request(struct dlm_ls *ls, struct dlm_message *ms, int nodeid) 130 127 { 131 - uint32_t type = ms->m_type; 128 + __le32 type = ms->m_type; 132 129 133 130 /* the ls is being cleaned up and freed by release_lockspace */ 134 131 if (!atomic_read(&ls->ls_count)) ··· 140 137 /* directory operations are always purged because the directory is 141 138 always rebuilt during recovery and the lookups resent */ 142 139 143 - if (type == DLM_MSG_REMOVE || 144 - type == DLM_MSG_LOOKUP || 145 - type == DLM_MSG_LOOKUP_REPLY) 140 + if (type == cpu_to_le32(DLM_MSG_REMOVE) || 141 + type == cpu_to_le32(DLM_MSG_LOOKUP) || 142 + type == cpu_to_le32(DLM_MSG_LOOKUP_REPLY)) 146 143 return 1; 147 144 148 145 if (!dlm_no_directory(ls))
+2 -46
fs/dlm/util.c
··· 23 23 /* higher errno values are inconsistent across architectures, so select 24 24 one set of values for on the wire */ 25 25 26 - static int to_dlm_errno(int err) 26 + int to_dlm_errno(int err) 27 27 { 28 28 switch (err) { 29 29 case -EDEADLK: ··· 44 44 return err; 45 45 } 46 46 47 - static int from_dlm_errno(int err) 47 + int from_dlm_errno(int err) 48 48 { 49 49 switch (err) { 50 50 case -DLM_ERRNO_EDEADLK: ··· 63 63 return -EINPROGRESS; 64 64 } 65 65 return err; 66 - } 67 - 68 - void dlm_message_out(struct dlm_message *ms) 69 - { 70 - ms->m_type = cpu_to_le32(ms->m_type); 71 - ms->m_nodeid = cpu_to_le32(ms->m_nodeid); 72 - ms->m_pid = cpu_to_le32(ms->m_pid); 73 - ms->m_lkid = cpu_to_le32(ms->m_lkid); 74 - ms->m_remid = cpu_to_le32(ms->m_remid); 75 - ms->m_parent_lkid = cpu_to_le32(ms->m_parent_lkid); 76 - ms->m_parent_remid = cpu_to_le32(ms->m_parent_remid); 77 - ms->m_exflags = cpu_to_le32(ms->m_exflags); 78 - ms->m_sbflags = cpu_to_le32(ms->m_sbflags); 79 - ms->m_flags = cpu_to_le32(ms->m_flags); 80 - ms->m_lvbseq = cpu_to_le32(ms->m_lvbseq); 81 - ms->m_hash = cpu_to_le32(ms->m_hash); 82 - ms->m_status = cpu_to_le32(ms->m_status); 83 - ms->m_grmode = cpu_to_le32(ms->m_grmode); 84 - ms->m_rqmode = cpu_to_le32(ms->m_rqmode); 85 - ms->m_bastmode = cpu_to_le32(ms->m_bastmode); 86 - ms->m_asts = cpu_to_le32(ms->m_asts); 87 - ms->m_result = cpu_to_le32(to_dlm_errno(ms->m_result)); 88 - } 89 - 90 - void dlm_message_in(struct dlm_message *ms) 91 - { 92 - ms->m_type = le32_to_cpu(ms->m_type); 93 - ms->m_nodeid = le32_to_cpu(ms->m_nodeid); 94 - ms->m_pid = le32_to_cpu(ms->m_pid); 95 - ms->m_lkid = le32_to_cpu(ms->m_lkid); 96 - ms->m_remid = le32_to_cpu(ms->m_remid); 97 - ms->m_parent_lkid = le32_to_cpu(ms->m_parent_lkid); 98 - ms->m_parent_remid = le32_to_cpu(ms->m_parent_remid); 99 - ms->m_exflags = le32_to_cpu(ms->m_exflags); 100 - ms->m_sbflags = le32_to_cpu(ms->m_sbflags); 101 - ms->m_flags = le32_to_cpu(ms->m_flags); 102 - ms->m_lvbseq = le32_to_cpu(ms->m_lvbseq); 103 - ms->m_hash = le32_to_cpu(ms->m_hash); 104 - ms->m_status = le32_to_cpu(ms->m_status); 105 - ms->m_grmode = le32_to_cpu(ms->m_grmode); 106 - ms->m_rqmode = le32_to_cpu(ms->m_rqmode); 107 - ms->m_bastmode = le32_to_cpu(ms->m_bastmode); 108 - ms->m_asts = le32_to_cpu(ms->m_asts); 109 - ms->m_result = from_dlm_errno(le32_to_cpu(ms->m_result)); 110 66 }
+2 -2
fs/dlm/util.h
··· 11 11 #ifndef __UTIL_DOT_H__ 12 12 #define __UTIL_DOT_H__ 13 13 14 - void dlm_message_out(struct dlm_message *ms); 15 - void dlm_message_in(struct dlm_message *ms); 14 + int to_dlm_errno(int err); 15 + int from_dlm_errno(int err); 16 16 17 17 #endif 18 18