util.c (762f99f4f3cb41a775b5157dd761217beba65873) util.c (3428785a65dabf05bc899b6c5334984e98286184)
1// SPDX-License-Identifier: GPL-2.0-only
2/******************************************************************************
3*******************************************************************************
4**
5** Copyright (C) 2005-2008 Red Hat, Inc. All rights reserved.
6**
7**
8*******************************************************************************

--- 6 unchanged lines hidden (view full) ---

15#define DLM_ERRNO_EDEADLK 35
16#define DLM_ERRNO_EBADR 53
17#define DLM_ERRNO_EBADSLT 57
18#define DLM_ERRNO_EPROTO 71
19#define DLM_ERRNO_EOPNOTSUPP 95
20#define DLM_ERRNO_ETIMEDOUT 110
21#define DLM_ERRNO_EINPROGRESS 115
22
1// SPDX-License-Identifier: GPL-2.0-only
2/******************************************************************************
3*******************************************************************************
4**
5** Copyright (C) 2005-2008 Red Hat, Inc. All rights reserved.
6**
7**
8*******************************************************************************

--- 6 unchanged lines hidden (view full) ---

15#define DLM_ERRNO_EDEADLK 35
16#define DLM_ERRNO_EBADR 53
17#define DLM_ERRNO_EBADSLT 57
18#define DLM_ERRNO_EPROTO 71
19#define DLM_ERRNO_EOPNOTSUPP 95
20#define DLM_ERRNO_ETIMEDOUT 110
21#define DLM_ERRNO_EINPROGRESS 115
22
23void header_out(struct dlm_header *hd)
24{
25 hd->h_version = cpu_to_le32(hd->h_version);
26 /* does it for others u32 in union as well */
27 hd->u.h_lockspace = cpu_to_le32(hd->u.h_lockspace);
28 hd->h_nodeid = cpu_to_le32(hd->h_nodeid);
29 hd->h_length = cpu_to_le16(hd->h_length);
30}
31
32void header_in(struct dlm_header *hd)
33{
34 hd->h_version = le32_to_cpu(hd->h_version);
35 /* does it for others u32 in union as well */
36 hd->u.h_lockspace = le32_to_cpu(hd->u.h_lockspace);
37 hd->h_nodeid = le32_to_cpu(hd->h_nodeid);
38 hd->h_length = le16_to_cpu(hd->h_length);
39}
40
41/* higher errno values are inconsistent across architectures, so select
42 one set of values for on the wire */
43
44static int to_dlm_errno(int err)
45{
46 switch (err) {
47 case -EDEADLK:
48 return -DLM_ERRNO_EDEADLK;

--- 31 unchanged lines hidden (view full) ---

80 case -DLM_ERRNO_EINPROGRESS:
81 return -EINPROGRESS;
82 }
83 return err;
84}
85
86void dlm_message_out(struct dlm_message *ms)
87{
23/* higher errno values are inconsistent across architectures, so select
24 one set of values for on the wire */
25
26static int to_dlm_errno(int err)
27{
28 switch (err) {
29 case -EDEADLK:
30 return -DLM_ERRNO_EDEADLK;

--- 31 unchanged lines hidden (view full) ---

62 case -DLM_ERRNO_EINPROGRESS:
63 return -EINPROGRESS;
64 }
65 return err;
66}
67
68void dlm_message_out(struct dlm_message *ms)
69{
88 header_out(&ms->m_header);
89
90 ms->m_type = cpu_to_le32(ms->m_type);
91 ms->m_nodeid = cpu_to_le32(ms->m_nodeid);
92 ms->m_pid = cpu_to_le32(ms->m_pid);
93 ms->m_lkid = cpu_to_le32(ms->m_lkid);
94 ms->m_remid = cpu_to_le32(ms->m_remid);
95 ms->m_parent_lkid = cpu_to_le32(ms->m_parent_lkid);
96 ms->m_parent_remid = cpu_to_le32(ms->m_parent_remid);
97 ms->m_exflags = cpu_to_le32(ms->m_exflags);

--- 6 unchanged lines hidden (view full) ---

104 ms->m_rqmode = cpu_to_le32(ms->m_rqmode);
105 ms->m_bastmode = cpu_to_le32(ms->m_bastmode);
106 ms->m_asts = cpu_to_le32(ms->m_asts);
107 ms->m_result = cpu_to_le32(to_dlm_errno(ms->m_result));
108}
109
110void dlm_message_in(struct dlm_message *ms)
111{
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);

--- 6 unchanged lines hidden (view full) ---

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
90void dlm_message_in(struct dlm_message *ms)
91{
112 header_in(&ms->m_header);
113
114 ms->m_type = le32_to_cpu(ms->m_type);
115 ms->m_nodeid = le32_to_cpu(ms->m_nodeid);
116 ms->m_pid = le32_to_cpu(ms->m_pid);
117 ms->m_lkid = le32_to_cpu(ms->m_lkid);
118 ms->m_remid = le32_to_cpu(ms->m_remid);
119 ms->m_parent_lkid = le32_to_cpu(ms->m_parent_lkid);
120 ms->m_parent_remid = le32_to_cpu(ms->m_parent_remid);
121 ms->m_exflags = le32_to_cpu(ms->m_exflags);

--- 6 unchanged lines hidden (view full) ---

128 ms->m_rqmode = le32_to_cpu(ms->m_rqmode);
129 ms->m_bastmode = le32_to_cpu(ms->m_bastmode);
130 ms->m_asts = le32_to_cpu(ms->m_asts);
131 ms->m_result = from_dlm_errno(le32_to_cpu(ms->m_result));
132}
133
134void dlm_rcom_out(struct dlm_rcom *rc)
135{
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);

--- 6 unchanged lines hidden (view full) ---

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}
111
112void dlm_rcom_out(struct dlm_rcom *rc)
113{
136 header_out(&rc->rc_header);
137
138 rc->rc_type = cpu_to_le32(rc->rc_type);
139 rc->rc_result = cpu_to_le32(rc->rc_result);
140 rc->rc_id = cpu_to_le64(rc->rc_id);
141 rc->rc_seq = cpu_to_le64(rc->rc_seq);
142 rc->rc_seq_reply = cpu_to_le64(rc->rc_seq_reply);
143}
144
145void dlm_rcom_in(struct dlm_rcom *rc)
146{
114 rc->rc_type = cpu_to_le32(rc->rc_type);
115 rc->rc_result = cpu_to_le32(rc->rc_result);
116 rc->rc_id = cpu_to_le64(rc->rc_id);
117 rc->rc_seq = cpu_to_le64(rc->rc_seq);
118 rc->rc_seq_reply = cpu_to_le64(rc->rc_seq_reply);
119}
120
121void dlm_rcom_in(struct dlm_rcom *rc)
122{
147 header_in(&rc->rc_header);
148
149 rc->rc_type = le32_to_cpu(rc->rc_type);
150 rc->rc_result = le32_to_cpu(rc->rc_result);
151 rc->rc_id = le64_to_cpu(rc->rc_id);
152 rc->rc_seq = le64_to_cpu(rc->rc_seq);
153 rc->rc_seq_reply = le64_to_cpu(rc->rc_seq_reply);
154}
123 rc->rc_type = le32_to_cpu(rc->rc_type);
124 rc->rc_result = le32_to_cpu(rc->rc_result);
125 rc->rc_id = le64_to_cpu(rc->rc_id);
126 rc->rc_seq = le64_to_cpu(rc->rc_seq);
127 rc->rc_seq_reply = le64_to_cpu(rc->rc_seq_reply);
128}