1 // SPDX-License-Identifier: GPL-2.0-only 1 // SPDX-License-Identifier: GPL-2.0-only 2 /********************************************* 2 /****************************************************************************** 3 ********************************************** 3 ******************************************************************************* 4 ** 4 ** 5 ** Copyright (C) 2005-2008 Red Hat, Inc. All 5 ** Copyright (C) 2005-2008 Red Hat, Inc. All rights reserved. 6 ** 6 ** 7 ** 7 ** 8 ********************************************** 8 ******************************************************************************* 9 ********************************************** 9 ******************************************************************************/ 10 10 11 #include "dlm_internal.h" 11 #include "dlm_internal.h" 12 #include "rcom.h" 12 #include "rcom.h" 13 #include "util.h" 13 #include "util.h" 14 14 15 #define DLM_ERRNO_EDEADLK 35 15 #define DLM_ERRNO_EDEADLK 35 16 #define DLM_ERRNO_EBADR 53 16 #define DLM_ERRNO_EBADR 53 17 #define DLM_ERRNO_EBADSLT 57 17 #define DLM_ERRNO_EBADSLT 57 18 #define DLM_ERRNO_EPROTO 71 18 #define DLM_ERRNO_EPROTO 71 19 #define DLM_ERRNO_EOPNOTSUPP 95 19 #define DLM_ERRNO_EOPNOTSUPP 95 20 #define DLM_ERRNO_ETIMEDOUT 110 20 #define DLM_ERRNO_ETIMEDOUT 110 21 #define DLM_ERRNO_EINPROGRESS 115 21 #define DLM_ERRNO_EINPROGRESS 115 22 22 >> 23 static void header_out(struct dlm_header *hd) >> 24 { >> 25 hd->h_version = cpu_to_le32(hd->h_version); >> 26 hd->h_lockspace = cpu_to_le32(hd->h_lockspace); >> 27 hd->h_nodeid = cpu_to_le32(hd->h_nodeid); >> 28 hd->h_length = cpu_to_le16(hd->h_length); >> 29 } >> 30 >> 31 static void header_in(struct dlm_header *hd) >> 32 { >> 33 hd->h_version = le32_to_cpu(hd->h_version); >> 34 hd->h_lockspace = le32_to_cpu(hd->h_lockspace); >> 35 hd->h_nodeid = le32_to_cpu(hd->h_nodeid); >> 36 hd->h_length = le16_to_cpu(hd->h_length); >> 37 } >> 38 23 /* higher errno values are inconsistent across 39 /* higher errno values are inconsistent across architectures, so select 24 one set of values for on the wire */ 40 one set of values for on the wire */ 25 41 26 int to_dlm_errno(int err) !! 42 static int to_dlm_errno(int err) 27 { 43 { 28 switch (err) { 44 switch (err) { 29 case -EDEADLK: 45 case -EDEADLK: 30 return -DLM_ERRNO_EDEADLK; 46 return -DLM_ERRNO_EDEADLK; 31 case -EBADR: 47 case -EBADR: 32 return -DLM_ERRNO_EBADR; 48 return -DLM_ERRNO_EBADR; 33 case -EBADSLT: 49 case -EBADSLT: 34 return -DLM_ERRNO_EBADSLT; 50 return -DLM_ERRNO_EBADSLT; 35 case -EPROTO: 51 case -EPROTO: 36 return -DLM_ERRNO_EPROTO; 52 return -DLM_ERRNO_EPROTO; 37 case -EOPNOTSUPP: 53 case -EOPNOTSUPP: 38 return -DLM_ERRNO_EOPNOTSUPP; 54 return -DLM_ERRNO_EOPNOTSUPP; 39 case -ETIMEDOUT: 55 case -ETIMEDOUT: 40 return -DLM_ERRNO_ETIMEDOUT; 56 return -DLM_ERRNO_ETIMEDOUT; 41 case -EINPROGRESS: 57 case -EINPROGRESS: 42 return -DLM_ERRNO_EINPROGRESS; 58 return -DLM_ERRNO_EINPROGRESS; 43 } 59 } 44 return err; 60 return err; 45 } 61 } 46 62 47 int from_dlm_errno(int err) !! 63 static int from_dlm_errno(int err) 48 { 64 { 49 switch (err) { 65 switch (err) { 50 case -DLM_ERRNO_EDEADLK: 66 case -DLM_ERRNO_EDEADLK: 51 return -EDEADLK; 67 return -EDEADLK; 52 case -DLM_ERRNO_EBADR: 68 case -DLM_ERRNO_EBADR: 53 return -EBADR; 69 return -EBADR; 54 case -DLM_ERRNO_EBADSLT: 70 case -DLM_ERRNO_EBADSLT: 55 return -EBADSLT; 71 return -EBADSLT; 56 case -DLM_ERRNO_EPROTO: 72 case -DLM_ERRNO_EPROTO: 57 return -EPROTO; 73 return -EPROTO; 58 case -DLM_ERRNO_EOPNOTSUPP: 74 case -DLM_ERRNO_EOPNOTSUPP: 59 return -EOPNOTSUPP; 75 return -EOPNOTSUPP; 60 case -DLM_ERRNO_ETIMEDOUT: 76 case -DLM_ERRNO_ETIMEDOUT: 61 return -ETIMEDOUT; 77 return -ETIMEDOUT; 62 case -DLM_ERRNO_EINPROGRESS: 78 case -DLM_ERRNO_EINPROGRESS: 63 return -EINPROGRESS; 79 return -EINPROGRESS; 64 } 80 } 65 return err; 81 return err; >> 82 } >> 83 >> 84 void dlm_message_out(struct dlm_message *ms) >> 85 { >> 86 header_out(&ms->m_header); >> 87 >> 88 ms->m_type = cpu_to_le32(ms->m_type); >> 89 ms->m_nodeid = cpu_to_le32(ms->m_nodeid); >> 90 ms->m_pid = cpu_to_le32(ms->m_pid); >> 91 ms->m_lkid = cpu_to_le32(ms->m_lkid); >> 92 ms->m_remid = cpu_to_le32(ms->m_remid); >> 93 ms->m_parent_lkid = cpu_to_le32(ms->m_parent_lkid); >> 94 ms->m_parent_remid = cpu_to_le32(ms->m_parent_remid); >> 95 ms->m_exflags = cpu_to_le32(ms->m_exflags); >> 96 ms->m_sbflags = cpu_to_le32(ms->m_sbflags); >> 97 ms->m_flags = cpu_to_le32(ms->m_flags); >> 98 ms->m_lvbseq = cpu_to_le32(ms->m_lvbseq); >> 99 ms->m_hash = cpu_to_le32(ms->m_hash); >> 100 ms->m_status = cpu_to_le32(ms->m_status); >> 101 ms->m_grmode = cpu_to_le32(ms->m_grmode); >> 102 ms->m_rqmode = cpu_to_le32(ms->m_rqmode); >> 103 ms->m_bastmode = cpu_to_le32(ms->m_bastmode); >> 104 ms->m_asts = cpu_to_le32(ms->m_asts); >> 105 ms->m_result = cpu_to_le32(to_dlm_errno(ms->m_result)); >> 106 } >> 107 >> 108 void dlm_message_in(struct dlm_message *ms) >> 109 { >> 110 header_in(&ms->m_header); >> 111 >> 112 ms->m_type = le32_to_cpu(ms->m_type); >> 113 ms->m_nodeid = le32_to_cpu(ms->m_nodeid); >> 114 ms->m_pid = le32_to_cpu(ms->m_pid); >> 115 ms->m_lkid = le32_to_cpu(ms->m_lkid); >> 116 ms->m_remid = le32_to_cpu(ms->m_remid); >> 117 ms->m_parent_lkid = le32_to_cpu(ms->m_parent_lkid); >> 118 ms->m_parent_remid = le32_to_cpu(ms->m_parent_remid); >> 119 ms->m_exflags = le32_to_cpu(ms->m_exflags); >> 120 ms->m_sbflags = le32_to_cpu(ms->m_sbflags); >> 121 ms->m_flags = le32_to_cpu(ms->m_flags); >> 122 ms->m_lvbseq = le32_to_cpu(ms->m_lvbseq); >> 123 ms->m_hash = le32_to_cpu(ms->m_hash); >> 124 ms->m_status = le32_to_cpu(ms->m_status); >> 125 ms->m_grmode = le32_to_cpu(ms->m_grmode); >> 126 ms->m_rqmode = le32_to_cpu(ms->m_rqmode); >> 127 ms->m_bastmode = le32_to_cpu(ms->m_bastmode); >> 128 ms->m_asts = le32_to_cpu(ms->m_asts); >> 129 ms->m_result = from_dlm_errno(le32_to_cpu(ms->m_result)); >> 130 } >> 131 >> 132 void dlm_rcom_out(struct dlm_rcom *rc) >> 133 { >> 134 header_out(&rc->rc_header); >> 135 >> 136 rc->rc_type = cpu_to_le32(rc->rc_type); >> 137 rc->rc_result = cpu_to_le32(rc->rc_result); >> 138 rc->rc_id = cpu_to_le64(rc->rc_id); >> 139 rc->rc_seq = cpu_to_le64(rc->rc_seq); >> 140 rc->rc_seq_reply = cpu_to_le64(rc->rc_seq_reply); >> 141 } >> 142 >> 143 void dlm_rcom_in(struct dlm_rcom *rc) >> 144 { >> 145 header_in(&rc->rc_header); >> 146 >> 147 rc->rc_type = le32_to_cpu(rc->rc_type); >> 148 rc->rc_result = le32_to_cpu(rc->rc_result); >> 149 rc->rc_id = le64_to_cpu(rc->rc_id); >> 150 rc->rc_seq = le64_to_cpu(rc->rc_seq); >> 151 rc->rc_seq_reply = le64_to_cpu(rc->rc_seq_reply); 66 } 152 } 67 153
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.