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

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'dlm-5.19' of git://git.kernel.org/pub/scm/linux/kernel/git/teigland/linux-dlm

Pull dlm updates from David Teigland:
"This includes several large patches to improve endian handling and
remove sparse warnings. The code previously used in/out, in-place
endianness conversion functions.

Other code cleanup includes the list iterator changes.

Finally, a long standing bug was found and fixed, caused by missed
decrement on an lock struct ref count"

* tag 'dlm-5.19' of git://git.kernel.org/pub/scm/linux/kernel/git/teigland/linux-dlm: (28 commits)
dlm: use kref_put_lock in __put_lkb
dlm: use kref_put_lock in put_rsb
dlm: remove unnecessary error assign
dlm: fix missing lkb refcount handling
fs: dlm: cast resource pointer to uintptr_t
dlm: replace usage of found with dedicated list iterator variable
dlm: remove usage of list iterator for list_add() after the loop body
dlm: fix pending remove if msg allocation fails
dlm: fix wake_up() calls for pending remove
dlm: check required context while close
dlm: cleanup lock handling in dlm_master_lookup
dlm: remove found label in dlm_master_lookup
dlm: remove __user conversion warnings
dlm: move conversion to compile time
dlm: use __le types for dlm messages
dlm: use __le types for rcom messages
dlm: use __le types for dlm header
dlm: use __le types for options header
dlm: add __CHECKER__ for false positives
dlm: move global to static inits
...

+633 -669
+1 -1
fs/dlm/dir.c
··· 101 101 */ 102 102 103 103 b = ls->ls_recover_buf->rc_buf; 104 - left = ls->ls_recover_buf->rc_header.h_length; 104 + left = le16_to_cpu(ls->ls_recover_buf->rc_header.h_length); 105 105 left -= sizeof(struct dlm_rcom); 106 106 107 107 for (;;) {
+33 -33
fs/dlm/dlm_internal.h
··· 379 379 #define DLM_FIN 5 380 380 381 381 struct dlm_header { 382 - uint32_t h_version; 382 + __le32 h_version; 383 383 union { 384 384 /* for DLM_MSG and DLM_RCOM */ 385 - uint32_t h_lockspace; 385 + __le32 h_lockspace; 386 386 /* for DLM_ACK and DLM_OPTS */ 387 - uint32_t h_seq; 387 + __le32 h_seq; 388 388 } u; 389 - uint32_t h_nodeid; /* nodeid of sender */ 390 - uint16_t h_length; 389 + __le32 h_nodeid; /* nodeid of sender */ 390 + __le16 h_length; 391 391 uint8_t h_cmd; /* DLM_MSG, DLM_RCOM */ 392 392 uint8_t h_pad; 393 393 }; ··· 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 ··· 451 451 452 452 struct dlm_rcom { 453 453 struct dlm_header rc_header; 454 - uint32_t rc_type; /* DLM_RCOM_ */ 455 - int rc_result; /* multi-purpose */ 456 - uint64_t rc_id; /* match reply with request */ 457 - uint64_t rc_seq; /* sender's ls_recover_seq */ 458 - uint64_t rc_seq_reply; /* remote ls_recover_seq */ 454 + __le32 rc_type; /* DLM_RCOM_ */ 455 + __le32 rc_result; /* multi-purpose */ 456 + __le64 rc_id; /* match reply with request */ 457 + __le64 rc_seq; /* sender's ls_recover_seq */ 458 + __le64 rc_seq_reply; /* remote ls_recover_seq */ 459 459 char rc_buf[]; 460 460 }; 461 461 462 462 struct dlm_opt_header { 463 - uint16_t t_type; 464 - uint16_t t_length; 465 - uint32_t t_pad; 463 + __le16 t_type; 464 + __le16 t_length; 465 + __le32 t_pad; 466 466 /* need to be 8 byte aligned */ 467 467 char t_value[]; 468 468 }; ··· 472 472 struct dlm_header o_header; 473 473 uint8_t o_nextcmd; 474 474 uint8_t o_pad; 475 - uint16_t o_optlen; 476 - uint32_t o_pad2; 475 + __le16 o_optlen; 476 + __le32 o_pad2; 477 477 char o_opts[]; 478 478 }; 479 479
+348 -306
fs/dlm/lock.c
··· 350 350 { 351 351 struct dlm_ls *ls = r->res_ls; 352 352 uint32_t bucket = r->res_bucket; 353 + int rv; 353 354 354 - spin_lock(&ls->ls_rsbtbl[bucket].lock); 355 - kref_put(&r->res_ref, toss_rsb); 356 - spin_unlock(&ls->ls_rsbtbl[bucket].lock); 355 + rv = kref_put_lock(&r->res_ref, toss_rsb, 356 + &ls->ls_rsbtbl[bucket].lock); 357 + if (rv) 358 + spin_unlock(&ls->ls_rsbtbl[bucket].lock); 357 359 } 358 360 359 361 void dlm_put_rsb(struct dlm_rsb *r) ··· 604 602 */ 605 603 606 604 kref_get(&r->res_ref); 607 - error = 0; 608 605 goto out_unlock; 609 606 610 607 ··· 881 880 } 882 881 } 883 882 883 + static void __dlm_master_lookup(struct dlm_ls *ls, struct dlm_rsb *r, int our_nodeid, 884 + int from_nodeid, bool toss_list, unsigned int flags, 885 + int *r_nodeid, int *result) 886 + { 887 + int fix_master = (flags & DLM_LU_RECOVER_MASTER); 888 + int from_master = (flags & DLM_LU_RECOVER_DIR); 889 + 890 + if (r->res_dir_nodeid != our_nodeid) { 891 + /* should not happen, but may as well fix it and carry on */ 892 + log_error(ls, "%s res_dir %d our %d %s", __func__, 893 + r->res_dir_nodeid, our_nodeid, r->res_name); 894 + r->res_dir_nodeid = our_nodeid; 895 + } 896 + 897 + if (fix_master && dlm_is_removed(ls, r->res_master_nodeid)) { 898 + /* Recovery uses this function to set a new master when 899 + * the previous master failed. Setting NEW_MASTER will 900 + * force dlm_recover_masters to call recover_master on this 901 + * rsb even though the res_nodeid is no longer removed. 902 + */ 903 + 904 + r->res_master_nodeid = from_nodeid; 905 + r->res_nodeid = from_nodeid; 906 + rsb_set_flag(r, RSB_NEW_MASTER); 907 + 908 + if (toss_list) { 909 + /* I don't think we should ever find it on toss list. */ 910 + log_error(ls, "%s fix_master on toss", __func__); 911 + dlm_dump_rsb(r); 912 + } 913 + } 914 + 915 + if (from_master && (r->res_master_nodeid != from_nodeid)) { 916 + /* this will happen if from_nodeid became master during 917 + * a previous recovery cycle, and we aborted the previous 918 + * cycle before recovering this master value 919 + */ 920 + 921 + log_limit(ls, "%s from_master %d master_nodeid %d res_nodeid %d first %x %s", 922 + __func__, from_nodeid, r->res_master_nodeid, 923 + r->res_nodeid, r->res_first_lkid, r->res_name); 924 + 925 + if (r->res_master_nodeid == our_nodeid) { 926 + log_error(ls, "from_master %d our_master", from_nodeid); 927 + dlm_dump_rsb(r); 928 + goto ret_assign; 929 + } 930 + 931 + r->res_master_nodeid = from_nodeid; 932 + r->res_nodeid = from_nodeid; 933 + rsb_set_flag(r, RSB_NEW_MASTER); 934 + } 935 + 936 + if (!r->res_master_nodeid) { 937 + /* this will happen if recovery happens while we're looking 938 + * up the master for this rsb 939 + */ 940 + 941 + log_debug(ls, "%s master 0 to %d first %x %s", __func__, 942 + from_nodeid, r->res_first_lkid, r->res_name); 943 + r->res_master_nodeid = from_nodeid; 944 + r->res_nodeid = from_nodeid; 945 + } 946 + 947 + if (!from_master && !fix_master && 948 + (r->res_master_nodeid == from_nodeid)) { 949 + /* this can happen when the master sends remove, the dir node 950 + * finds the rsb on the keep list and ignores the remove, 951 + * and the former master sends a lookup 952 + */ 953 + 954 + log_limit(ls, "%s from master %d flags %x first %x %s", 955 + __func__, from_nodeid, flags, r->res_first_lkid, 956 + r->res_name); 957 + } 958 + 959 + ret_assign: 960 + *r_nodeid = r->res_master_nodeid; 961 + if (result) 962 + *result = DLM_LU_MATCH; 963 + } 964 + 884 965 /* 885 966 * We're the dir node for this res and another node wants to know the 886 967 * master nodeid. During normal operation (non recovery) this is only ··· 997 914 { 998 915 struct dlm_rsb *r = NULL; 999 916 uint32_t hash, b; 1000 - int from_master = (flags & DLM_LU_RECOVER_DIR); 1001 - int fix_master = (flags & DLM_LU_RECOVER_MASTER); 1002 917 int our_nodeid = dlm_our_nodeid(); 1003 - int dir_nodeid, error, toss_list = 0; 918 + int dir_nodeid, error; 1004 919 1005 920 if (len > DLM_RESNAME_MAXLEN) 1006 921 return -EINVAL; ··· 1030 949 error = dlm_search_rsb_tree(&ls->ls_rsbtbl[b].keep, name, len, &r); 1031 950 if (!error) { 1032 951 /* because the rsb is active, we need to lock_rsb before 1033 - checking/changing re_master_nodeid */ 952 + * checking/changing re_master_nodeid 953 + */ 1034 954 1035 955 hold_rsb(r); 1036 956 spin_unlock(&ls->ls_rsbtbl[b].lock); 1037 957 lock_rsb(r); 1038 - goto found; 958 + 959 + __dlm_master_lookup(ls, r, our_nodeid, from_nodeid, false, 960 + flags, r_nodeid, result); 961 + 962 + /* the rsb was active */ 963 + unlock_rsb(r); 964 + put_rsb(r); 965 + 966 + return 0; 1039 967 } 1040 968 1041 969 error = dlm_search_rsb_tree(&ls->ls_rsbtbl[b].toss, name, len, &r); ··· 1052 962 goto not_found; 1053 963 1054 964 /* because the rsb is inactive (on toss list), it's not refcounted 1055 - and lock_rsb is not used, but is protected by the rsbtbl lock */ 965 + * and lock_rsb is not used, but is protected by the rsbtbl lock 966 + */ 1056 967 1057 - toss_list = 1; 1058 - found: 1059 - if (r->res_dir_nodeid != our_nodeid) { 1060 - /* should not happen, but may as well fix it and carry on */ 1061 - log_error(ls, "dlm_master_lookup res_dir %d our %d %s", 1062 - r->res_dir_nodeid, our_nodeid, r->res_name); 1063 - r->res_dir_nodeid = our_nodeid; 1064 - } 968 + __dlm_master_lookup(ls, r, our_nodeid, from_nodeid, true, flags, 969 + r_nodeid, result); 1065 970 1066 - if (fix_master && dlm_is_removed(ls, r->res_master_nodeid)) { 1067 - /* Recovery uses this function to set a new master when 1068 - the previous master failed. Setting NEW_MASTER will 1069 - force dlm_recover_masters to call recover_master on this 1070 - rsb even though the res_nodeid is no longer removed. */ 971 + r->res_toss_time = jiffies; 972 + /* the rsb was inactive (on toss list) */ 973 + spin_unlock(&ls->ls_rsbtbl[b].lock); 1071 974 1072 - r->res_master_nodeid = from_nodeid; 1073 - r->res_nodeid = from_nodeid; 1074 - rsb_set_flag(r, RSB_NEW_MASTER); 1075 - 1076 - if (toss_list) { 1077 - /* I don't think we should ever find it on toss list. */ 1078 - log_error(ls, "dlm_master_lookup fix_master on toss"); 1079 - dlm_dump_rsb(r); 1080 - } 1081 - } 1082 - 1083 - if (from_master && (r->res_master_nodeid != from_nodeid)) { 1084 - /* this will happen if from_nodeid became master during 1085 - a previous recovery cycle, and we aborted the previous 1086 - cycle before recovering this master value */ 1087 - 1088 - log_limit(ls, "dlm_master_lookup from_master %d " 1089 - "master_nodeid %d res_nodeid %d first %x %s", 1090 - from_nodeid, r->res_master_nodeid, r->res_nodeid, 1091 - r->res_first_lkid, r->res_name); 1092 - 1093 - if (r->res_master_nodeid == our_nodeid) { 1094 - log_error(ls, "from_master %d our_master", from_nodeid); 1095 - dlm_dump_rsb(r); 1096 - goto out_found; 1097 - } 1098 - 1099 - r->res_master_nodeid = from_nodeid; 1100 - r->res_nodeid = from_nodeid; 1101 - rsb_set_flag(r, RSB_NEW_MASTER); 1102 - } 1103 - 1104 - if (!r->res_master_nodeid) { 1105 - /* this will happen if recovery happens while we're looking 1106 - up the master for this rsb */ 1107 - 1108 - log_debug(ls, "dlm_master_lookup master 0 to %d first %x %s", 1109 - from_nodeid, r->res_first_lkid, r->res_name); 1110 - r->res_master_nodeid = from_nodeid; 1111 - r->res_nodeid = from_nodeid; 1112 - } 1113 - 1114 - if (!from_master && !fix_master && 1115 - (r->res_master_nodeid == from_nodeid)) { 1116 - /* this can happen when the master sends remove, the dir node 1117 - finds the rsb on the keep list and ignores the remove, 1118 - and the former master sends a lookup */ 1119 - 1120 - log_limit(ls, "dlm_master_lookup from master %d flags %x " 1121 - "first %x %s", from_nodeid, flags, 1122 - r->res_first_lkid, r->res_name); 1123 - } 1124 - 1125 - out_found: 1126 - *r_nodeid = r->res_master_nodeid; 1127 - if (result) 1128 - *result = DLM_LU_MATCH; 1129 - 1130 - if (toss_list) { 1131 - r->res_toss_time = jiffies; 1132 - /* the rsb was inactive (on toss list) */ 1133 - spin_unlock(&ls->ls_rsbtbl[b].lock); 1134 - } else { 1135 - /* the rsb was active */ 1136 - unlock_rsb(r); 1137 - put_rsb(r); 1138 - } 1139 975 return 0; 1140 976 1141 977 not_found: ··· 1092 1076 if (result) 1093 1077 *result = DLM_LU_ADD; 1094 1078 *r_nodeid = from_nodeid; 1095 - error = 0; 1096 1079 out_unlock: 1097 1080 spin_unlock(&ls->ls_rsbtbl[b].lock); 1098 1081 return error; ··· 1268 1253 static int __put_lkb(struct dlm_ls *ls, struct dlm_lkb *lkb) 1269 1254 { 1270 1255 uint32_t lkid = lkb->lkb_id; 1256 + int rv; 1271 1257 1272 - spin_lock(&ls->ls_lkbidr_spin); 1273 - if (kref_put(&lkb->lkb_ref, kill_lkb)) { 1258 + rv = kref_put_lock(&lkb->lkb_ref, kill_lkb, 1259 + &ls->ls_lkbidr_spin); 1260 + if (rv) { 1274 1261 idr_remove(&ls->ls_lkbidr, lkid); 1275 1262 spin_unlock(&ls->ls_lkbidr_spin); 1276 1263 ··· 1282 1265 if (lkb->lkb_lvbptr && is_master_copy(lkb)) 1283 1266 dlm_free_lvb(lkb->lkb_lvbptr); 1284 1267 dlm_free_lkb(lkb); 1285 - return 1; 1286 - } else { 1287 - spin_unlock(&ls->ls_lkbidr_spin); 1288 - return 0; 1289 1268 } 1269 + 1270 + return rv; 1290 1271 } 1291 1272 1292 1273 int dlm_put_lkb(struct dlm_lkb *lkb) ··· 1321 1306 static void lkb_add_ordered(struct list_head *new, struct list_head *head, 1322 1307 int mode) 1323 1308 { 1324 - struct dlm_lkb *lkb = NULL; 1309 + struct dlm_lkb *lkb = NULL, *iter; 1325 1310 1326 - list_for_each_entry(lkb, head, lkb_statequeue) 1327 - if (lkb->lkb_rqmode < mode) 1311 + list_for_each_entry(iter, head, lkb_statequeue) 1312 + if (iter->lkb_rqmode < mode) { 1313 + lkb = iter; 1314 + list_add_tail(new, &iter->lkb_statequeue); 1328 1315 break; 1316 + } 1329 1317 1330 - __list_add(new, lkb->lkb_statequeue.prev, &lkb->lkb_statequeue); 1318 + if (!lkb) 1319 + list_add_tail(new, head); 1331 1320 } 1332 1321 1333 1322 /* add/remove lkb to rsb's grant/convert/wait queue */ ··· 1578 1559 lkb->lkb_wait_type = 0; 1579 1560 lkb->lkb_flags &= ~DLM_IFL_OVERLAP_CANCEL; 1580 1561 lkb->lkb_wait_count--; 1562 + unhold_lkb(lkb); 1581 1563 goto out_del; 1582 1564 } 1583 1565 ··· 1591 1571 } 1592 1572 1593 1573 log_error(ls, "remwait error %x remote %d %x msg %d flags %x no wait", 1594 - lkb->lkb_id, ms ? ms->m_header.h_nodeid : 0, lkb->lkb_remid, 1595 - mstype, lkb->lkb_flags); 1574 + lkb->lkb_id, ms ? le32_to_cpu(ms->m_header.h_nodeid) : 0, 1575 + lkb->lkb_remid, mstype, lkb->lkb_flags); 1596 1576 return -1; 1597 1577 1598 1578 out_del: ··· 1605 1585 log_error(ls, "remwait error %x reply %d wait_type %d overlap", 1606 1586 lkb->lkb_id, mstype, lkb->lkb_wait_type); 1607 1587 lkb->lkb_wait_count--; 1588 + unhold_lkb(lkb); 1608 1589 lkb->lkb_wait_type = 0; 1609 1590 } 1610 1591 ··· 1638 1617 struct dlm_ls *ls = lkb->lkb_resource->res_ls; 1639 1618 int error; 1640 1619 1641 - if (ms->m_flags != DLM_IFL_STUB_MS) 1620 + if (ms->m_flags != cpu_to_le32(DLM_IFL_STUB_MS)) 1642 1621 mutex_lock(&ls->ls_waiters_mutex); 1643 - error = _remove_from_waiters(lkb, ms->m_type, ms); 1644 - 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)) 1645 1624 mutex_unlock(&ls->ls_waiters_mutex); 1646 1625 return error; 1647 1626 } ··· 1816 1795 memcpy(ls->ls_remove_name, name, DLM_RESNAME_MAXLEN); 1817 1796 spin_unlock(&ls->ls_remove_spin); 1818 1797 spin_unlock(&ls->ls_rsbtbl[b].lock); 1819 - wake_up(&ls->ls_remove_wait); 1820 1798 1821 1799 send_remove(r); 1822 1800 ··· 1824 1804 ls->ls_remove_len = 0; 1825 1805 memset(ls->ls_remove_name, 0, DLM_RESNAME_MAXLEN); 1826 1806 spin_unlock(&ls->ls_remove_spin); 1807 + wake_up(&ls->ls_remove_wait); 1827 1808 1828 1809 dlm_free_rsb(r); 1829 1810 } ··· 1887 1866 void dlm_scan_timeout(struct dlm_ls *ls) 1888 1867 { 1889 1868 struct dlm_rsb *r; 1890 - struct dlm_lkb *lkb; 1869 + struct dlm_lkb *lkb = NULL, *iter; 1891 1870 int do_cancel, do_warn; 1892 1871 s64 wait_us; 1893 1872 ··· 1898 1877 do_cancel = 0; 1899 1878 do_warn = 0; 1900 1879 mutex_lock(&ls->ls_timeout_mutex); 1901 - list_for_each_entry(lkb, &ls->ls_timeout, lkb_time_list) { 1880 + list_for_each_entry(iter, &ls->ls_timeout, lkb_time_list) { 1902 1881 1903 1882 wait_us = ktime_to_us(ktime_sub(ktime_get(), 1904 - lkb->lkb_timestamp)); 1883 + iter->lkb_timestamp)); 1905 1884 1906 - if ((lkb->lkb_exflags & DLM_LKF_TIMEOUT) && 1907 - wait_us >= (lkb->lkb_timeout_cs * 10000)) 1885 + if ((iter->lkb_exflags & DLM_LKF_TIMEOUT) && 1886 + wait_us >= (iter->lkb_timeout_cs * 10000)) 1908 1887 do_cancel = 1; 1909 1888 1910 - if ((lkb->lkb_flags & DLM_IFL_WATCH_TIMEWARN) && 1889 + if ((iter->lkb_flags & DLM_IFL_WATCH_TIMEWARN) && 1911 1890 wait_us >= dlm_config.ci_timewarn_cs * 10000) 1912 1891 do_warn = 1; 1913 1892 1914 1893 if (!do_cancel && !do_warn) 1915 1894 continue; 1916 - hold_lkb(lkb); 1895 + hold_lkb(iter); 1896 + lkb = iter; 1917 1897 break; 1918 1898 } 1919 1899 mutex_unlock(&ls->ls_timeout_mutex); 1920 1900 1921 - if (!do_cancel && !do_warn) 1901 + if (!lkb) 1922 1902 break; 1923 1903 1924 1904 r = lkb->lkb_resource; ··· 2073 2051 if (len > r->res_ls->ls_lvblen) 2074 2052 len = r->res_ls->ls_lvblen; 2075 2053 memcpy(lkb->lkb_lvbptr, ms->m_extra, len); 2076 - lkb->lkb_lvbseq = ms->m_lvbseq; 2054 + lkb->lkb_lvbseq = le32_to_cpu(ms->m_lvbseq); 2077 2055 } 2078 2056 } 2079 2057 ··· 2204 2182 2205 2183 static void munge_altmode(struct dlm_lkb *lkb, struct dlm_message *ms) 2206 2184 { 2207 - if (ms->m_type != DLM_MSG_REQUEST_REPLY && 2208 - 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)) { 2209 2187 log_print("munge_altmode %x invalid reply type %d", 2210 - lkb->lkb_id, ms->m_type); 2188 + lkb->lkb_id, le32_to_cpu(ms->m_type)); 2211 2189 return; 2212 2190 } 2213 2191 ··· 2934 2912 if (lkb->lkb_status != DLM_LKSTS_GRANTED) 2935 2913 goto out; 2936 2914 2937 - if (lkb->lkb_wait_type) 2915 + /* lock not allowed if there's any op in progress */ 2916 + if (lkb->lkb_wait_type || lkb->lkb_wait_count) 2938 2917 goto out; 2939 2918 2940 2919 if (is_overlap(lkb)) ··· 3586 3563 3587 3564 ms = (struct dlm_message *) mb; 3588 3565 3589 - ms->m_header.h_version = (DLM_HEADER_MAJOR | DLM_HEADER_MINOR); 3590 - ms->m_header.u.h_lockspace = ls->ls_global_id; 3591 - ms->m_header.h_nodeid = dlm_our_nodeid(); 3592 - ms->m_header.h_length = mb_len; 3566 + ms->m_header.h_version = cpu_to_le32(DLM_HEADER_MAJOR | DLM_HEADER_MINOR); 3567 + ms->m_header.u.h_lockspace = cpu_to_le32(ls->ls_global_id); 3568 + ms->m_header.h_nodeid = cpu_to_le32(dlm_our_nodeid()); 3569 + ms->m_header.h_length = cpu_to_le16(mb_len); 3593 3570 ms->m_header.h_cmd = DLM_MSG; 3594 3571 3595 - ms->m_type = mstype; 3572 + ms->m_type = cpu_to_le32(mstype); 3596 3573 3597 3574 *mh_ret = mh; 3598 3575 *ms_ret = ms; ··· 3631 3608 3632 3609 static int send_message(struct dlm_mhandle *mh, struct dlm_message *ms) 3633 3610 { 3634 - dlm_message_out(ms); 3635 3611 dlm_midcomms_commit_mhandle(mh); 3636 3612 return 0; 3637 3613 } ··· 3638 3616 static void send_args(struct dlm_rsb *r, struct dlm_lkb *lkb, 3639 3617 struct dlm_message *ms) 3640 3618 { 3641 - ms->m_nodeid = lkb->lkb_nodeid; 3642 - ms->m_pid = lkb->lkb_ownpid; 3643 - ms->m_lkid = lkb->lkb_id; 3644 - ms->m_remid = lkb->lkb_remid; 3645 - ms->m_exflags = lkb->lkb_exflags; 3646 - ms->m_sbflags = lkb->lkb_sbflags; 3647 - ms->m_flags = lkb->lkb_flags; 3648 - ms->m_lvbseq = lkb->lkb_lvbseq; 3649 - ms->m_status = lkb->lkb_status; 3650 - ms->m_grmode = lkb->lkb_grmode; 3651 - ms->m_rqmode = lkb->lkb_rqmode; 3652 - ms->m_hash = r->res_hash; 3619 + ms->m_nodeid = cpu_to_le32(lkb->lkb_nodeid); 3620 + ms->m_pid = cpu_to_le32(lkb->lkb_ownpid); 3621 + ms->m_lkid = cpu_to_le32(lkb->lkb_id); 3622 + ms->m_remid = cpu_to_le32(lkb->lkb_remid); 3623 + ms->m_exflags = cpu_to_le32(lkb->lkb_exflags); 3624 + ms->m_sbflags = cpu_to_le32(lkb->lkb_sbflags); 3625 + ms->m_flags = cpu_to_le32(lkb->lkb_flags); 3626 + ms->m_lvbseq = cpu_to_le32(lkb->lkb_lvbseq); 3627 + ms->m_status = cpu_to_le32(lkb->lkb_status); 3628 + ms->m_grmode = cpu_to_le32(lkb->lkb_grmode); 3629 + ms->m_rqmode = cpu_to_le32(lkb->lkb_rqmode); 3630 + ms->m_hash = cpu_to_le32(r->res_hash); 3653 3631 3654 3632 /* m_result and m_bastmode are set from function args, 3655 3633 not from lkb fields */ 3656 3634 3657 3635 if (lkb->lkb_bastfn) 3658 - ms->m_asts |= DLM_CB_BAST; 3636 + ms->m_asts |= cpu_to_le32(DLM_CB_BAST); 3659 3637 if (lkb->lkb_astfn) 3660 - ms->m_asts |= DLM_CB_CAST; 3638 + ms->m_asts |= cpu_to_le32(DLM_CB_CAST); 3661 3639 3662 3640 /* compare with switch in create_message; send_remove() doesn't 3663 3641 use send_args() */ 3664 3642 3665 3643 switch (ms->m_type) { 3666 - case DLM_MSG_REQUEST: 3667 - case DLM_MSG_LOOKUP: 3644 + case cpu_to_le32(DLM_MSG_REQUEST): 3645 + case cpu_to_le32(DLM_MSG_LOOKUP): 3668 3646 memcpy(ms->m_extra, r->res_name, r->res_length); 3669 3647 break; 3670 - case DLM_MSG_CONVERT: 3671 - case DLM_MSG_UNLOCK: 3672 - case DLM_MSG_REQUEST_REPLY: 3673 - case DLM_MSG_CONVERT_REPLY: 3674 - case DLM_MSG_GRANT: 3648 + case cpu_to_le32(DLM_MSG_CONVERT): 3649 + case cpu_to_le32(DLM_MSG_UNLOCK): 3650 + case cpu_to_le32(DLM_MSG_REQUEST_REPLY): 3651 + case cpu_to_le32(DLM_MSG_CONVERT_REPLY): 3652 + case cpu_to_le32(DLM_MSG_GRANT): 3675 3653 if (!lkb->lkb_lvbptr) 3676 3654 break; 3677 3655 memcpy(ms->m_extra, lkb->lkb_lvbptr, r->res_ls->ls_lvblen); ··· 3721 3699 /* down conversions go without a reply from the master */ 3722 3700 if (!error && down_conversion(lkb)) { 3723 3701 remove_from_waiters(lkb, DLM_MSG_CONVERT_REPLY); 3724 - r->res_ls->ls_stub_ms.m_flags = DLM_IFL_STUB_MS; 3725 - r->res_ls->ls_stub_ms.m_type = DLM_MSG_CONVERT_REPLY; 3702 + r->res_ls->ls_stub_ms.m_flags = cpu_to_le32(DLM_IFL_STUB_MS); 3703 + r->res_ls->ls_stub_ms.m_type = cpu_to_le32(DLM_MSG_CONVERT_REPLY); 3726 3704 r->res_ls->ls_stub_ms.m_result = 0; 3727 3705 __receive_convert_reply(r, lkb, &r->res_ls->ls_stub_ms); 3728 3706 } ··· 3779 3757 3780 3758 send_args(r, lkb, ms); 3781 3759 3782 - ms->m_bastmode = mode; 3760 + ms->m_bastmode = cpu_to_le32(mode); 3783 3761 3784 3762 error = send_message(mh, ms); 3785 3763 out: ··· 3827 3805 goto out; 3828 3806 3829 3807 memcpy(ms->m_extra, r->res_name, r->res_length); 3830 - ms->m_hash = r->res_hash; 3808 + ms->m_hash = cpu_to_le32(r->res_hash); 3831 3809 3832 3810 error = send_message(mh, ms); 3833 3811 out: ··· 3849 3827 3850 3828 send_args(r, lkb, ms); 3851 3829 3852 - ms->m_result = rv; 3830 + ms->m_result = cpu_to_le32(to_dlm_errno(rv)); 3853 3831 3854 3832 error = send_message(mh, ms); 3855 3833 out: ··· 3882 3860 struct dlm_rsb *r = &ls->ls_stub_rsb; 3883 3861 struct dlm_message *ms; 3884 3862 struct dlm_mhandle *mh; 3885 - int error, nodeid = ms_in->m_header.h_nodeid; 3863 + int error, nodeid = le32_to_cpu(ms_in->m_header.h_nodeid); 3886 3864 3887 3865 error = create_message(r, NULL, nodeid, DLM_MSG_LOOKUP_REPLY, &ms, &mh); 3888 3866 if (error) 3889 3867 goto out; 3890 3868 3891 3869 ms->m_lkid = ms_in->m_lkid; 3892 - ms->m_result = rv; 3893 - ms->m_nodeid = ret_nodeid; 3870 + ms->m_result = cpu_to_le32(to_dlm_errno(rv)); 3871 + ms->m_nodeid = cpu_to_le32(ret_nodeid); 3894 3872 3895 3873 error = send_message(mh, ms); 3896 3874 out: ··· 3903 3881 3904 3882 static void receive_flags(struct dlm_lkb *lkb, struct dlm_message *ms) 3905 3883 { 3906 - lkb->lkb_exflags = ms->m_exflags; 3907 - lkb->lkb_sbflags = ms->m_sbflags; 3884 + lkb->lkb_exflags = le32_to_cpu(ms->m_exflags); 3885 + lkb->lkb_sbflags = le32_to_cpu(ms->m_sbflags); 3908 3886 lkb->lkb_flags = (lkb->lkb_flags & 0xFFFF0000) | 3909 - (ms->m_flags & 0x0000FFFF); 3887 + (le32_to_cpu(ms->m_flags) & 0x0000FFFF); 3910 3888 } 3911 3889 3912 3890 static void receive_flags_reply(struct dlm_lkb *lkb, struct dlm_message *ms) 3913 3891 { 3914 - if (ms->m_flags == DLM_IFL_STUB_MS) 3892 + if (ms->m_flags == cpu_to_le32(DLM_IFL_STUB_MS)) 3915 3893 return; 3916 3894 3917 - lkb->lkb_sbflags = ms->m_sbflags; 3895 + lkb->lkb_sbflags = le32_to_cpu(ms->m_sbflags); 3918 3896 lkb->lkb_flags = (lkb->lkb_flags & 0xFFFF0000) | 3919 - (ms->m_flags & 0x0000FFFF); 3897 + (le32_to_cpu(ms->m_flags) & 0x0000FFFF); 3920 3898 } 3921 3899 3922 3900 static int receive_extralen(struct dlm_message *ms) 3923 3901 { 3924 - return (ms->m_header.h_length - sizeof(struct dlm_message)); 3902 + return (le16_to_cpu(ms->m_header.h_length) - 3903 + sizeof(struct dlm_message)); 3925 3904 } 3926 3905 3927 3906 static int receive_lvb(struct dlm_ls *ls, struct dlm_lkb *lkb, ··· 3956 3933 static int receive_request_args(struct dlm_ls *ls, struct dlm_lkb *lkb, 3957 3934 struct dlm_message *ms) 3958 3935 { 3959 - lkb->lkb_nodeid = ms->m_header.h_nodeid; 3960 - lkb->lkb_ownpid = ms->m_pid; 3961 - lkb->lkb_remid = ms->m_lkid; 3936 + lkb->lkb_nodeid = le32_to_cpu(ms->m_header.h_nodeid); 3937 + lkb->lkb_ownpid = le32_to_cpu(ms->m_pid); 3938 + lkb->lkb_remid = le32_to_cpu(ms->m_lkid); 3962 3939 lkb->lkb_grmode = DLM_LOCK_IV; 3963 - lkb->lkb_rqmode = ms->m_rqmode; 3940 + lkb->lkb_rqmode = le32_to_cpu(ms->m_rqmode); 3964 3941 3965 - lkb->lkb_bastfn = (ms->m_asts & DLM_CB_BAST) ? &fake_bastfn : NULL; 3966 - lkb->lkb_astfn = (ms->m_asts & DLM_CB_CAST) ? &fake_astfn : NULL; 3942 + lkb->lkb_bastfn = (ms->m_asts & cpu_to_le32(DLM_CB_BAST)) ? &fake_bastfn : NULL; 3943 + lkb->lkb_astfn = (ms->m_asts & cpu_to_le32(DLM_CB_CAST)) ? &fake_astfn : NULL; 3967 3944 3968 3945 if (lkb->lkb_exflags & DLM_LKF_VALBLK) { 3969 3946 /* lkb was just created so there won't be an lvb yet */ ··· 3984 3961 if (receive_lvb(ls, lkb, ms)) 3985 3962 return -ENOMEM; 3986 3963 3987 - lkb->lkb_rqmode = ms->m_rqmode; 3988 - lkb->lkb_lvbseq = ms->m_lvbseq; 3964 + lkb->lkb_rqmode = le32_to_cpu(ms->m_rqmode); 3965 + lkb->lkb_lvbseq = le32_to_cpu(ms->m_lvbseq); 3989 3966 3990 3967 return 0; 3991 3968 } ··· 4004 3981 static void setup_stub_lkb(struct dlm_ls *ls, struct dlm_message *ms) 4005 3982 { 4006 3983 struct dlm_lkb *lkb = &ls->ls_stub_lkb; 4007 - lkb->lkb_nodeid = ms->m_header.h_nodeid; 4008 - lkb->lkb_remid = ms->m_lkid; 3984 + lkb->lkb_nodeid = le32_to_cpu(ms->m_header.h_nodeid); 3985 + lkb->lkb_remid = le32_to_cpu(ms->m_lkid); 4009 3986 } 4010 3987 4011 3988 /* This is called after the rsb is locked so that we can safely inspect ··· 4013 3990 4014 3991 static int validate_message(struct dlm_lkb *lkb, struct dlm_message *ms) 4015 3992 { 4016 - int from = ms->m_header.h_nodeid; 3993 + int from = le32_to_cpu(ms->m_header.h_nodeid); 4017 3994 int error = 0; 4018 3995 4019 3996 /* currently mixing of user/kernel locks are not supported */ 4020 - if (ms->m_flags & DLM_IFL_USER && ~lkb->lkb_flags & DLM_IFL_USER) { 3997 + if (ms->m_flags & cpu_to_le32(DLM_IFL_USER) && 3998 + ~lkb->lkb_flags & DLM_IFL_USER) { 4021 3999 log_error(lkb->lkb_resource->res_ls, 4022 4000 "got user dlm message for a kernel lock"); 4023 4001 error = -EINVAL; ··· 4026 4002 } 4027 4003 4028 4004 switch (ms->m_type) { 4029 - case DLM_MSG_CONVERT: 4030 - case DLM_MSG_UNLOCK: 4031 - case DLM_MSG_CANCEL: 4005 + case cpu_to_le32(DLM_MSG_CONVERT): 4006 + case cpu_to_le32(DLM_MSG_UNLOCK): 4007 + case cpu_to_le32(DLM_MSG_CANCEL): 4032 4008 if (!is_master_copy(lkb) || lkb->lkb_nodeid != from) 4033 4009 error = -EINVAL; 4034 4010 break; 4035 4011 4036 - case DLM_MSG_CONVERT_REPLY: 4037 - case DLM_MSG_UNLOCK_REPLY: 4038 - case DLM_MSG_CANCEL_REPLY: 4039 - case DLM_MSG_GRANT: 4040 - case DLM_MSG_BAST: 4012 + case cpu_to_le32(DLM_MSG_CONVERT_REPLY): 4013 + case cpu_to_le32(DLM_MSG_UNLOCK_REPLY): 4014 + case cpu_to_le32(DLM_MSG_CANCEL_REPLY): 4015 + case cpu_to_le32(DLM_MSG_GRANT): 4016 + case cpu_to_le32(DLM_MSG_BAST): 4041 4017 if (!is_process_copy(lkb) || lkb->lkb_nodeid != from) 4042 4018 error = -EINVAL; 4043 4019 break; 4044 4020 4045 - case DLM_MSG_REQUEST_REPLY: 4021 + case cpu_to_le32(DLM_MSG_REQUEST_REPLY): 4046 4022 if (!is_process_copy(lkb)) 4047 4023 error = -EINVAL; 4048 4024 else if (lkb->lkb_nodeid != -1 && lkb->lkb_nodeid != from) ··· 4057 4033 if (error) 4058 4034 log_error(lkb->lkb_resource->res_ls, 4059 4035 "ignore invalid message %d from %d %x %x %x %d", 4060 - ms->m_type, from, lkb->lkb_id, lkb->lkb_remid, 4061 - lkb->lkb_flags, lkb->lkb_nodeid); 4036 + le32_to_cpu(ms->m_type), from, lkb->lkb_id, 4037 + lkb->lkb_remid, lkb->lkb_flags, lkb->lkb_nodeid); 4062 4038 return error; 4063 4039 } 4064 4040 ··· 4103 4079 memcpy(ls->ls_remove_name, name, DLM_RESNAME_MAXLEN); 4104 4080 spin_unlock(&ls->ls_remove_spin); 4105 4081 spin_unlock(&ls->ls_rsbtbl[b].lock); 4106 - wake_up(&ls->ls_remove_wait); 4107 4082 4108 4083 rv = _create_message(ls, sizeof(struct dlm_message) + len, 4109 4084 dir_nodeid, DLM_MSG_REMOVE, &ms, &mh); 4110 4085 if (rv) 4111 - return; 4086 + goto out; 4112 4087 4113 4088 memcpy(ms->m_extra, name, len); 4114 - ms->m_hash = hash; 4089 + ms->m_hash = cpu_to_le32(hash); 4115 4090 4116 4091 send_message(mh, ms); 4117 4092 4093 + out: 4118 4094 spin_lock(&ls->ls_remove_spin); 4119 4095 ls->ls_remove_len = 0; 4120 4096 memset(ls->ls_remove_name, 0, DLM_RESNAME_MAXLEN); 4121 4097 spin_unlock(&ls->ls_remove_spin); 4098 + wake_up(&ls->ls_remove_wait); 4122 4099 } 4123 4100 4124 4101 static int receive_request(struct dlm_ls *ls, struct dlm_message *ms) ··· 4129 4104 int from_nodeid; 4130 4105 int error, namelen = 0; 4131 4106 4132 - from_nodeid = ms->m_header.h_nodeid; 4107 + from_nodeid = le32_to_cpu(ms->m_header.h_nodeid); 4133 4108 4134 4109 error = create_lkb(ls, &lkb); 4135 4110 if (error) ··· 4202 4177 4203 4178 if (error != -ENOTBLK) { 4204 4179 log_limit(ls, "receive_request %x from %d %d", 4205 - ms->m_lkid, from_nodeid, error); 4180 + le32_to_cpu(ms->m_lkid), from_nodeid, error); 4206 4181 } 4207 4182 4208 4183 if (namelen && error == -EBADR) { ··· 4221 4196 struct dlm_rsb *r; 4222 4197 int error, reply = 1; 4223 4198 4224 - error = find_lkb(ls, ms->m_remid, &lkb); 4199 + error = find_lkb(ls, le32_to_cpu(ms->m_remid), &lkb); 4225 4200 if (error) 4226 4201 goto fail; 4227 4202 4228 - if (lkb->lkb_remid != ms->m_lkid) { 4203 + if (lkb->lkb_remid != le32_to_cpu(ms->m_lkid)) { 4229 4204 log_error(ls, "receive_convert %x remid %x recover_seq %llu " 4230 4205 "remote %d %x", lkb->lkb_id, lkb->lkb_remid, 4231 4206 (unsigned long long)lkb->lkb_recover_seq, 4232 - ms->m_header.h_nodeid, ms->m_lkid); 4207 + le32_to_cpu(ms->m_header.h_nodeid), 4208 + le32_to_cpu(ms->m_lkid)); 4233 4209 error = -ENOENT; 4234 4210 dlm_put_lkb(lkb); 4235 4211 goto fail; ··· 4277 4251 struct dlm_rsb *r; 4278 4252 int error; 4279 4253 4280 - error = find_lkb(ls, ms->m_remid, &lkb); 4254 + error = find_lkb(ls, le32_to_cpu(ms->m_remid), &lkb); 4281 4255 if (error) 4282 4256 goto fail; 4283 4257 4284 - if (lkb->lkb_remid != ms->m_lkid) { 4258 + if (lkb->lkb_remid != le32_to_cpu(ms->m_lkid)) { 4285 4259 log_error(ls, "receive_unlock %x remid %x remote %d %x", 4286 4260 lkb->lkb_id, lkb->lkb_remid, 4287 - ms->m_header.h_nodeid, ms->m_lkid); 4261 + le32_to_cpu(ms->m_header.h_nodeid), 4262 + le32_to_cpu(ms->m_lkid)); 4288 4263 error = -ENOENT; 4289 4264 dlm_put_lkb(lkb); 4290 4265 goto fail; ··· 4329 4302 struct dlm_rsb *r; 4330 4303 int error; 4331 4304 4332 - error = find_lkb(ls, ms->m_remid, &lkb); 4305 + error = find_lkb(ls, le32_to_cpu(ms->m_remid), &lkb); 4333 4306 if (error) 4334 4307 goto fail; 4335 4308 ··· 4365 4338 struct dlm_rsb *r; 4366 4339 int error; 4367 4340 4368 - error = find_lkb(ls, ms->m_remid, &lkb); 4341 + error = find_lkb(ls, le32_to_cpu(ms->m_remid), &lkb); 4369 4342 if (error) 4370 4343 return error; 4371 4344 ··· 4396 4369 struct dlm_rsb *r; 4397 4370 int error; 4398 4371 4399 - error = find_lkb(ls, ms->m_remid, &lkb); 4372 + error = find_lkb(ls, le32_to_cpu(ms->m_remid), &lkb); 4400 4373 if (error) 4401 4374 return error; 4402 4375 ··· 4409 4382 if (error) 4410 4383 goto out; 4411 4384 4412 - queue_bast(r, lkb, ms->m_bastmode); 4413 - lkb->lkb_highbast = ms->m_bastmode; 4385 + queue_bast(r, lkb, le32_to_cpu(ms->m_bastmode)); 4386 + lkb->lkb_highbast = le32_to_cpu(ms->m_bastmode); 4414 4387 out: 4415 4388 unlock_rsb(r); 4416 4389 put_rsb(r); ··· 4422 4395 { 4423 4396 int len, error, ret_nodeid, from_nodeid, our_nodeid; 4424 4397 4425 - from_nodeid = ms->m_header.h_nodeid; 4398 + from_nodeid = le32_to_cpu(ms->m_header.h_nodeid); 4426 4399 our_nodeid = dlm_our_nodeid(); 4427 4400 4428 4401 len = receive_extralen(ms); ··· 4445 4418 uint32_t hash, b; 4446 4419 int rv, len, dir_nodeid, from_nodeid; 4447 4420 4448 - from_nodeid = ms->m_header.h_nodeid; 4421 + from_nodeid = le32_to_cpu(ms->m_header.h_nodeid); 4449 4422 4450 4423 len = receive_extralen(ms); 4451 4424 ··· 4455 4428 return; 4456 4429 } 4457 4430 4458 - dir_nodeid = dlm_hash2nodeid(ls, ms->m_hash); 4431 + dir_nodeid = dlm_hash2nodeid(ls, le32_to_cpu(ms->m_hash)); 4459 4432 if (dir_nodeid != dlm_our_nodeid()) { 4460 4433 log_error(ls, "receive_remove from %d bad nodeid %d", 4461 4434 from_nodeid, dir_nodeid); ··· 4528 4501 4529 4502 static void receive_purge(struct dlm_ls *ls, struct dlm_message *ms) 4530 4503 { 4531 - do_purge(ls, ms->m_nodeid, ms->m_pid); 4504 + do_purge(ls, le32_to_cpu(ms->m_nodeid), le32_to_cpu(ms->m_pid)); 4532 4505 } 4533 4506 4534 4507 static int receive_request_reply(struct dlm_ls *ls, struct dlm_message *ms) ··· 4536 4509 struct dlm_lkb *lkb; 4537 4510 struct dlm_rsb *r; 4538 4511 int error, mstype, result; 4539 - int from_nodeid = ms->m_header.h_nodeid; 4512 + int from_nodeid = le32_to_cpu(ms->m_header.h_nodeid); 4540 4513 4541 - error = find_lkb(ls, ms->m_remid, &lkb); 4514 + error = find_lkb(ls, le32_to_cpu(ms->m_remid), &lkb); 4542 4515 if (error) 4543 4516 return error; 4544 4517 ··· 4554 4527 error = remove_from_waiters(lkb, DLM_MSG_REQUEST_REPLY); 4555 4528 if (error) { 4556 4529 log_error(ls, "receive_request_reply %x remote %d %x result %d", 4557 - lkb->lkb_id, from_nodeid, ms->m_lkid, ms->m_result); 4530 + lkb->lkb_id, from_nodeid, le32_to_cpu(ms->m_lkid), 4531 + from_dlm_errno(le32_to_cpu(ms->m_result))); 4558 4532 dlm_dump_rsb(r); 4559 4533 goto out; 4560 4534 } ··· 4569 4541 } 4570 4542 4571 4543 /* this is the value returned from do_request() on the master */ 4572 - result = ms->m_result; 4544 + result = from_dlm_errno(le32_to_cpu(ms->m_result)); 4573 4545 4574 4546 switch (result) { 4575 4547 case -EAGAIN: ··· 4583 4555 case 0: 4584 4556 /* request was queued or granted on remote master */ 4585 4557 receive_flags_reply(lkb, ms); 4586 - lkb->lkb_remid = ms->m_lkid; 4558 + lkb->lkb_remid = le32_to_cpu(ms->m_lkid); 4587 4559 if (is_altmode(lkb)) 4588 4560 munge_altmode(lkb, ms); 4589 4561 if (result) { ··· 4656 4628 struct dlm_message *ms) 4657 4629 { 4658 4630 /* this is the value returned from do_convert() on the master */ 4659 - switch (ms->m_result) { 4631 + switch (from_dlm_errno(le32_to_cpu(ms->m_result))) { 4660 4632 case -EAGAIN: 4661 4633 /* convert would block (be queued) on remote master */ 4662 4634 queue_cast(r, lkb, -EAGAIN); ··· 4689 4661 4690 4662 default: 4691 4663 log_error(r->res_ls, "receive_convert_reply %x remote %d %x %d", 4692 - lkb->lkb_id, ms->m_header.h_nodeid, ms->m_lkid, 4693 - ms->m_result); 4664 + lkb->lkb_id, le32_to_cpu(ms->m_header.h_nodeid), 4665 + le32_to_cpu(ms->m_lkid), 4666 + from_dlm_errno(le32_to_cpu(ms->m_result))); 4694 4667 dlm_print_rsb(r); 4695 4668 dlm_print_lkb(lkb); 4696 4669 } ··· 4725 4696 struct dlm_lkb *lkb; 4726 4697 int error; 4727 4698 4728 - error = find_lkb(ls, ms->m_remid, &lkb); 4699 + error = find_lkb(ls, le32_to_cpu(ms->m_remid), &lkb); 4729 4700 if (error) 4730 4701 return error; 4731 4702 ··· 4753 4724 4754 4725 /* this is the value returned from do_unlock() on the master */ 4755 4726 4756 - switch (ms->m_result) { 4727 + switch (from_dlm_errno(le32_to_cpu(ms->m_result))) { 4757 4728 case -DLM_EUNLOCK: 4758 4729 receive_flags_reply(lkb, ms); 4759 4730 remove_lock_pc(r, lkb); ··· 4763 4734 break; 4764 4735 default: 4765 4736 log_error(r->res_ls, "receive_unlock_reply %x error %d", 4766 - lkb->lkb_id, ms->m_result); 4737 + lkb->lkb_id, from_dlm_errno(le32_to_cpu(ms->m_result))); 4767 4738 } 4768 4739 out: 4769 4740 unlock_rsb(r); ··· 4775 4746 struct dlm_lkb *lkb; 4776 4747 int error; 4777 4748 4778 - error = find_lkb(ls, ms->m_remid, &lkb); 4749 + error = find_lkb(ls, le32_to_cpu(ms->m_remid), &lkb); 4779 4750 if (error) 4780 4751 return error; 4781 4752 ··· 4803 4774 4804 4775 /* this is the value returned from do_cancel() on the master */ 4805 4776 4806 - switch (ms->m_result) { 4777 + switch (from_dlm_errno(le32_to_cpu(ms->m_result))) { 4807 4778 case -DLM_ECANCEL: 4808 4779 receive_flags_reply(lkb, ms); 4809 4780 revert_lock_pc(r, lkb); ··· 4813 4784 break; 4814 4785 default: 4815 4786 log_error(r->res_ls, "receive_cancel_reply %x error %d", 4816 - lkb->lkb_id, ms->m_result); 4787 + lkb->lkb_id, 4788 + from_dlm_errno(le32_to_cpu(ms->m_result))); 4817 4789 } 4818 4790 out: 4819 4791 unlock_rsb(r); ··· 4826 4796 struct dlm_lkb *lkb; 4827 4797 int error; 4828 4798 4829 - error = find_lkb(ls, ms->m_remid, &lkb); 4799 + error = find_lkb(ls, le32_to_cpu(ms->m_remid), &lkb); 4830 4800 if (error) 4831 4801 return error; 4832 4802 ··· 4842 4812 int error, ret_nodeid; 4843 4813 int do_lookup_list = 0; 4844 4814 4845 - error = find_lkb(ls, ms->m_lkid, &lkb); 4815 + error = find_lkb(ls, le32_to_cpu(ms->m_lkid), &lkb); 4846 4816 if (error) { 4847 - log_error(ls, "receive_lookup_reply no lkid %x", ms->m_lkid); 4817 + log_error(ls, "%s no lkid %x", __func__, 4818 + le32_to_cpu(ms->m_lkid)); 4848 4819 return; 4849 4820 } 4850 4821 ··· 4860 4829 if (error) 4861 4830 goto out; 4862 4831 4863 - ret_nodeid = ms->m_nodeid; 4832 + ret_nodeid = le32_to_cpu(ms->m_nodeid); 4864 4833 4865 4834 /* We sometimes receive a request from the dir node for this 4866 4835 rsb before we've received the dir node's loookup_reply for it. ··· 4872 4841 /* This should never happen */ 4873 4842 log_error(ls, "receive_lookup_reply %x from %d ret %d " 4874 4843 "master %d dir %d our %d first %x %s", 4875 - lkb->lkb_id, ms->m_header.h_nodeid, ret_nodeid, 4876 - r->res_master_nodeid, r->res_dir_nodeid, 4844 + lkb->lkb_id, le32_to_cpu(ms->m_header.h_nodeid), 4845 + ret_nodeid, r->res_master_nodeid, r->res_dir_nodeid, 4877 4846 dlm_our_nodeid(), r->res_first_lkid, r->res_name); 4878 4847 } 4879 4848 ··· 4885 4854 } else if (ret_nodeid == -1) { 4886 4855 /* the remote node doesn't believe it's the dir node */ 4887 4856 log_error(ls, "receive_lookup_reply %x from %d bad ret_nodeid", 4888 - lkb->lkb_id, ms->m_header.h_nodeid); 4857 + lkb->lkb_id, le32_to_cpu(ms->m_header.h_nodeid)); 4889 4858 r->res_master_nodeid = 0; 4890 4859 r->res_nodeid = -1; 4891 4860 lkb->lkb_nodeid = -1; ··· 4919 4888 { 4920 4889 int error = 0, noent = 0; 4921 4890 4922 - if (!dlm_is_member(ls, ms->m_header.h_nodeid)) { 4891 + if (!dlm_is_member(ls, le32_to_cpu(ms->m_header.h_nodeid))) { 4923 4892 log_limit(ls, "receive %d from non-member %d %x %x %d", 4924 - ms->m_type, ms->m_header.h_nodeid, ms->m_lkid, 4925 - ms->m_remid, ms->m_result); 4893 + le32_to_cpu(ms->m_type), 4894 + le32_to_cpu(ms->m_header.h_nodeid), 4895 + le32_to_cpu(ms->m_lkid), le32_to_cpu(ms->m_remid), 4896 + from_dlm_errno(le32_to_cpu(ms->m_result))); 4926 4897 return; 4927 4898 } 4928 4899 ··· 4932 4899 4933 4900 /* messages sent to a master node */ 4934 4901 4935 - case DLM_MSG_REQUEST: 4902 + case cpu_to_le32(DLM_MSG_REQUEST): 4936 4903 error = receive_request(ls, ms); 4937 4904 break; 4938 4905 4939 - case DLM_MSG_CONVERT: 4906 + case cpu_to_le32(DLM_MSG_CONVERT): 4940 4907 error = receive_convert(ls, ms); 4941 4908 break; 4942 4909 4943 - case DLM_MSG_UNLOCK: 4910 + case cpu_to_le32(DLM_MSG_UNLOCK): 4944 4911 error = receive_unlock(ls, ms); 4945 4912 break; 4946 4913 4947 - case DLM_MSG_CANCEL: 4914 + case cpu_to_le32(DLM_MSG_CANCEL): 4948 4915 noent = 1; 4949 4916 error = receive_cancel(ls, ms); 4950 4917 break; 4951 4918 4952 4919 /* messages sent from a master node (replies to above) */ 4953 4920 4954 - case DLM_MSG_REQUEST_REPLY: 4921 + case cpu_to_le32(DLM_MSG_REQUEST_REPLY): 4955 4922 error = receive_request_reply(ls, ms); 4956 4923 break; 4957 4924 4958 - case DLM_MSG_CONVERT_REPLY: 4925 + case cpu_to_le32(DLM_MSG_CONVERT_REPLY): 4959 4926 error = receive_convert_reply(ls, ms); 4960 4927 break; 4961 4928 4962 - case DLM_MSG_UNLOCK_REPLY: 4929 + case cpu_to_le32(DLM_MSG_UNLOCK_REPLY): 4963 4930 error = receive_unlock_reply(ls, ms); 4964 4931 break; 4965 4932 4966 - case DLM_MSG_CANCEL_REPLY: 4933 + case cpu_to_le32(DLM_MSG_CANCEL_REPLY): 4967 4934 error = receive_cancel_reply(ls, ms); 4968 4935 break; 4969 4936 4970 4937 /* messages sent from a master node (only two types of async msg) */ 4971 4938 4972 - case DLM_MSG_GRANT: 4939 + case cpu_to_le32(DLM_MSG_GRANT): 4973 4940 noent = 1; 4974 4941 error = receive_grant(ls, ms); 4975 4942 break; 4976 4943 4977 - case DLM_MSG_BAST: 4944 + case cpu_to_le32(DLM_MSG_BAST): 4978 4945 noent = 1; 4979 4946 error = receive_bast(ls, ms); 4980 4947 break; 4981 4948 4982 4949 /* messages sent to a dir node */ 4983 4950 4984 - case DLM_MSG_LOOKUP: 4951 + case cpu_to_le32(DLM_MSG_LOOKUP): 4985 4952 receive_lookup(ls, ms); 4986 4953 break; 4987 4954 4988 - case DLM_MSG_REMOVE: 4955 + case cpu_to_le32(DLM_MSG_REMOVE): 4989 4956 receive_remove(ls, ms); 4990 4957 break; 4991 4958 4992 4959 /* messages sent from a dir node (remove has no reply) */ 4993 4960 4994 - case DLM_MSG_LOOKUP_REPLY: 4961 + case cpu_to_le32(DLM_MSG_LOOKUP_REPLY): 4995 4962 receive_lookup_reply(ls, ms); 4996 4963 break; 4997 4964 4998 4965 /* other messages */ 4999 4966 5000 - case DLM_MSG_PURGE: 4967 + case cpu_to_le32(DLM_MSG_PURGE): 5001 4968 receive_purge(ls, ms); 5002 4969 break; 5003 4970 5004 4971 default: 5005 - log_error(ls, "unknown message type %d", ms->m_type); 4972 + log_error(ls, "unknown message type %d", 4973 + le32_to_cpu(ms->m_type)); 5006 4974 } 5007 4975 5008 4976 /* ··· 5019 4985 5020 4986 if (error == -ENOENT && noent) { 5021 4987 log_debug(ls, "receive %d no %x remote %d %x saved_seq %u", 5022 - ms->m_type, ms->m_remid, ms->m_header.h_nodeid, 5023 - ms->m_lkid, saved_seq); 4988 + le32_to_cpu(ms->m_type), le32_to_cpu(ms->m_remid), 4989 + le32_to_cpu(ms->m_header.h_nodeid), 4990 + le32_to_cpu(ms->m_lkid), saved_seq); 5024 4991 } else if (error == -ENOENT) { 5025 4992 log_error(ls, "receive %d no %x remote %d %x saved_seq %u", 5026 - ms->m_type, ms->m_remid, ms->m_header.h_nodeid, 5027 - ms->m_lkid, saved_seq); 4993 + le32_to_cpu(ms->m_type), le32_to_cpu(ms->m_remid), 4994 + le32_to_cpu(ms->m_header.h_nodeid), 4995 + le32_to_cpu(ms->m_lkid), saved_seq); 5028 4996 5029 - if (ms->m_type == DLM_MSG_CONVERT) 5030 - dlm_dump_rsb_hash(ls, ms->m_hash); 4997 + if (ms->m_type == cpu_to_le32(DLM_MSG_CONVERT)) 4998 + dlm_dump_rsb_hash(ls, le32_to_cpu(ms->m_hash)); 5031 4999 } 5032 5000 5033 5001 if (error == -EINVAL) { 5034 5002 log_error(ls, "receive %d inval from %d lkid %x remid %x " 5035 5003 "saved_seq %u", 5036 - ms->m_type, ms->m_header.h_nodeid, 5037 - ms->m_lkid, ms->m_remid, saved_seq); 5004 + le32_to_cpu(ms->m_type), 5005 + le32_to_cpu(ms->m_header.h_nodeid), 5006 + le32_to_cpu(ms->m_lkid), le32_to_cpu(ms->m_remid), 5007 + saved_seq); 5038 5008 } 5039 5009 } 5040 5010 ··· 5059 5021 lockspace generation before we left. */ 5060 5022 if (!ls->ls_generation) { 5061 5023 log_limit(ls, "receive %d from %d ignore old gen", 5062 - ms->m_type, nodeid); 5024 + le32_to_cpu(ms->m_type), nodeid); 5063 5025 return; 5064 5026 } 5065 5027 ··· 5092 5054 5093 5055 switch (hd->h_cmd) { 5094 5056 case DLM_MSG: 5095 - dlm_message_in(&p->message); 5096 - type = p->message.m_type; 5057 + type = le32_to_cpu(p->message.m_type); 5097 5058 break; 5098 5059 case DLM_RCOM: 5099 - dlm_rcom_in(&p->rcom); 5100 - type = p->rcom.rc_type; 5060 + type = le32_to_cpu(p->rcom.rc_type); 5101 5061 break; 5102 5062 default: 5103 5063 log_print("invalid h_cmd %d from %u", hd->h_cmd, nodeid); 5104 5064 return; 5105 5065 } 5106 5066 5107 - if (hd->h_nodeid != nodeid) { 5067 + if (le32_to_cpu(hd->h_nodeid) != nodeid) { 5108 5068 log_print("invalid h_nodeid %d from %d lockspace %x", 5109 - hd->h_nodeid, nodeid, hd->u.h_lockspace); 5069 + le32_to_cpu(hd->h_nodeid), nodeid, 5070 + le32_to_cpu(hd->u.h_lockspace)); 5110 5071 return; 5111 5072 } 5112 5073 5113 - ls = dlm_find_lockspace_global(hd->u.h_lockspace); 5074 + ls = dlm_find_lockspace_global(le32_to_cpu(hd->u.h_lockspace)); 5114 5075 if (!ls) { 5115 5076 if (dlm_config.ci_log_debug) { 5116 5077 printk_ratelimited(KERN_DEBUG "dlm: invalid lockspace " 5117 5078 "%u from %d cmd %d type %d\n", 5118 - hd->u.h_lockspace, nodeid, hd->h_cmd, type); 5079 + le32_to_cpu(hd->u.h_lockspace), nodeid, 5080 + hd->h_cmd, type); 5119 5081 } 5120 5082 5121 5083 if (hd->h_cmd == DLM_RCOM && type == DLM_RCOM_STATUS) ··· 5142 5104 if (middle_conversion(lkb)) { 5143 5105 hold_lkb(lkb); 5144 5106 memset(ms_stub, 0, sizeof(struct dlm_message)); 5145 - ms_stub->m_flags = DLM_IFL_STUB_MS; 5146 - ms_stub->m_type = DLM_MSG_CONVERT_REPLY; 5147 - ms_stub->m_result = -EINPROGRESS; 5148 - ms_stub->m_header.h_nodeid = lkb->lkb_nodeid; 5107 + ms_stub->m_flags = cpu_to_le32(DLM_IFL_STUB_MS); 5108 + ms_stub->m_type = cpu_to_le32(DLM_MSG_CONVERT_REPLY); 5109 + ms_stub->m_result = cpu_to_le32(to_dlm_errno(-EINPROGRESS)); 5110 + ms_stub->m_header.h_nodeid = cpu_to_le32(lkb->lkb_nodeid); 5149 5111 _receive_convert_reply(lkb, ms_stub); 5150 5112 5151 5113 /* Same special case as in receive_rcom_lock_args() */ ··· 5264 5226 case DLM_MSG_UNLOCK: 5265 5227 hold_lkb(lkb); 5266 5228 memset(ms_stub, 0, sizeof(struct dlm_message)); 5267 - ms_stub->m_flags = DLM_IFL_STUB_MS; 5268 - ms_stub->m_type = DLM_MSG_UNLOCK_REPLY; 5269 - ms_stub->m_result = stub_unlock_result; 5270 - ms_stub->m_header.h_nodeid = lkb->lkb_nodeid; 5229 + ms_stub->m_flags = cpu_to_le32(DLM_IFL_STUB_MS); 5230 + ms_stub->m_type = cpu_to_le32(DLM_MSG_UNLOCK_REPLY); 5231 + ms_stub->m_result = cpu_to_le32(to_dlm_errno(stub_unlock_result)); 5232 + ms_stub->m_header.h_nodeid = cpu_to_le32(lkb->lkb_nodeid); 5271 5233 _receive_unlock_reply(lkb, ms_stub); 5272 5234 dlm_put_lkb(lkb); 5273 5235 break; ··· 5275 5237 case DLM_MSG_CANCEL: 5276 5238 hold_lkb(lkb); 5277 5239 memset(ms_stub, 0, sizeof(struct dlm_message)); 5278 - ms_stub->m_flags = DLM_IFL_STUB_MS; 5279 - ms_stub->m_type = DLM_MSG_CANCEL_REPLY; 5280 - ms_stub->m_result = stub_cancel_result; 5281 - ms_stub->m_header.h_nodeid = lkb->lkb_nodeid; 5240 + ms_stub->m_flags = cpu_to_le32(DLM_IFL_STUB_MS); 5241 + ms_stub->m_type = cpu_to_le32(DLM_MSG_CANCEL_REPLY); 5242 + ms_stub->m_result = cpu_to_le32(to_dlm_errno(stub_cancel_result)); 5243 + ms_stub->m_header.h_nodeid = cpu_to_le32(lkb->lkb_nodeid); 5282 5244 _receive_cancel_reply(lkb, ms_stub); 5283 5245 dlm_put_lkb(lkb); 5284 5246 break; ··· 5295 5257 5296 5258 static struct dlm_lkb *find_resend_waiter(struct dlm_ls *ls) 5297 5259 { 5298 - struct dlm_lkb *lkb; 5299 - int found = 0; 5260 + struct dlm_lkb *lkb = NULL, *iter; 5300 5261 5301 5262 mutex_lock(&ls->ls_waiters_mutex); 5302 - list_for_each_entry(lkb, &ls->ls_waiters, lkb_wait_reply) { 5303 - if (lkb->lkb_flags & DLM_IFL_RESEND) { 5304 - hold_lkb(lkb); 5305 - found = 1; 5263 + list_for_each_entry(iter, &ls->ls_waiters, lkb_wait_reply) { 5264 + if (iter->lkb_flags & DLM_IFL_RESEND) { 5265 + hold_lkb(iter); 5266 + lkb = iter; 5306 5267 break; 5307 5268 } 5308 5269 } 5309 5270 mutex_unlock(&ls->ls_waiters_mutex); 5310 5271 5311 - if (!found) 5312 - lkb = NULL; 5313 5272 return lkb; 5314 5273 } 5315 5274 ··· 5366 5331 lkb->lkb_flags &= ~DLM_IFL_OVERLAP_UNLOCK; 5367 5332 lkb->lkb_flags &= ~DLM_IFL_OVERLAP_CANCEL; 5368 5333 lkb->lkb_wait_type = 0; 5369 - lkb->lkb_wait_count = 0; 5334 + /* drop all wait_count references we still 5335 + * hold a reference for this iteration. 5336 + */ 5337 + while (lkb->lkb_wait_count) { 5338 + lkb->lkb_wait_count--; 5339 + unhold_lkb(lkb); 5340 + } 5370 5341 mutex_lock(&ls->ls_waiters_mutex); 5371 5342 list_del_init(&lkb->lkb_wait_reply); 5372 5343 mutex_unlock(&ls->ls_waiters_mutex); 5373 - unhold_lkb(lkb); /* for waiters list */ 5374 5344 5375 5345 if (oc || ou) { 5376 5346 /* do an unlock or cancel instead of resending */ ··· 5645 5605 { 5646 5606 struct rcom_lock *rl = (struct rcom_lock *) rc->rc_buf; 5647 5607 5648 - lkb->lkb_nodeid = rc->rc_header.h_nodeid; 5608 + lkb->lkb_nodeid = le32_to_cpu(rc->rc_header.h_nodeid); 5649 5609 lkb->lkb_ownpid = le32_to_cpu(rl->rl_ownpid); 5650 5610 lkb->lkb_remid = le32_to_cpu(rl->rl_lkid); 5651 5611 lkb->lkb_exflags = le32_to_cpu(rl->rl_exflags); ··· 5660 5620 lkb->lkb_astfn = (rl->rl_asts & DLM_CB_CAST) ? &fake_astfn : NULL; 5661 5621 5662 5622 if (lkb->lkb_exflags & DLM_LKF_VALBLK) { 5663 - int lvblen = rc->rc_header.h_length - sizeof(struct dlm_rcom) - 5664 - sizeof(struct rcom_lock); 5623 + int lvblen = le16_to_cpu(rc->rc_header.h_length) - 5624 + sizeof(struct dlm_rcom) - sizeof(struct rcom_lock); 5665 5625 if (lvblen > ls->ls_lvblen) 5666 5626 return -EINVAL; 5667 5627 lkb->lkb_lvbptr = dlm_allocate_lvb(ls); ··· 5697 5657 struct dlm_rsb *r; 5698 5658 struct dlm_lkb *lkb; 5699 5659 uint32_t remid = 0; 5700 - int from_nodeid = rc->rc_header.h_nodeid; 5660 + int from_nodeid = le32_to_cpu(rc->rc_header.h_nodeid); 5701 5661 int error; 5702 5662 5703 5663 if (rl->rl_parent_lkid) { ··· 5747 5707 5748 5708 attach_lkb(r, lkb); 5749 5709 add_lkb(r, lkb, rl->rl_status); 5750 - error = 0; 5751 5710 ls->ls_recover_locks_in++; 5752 5711 5753 5712 if (!list_empty(&r->res_waitqueue) || !list_empty(&r->res_convertqueue)) ··· 5786 5747 error = find_lkb(ls, lkid, &lkb); 5787 5748 if (error) { 5788 5749 log_error(ls, "dlm_recover_process_copy no %x remote %d %x %d", 5789 - lkid, rc->rc_header.h_nodeid, remid, result); 5750 + lkid, le32_to_cpu(rc->rc_header.h_nodeid), remid, 5751 + result); 5790 5752 return error; 5791 5753 } 5792 5754 ··· 5797 5757 5798 5758 if (!is_process_copy(lkb)) { 5799 5759 log_error(ls, "dlm_recover_process_copy bad %x remote %d %x %d", 5800 - lkid, rc->rc_header.h_nodeid, remid, result); 5760 + lkid, le32_to_cpu(rc->rc_header.h_nodeid), remid, 5761 + result); 5801 5762 dlm_dump_rsb(r); 5802 5763 unlock_rsb(r); 5803 5764 put_rsb(r); ··· 5813 5772 a barrier between recover_masters and recover_locks. */ 5814 5773 5815 5774 log_debug(ls, "dlm_recover_process_copy %x remote %d %x %d", 5816 - lkid, rc->rc_header.h_nodeid, remid, result); 5775 + lkid, le32_to_cpu(rc->rc_header.h_nodeid), remid, 5776 + result); 5817 5777 5818 5778 dlm_send_rcom_lock(r, lkb); 5819 5779 goto out; ··· 5824 5782 break; 5825 5783 default: 5826 5784 log_error(ls, "dlm_recover_process_copy %x remote %d %x %d unk", 5827 - lkid, rc->rc_header.h_nodeid, remid, result); 5785 + lkid, le32_to_cpu(rc->rc_header.h_nodeid), remid, 5786 + result); 5828 5787 } 5829 5788 5830 5789 /* an ack for dlm_recover_locks() which waits for replies from ··· 5968 5925 int mode, uint32_t flags, void *name, unsigned int namelen, 5969 5926 unsigned long timeout_cs, uint32_t *lkid) 5970 5927 { 5971 - struct dlm_lkb *lkb; 5928 + struct dlm_lkb *lkb = NULL, *iter; 5972 5929 struct dlm_user_args *ua; 5973 5930 int found_other_mode = 0; 5974 - int found = 0; 5975 5931 int rv = 0; 5976 5932 5977 5933 mutex_lock(&ls->ls_orphans_mutex); 5978 - list_for_each_entry(lkb, &ls->ls_orphans, lkb_ownqueue) { 5979 - if (lkb->lkb_resource->res_length != namelen) 5934 + list_for_each_entry(iter, &ls->ls_orphans, lkb_ownqueue) { 5935 + if (iter->lkb_resource->res_length != namelen) 5980 5936 continue; 5981 - if (memcmp(lkb->lkb_resource->res_name, name, namelen)) 5937 + if (memcmp(iter->lkb_resource->res_name, name, namelen)) 5982 5938 continue; 5983 - if (lkb->lkb_grmode != mode) { 5939 + if (iter->lkb_grmode != mode) { 5984 5940 found_other_mode = 1; 5985 5941 continue; 5986 5942 } 5987 5943 5988 - found = 1; 5989 - list_del_init(&lkb->lkb_ownqueue); 5990 - lkb->lkb_flags &= ~DLM_IFL_ORPHAN; 5991 - *lkid = lkb->lkb_id; 5944 + lkb = iter; 5945 + list_del_init(&iter->lkb_ownqueue); 5946 + iter->lkb_flags &= ~DLM_IFL_ORPHAN; 5947 + *lkid = iter->lkb_id; 5992 5948 break; 5993 5949 } 5994 5950 mutex_unlock(&ls->ls_orphans_mutex); 5995 5951 5996 - if (!found && found_other_mode) { 5952 + if (!lkb && found_other_mode) { 5997 5953 rv = -EAGAIN; 5998 5954 goto out; 5999 5955 } 6000 5956 6001 - if (!found) { 5957 + if (!lkb) { 6002 5958 rv = -ENOENT; 6003 5959 goto out; 6004 5960 } ··· 6349 6307 DLM_MSG_PURGE, &ms, &mh); 6350 6308 if (error) 6351 6309 return error; 6352 - ms->m_nodeid = nodeid; 6353 - ms->m_pid = pid; 6310 + ms->m_nodeid = cpu_to_le32(nodeid); 6311 + ms->m_pid = cpu_to_le32(pid); 6354 6312 6355 6313 return send_message(mh, ms); 6356 6314 }
+12
fs/dlm/lockspace.c
··· 922 922 log_print("dlm user daemon left %d lockspaces", count); 923 923 } 924 924 925 + void dlm_stop_lockspaces_check(void) 926 + { 927 + struct dlm_ls *ls; 928 + 929 + spin_lock(&lslist_lock); 930 + list_for_each_entry(ls, &lslist, ls_list) { 931 + if (WARN_ON(!rwsem_is_locked(&ls->ls_in_recovery) || 932 + !dlm_locking_stopped(ls))) 933 + break; 934 + } 935 + spin_unlock(&lslist_lock); 936 + }
+1
fs/dlm/lockspace.h
··· 19 19 struct dlm_ls *dlm_find_lockspace_device(int minor); 20 20 void dlm_put_lockspace(struct dlm_ls *ls); 21 21 void dlm_stop_lockspaces(void); 22 + void dlm_stop_lockspaces_check(void); 22 23 23 24 #endif /* __LOCKSPACE_DOT_H__ */ 24 25
+11 -1
fs/dlm/lowcomms.c
··· 1303 1303 return msg; 1304 1304 } 1305 1305 1306 + /* avoid false positive for nodes_srcu, unlock happens in 1307 + * dlm_lowcomms_commit_msg which is a must call if success 1308 + */ 1309 + #ifndef __CHECKER__ 1306 1310 struct dlm_msg *dlm_lowcomms_new_msg(int nodeid, int len, gfp_t allocation, 1307 1311 char **ppc, void (*cb)(void *data), 1308 1312 void *data) ··· 1340 1336 msg->idx = idx; 1341 1337 return msg; 1342 1338 } 1339 + #endif 1343 1340 1344 1341 static void _dlm_lowcomms_commit_msg(struct dlm_msg *msg) 1345 1342 { ··· 1367 1362 return; 1368 1363 } 1369 1364 1365 + /* avoid false positive for nodes_srcu, lock was happen in 1366 + * dlm_lowcomms_new_msg 1367 + */ 1368 + #ifndef __CHECKER__ 1370 1369 void dlm_lowcomms_commit_msg(struct dlm_msg *msg) 1371 1370 { 1372 1371 _dlm_lowcomms_commit_msg(msg); 1373 1372 srcu_read_unlock(&connections_srcu, msg->idx); 1374 1373 } 1374 + #endif 1375 1375 1376 1376 void dlm_lowcomms_put_msg(struct dlm_msg *msg) 1377 1377 { ··· 1799 1789 SOCK_STREAM, dlm_proto_ops->proto, &sock); 1800 1790 if (result < 0) { 1801 1791 log_print("Can't create comms socket: %d", result); 1802 - goto out; 1792 + return result; 1803 1793 } 1804 1794 1805 1795 sock_set_mark(sock->sk, dlm_config.ci_mark);
+3 -8
fs/dlm/member.c
··· 20 20 21 21 int dlm_slots_version(struct dlm_header *h) 22 22 { 23 - if ((h->h_version & 0x0000FFFF) < DLM_HEADER_SLOTS) 23 + if ((le32_to_cpu(h->h_version) & 0x0000FFFF) < DLM_HEADER_SLOTS) 24 24 return 0; 25 25 return 1; 26 26 } ··· 120 120 121 121 ro0 = (struct rcom_slot *)(rc->rc_buf + sizeof(struct rcom_config)); 122 122 123 - for (i = 0, ro = ro0; i < num_slots; i++, ro++) { 124 - ro->ro_nodeid = le32_to_cpu(ro->ro_nodeid); 125 - ro->ro_slot = le16_to_cpu(ro->ro_slot); 126 - } 127 - 128 123 log_slots(ls, gen, num_slots, ro0, NULL, 0); 129 124 130 125 list_for_each_entry(memb, &ls->ls_nodes, list) { 131 126 for (i = 0, ro = ro0; i < num_slots; i++, ro++) { 132 - if (ro->ro_nodeid != memb->nodeid) 127 + if (le32_to_cpu(ro->ro_nodeid) != memb->nodeid) 133 128 continue; 134 - memb->slot = ro->ro_slot; 129 + memb->slot = le16_to_cpu(ro->ro_slot); 135 130 memb->slot_prev = memb->slot; 136 131 break; 137 132 }
+35 -26
fs/dlm/midcomms.c
··· 135 135 #include <net/tcp.h> 136 136 137 137 #include "dlm_internal.h" 138 + #include "lockspace.h" 138 139 #include "lowcomms.h" 139 140 #include "config.h" 140 141 #include "memory.h" ··· 381 380 382 381 m_header = (struct dlm_header *)ppc; 383 382 384 - m_header->h_version = (DLM_HEADER_MAJOR | DLM_HEADER_MINOR); 385 - m_header->h_nodeid = dlm_our_nodeid(); 386 - m_header->h_length = mb_len; 383 + m_header->h_version = cpu_to_le32(DLM_HEADER_MAJOR | DLM_HEADER_MINOR); 384 + m_header->h_nodeid = cpu_to_le32(dlm_our_nodeid()); 385 + m_header->h_length = cpu_to_le16(mb_len); 387 386 m_header->h_cmd = DLM_ACK; 388 - m_header->u.h_seq = seq; 387 + m_header->u.h_seq = cpu_to_le32(seq); 389 388 390 - header_out(m_header); 391 389 dlm_lowcomms_commit_msg(msg); 392 390 dlm_lowcomms_put_msg(msg); 393 391 ··· 409 409 410 410 m_header = (struct dlm_header *)ppc; 411 411 412 - m_header->h_version = (DLM_HEADER_MAJOR | DLM_HEADER_MINOR); 413 - m_header->h_nodeid = dlm_our_nodeid(); 414 - m_header->h_length = mb_len; 412 + m_header->h_version = cpu_to_le32(DLM_HEADER_MAJOR | DLM_HEADER_MINOR); 413 + m_header->h_nodeid = cpu_to_le32(dlm_our_nodeid()); 414 + m_header->h_length = cpu_to_le16(mb_len); 415 415 m_header->h_cmd = DLM_FIN; 416 - 417 - header_out(m_header); 418 416 419 417 pr_debug("sending fin msg to node %d\n", node->nodeid); 420 418 dlm_midcomms_commit_mhandle(mh); ··· 572 574 return NULL; 573 575 } 574 576 575 - switch (le32_to_cpu(p->rcom.rc_type)) { 576 - case DLM_RCOM_NAMES: 577 + switch (p->rcom.rc_type) { 578 + case cpu_to_le32(DLM_RCOM_NAMES): 577 579 fallthrough; 578 - case DLM_RCOM_NAMES_REPLY: 580 + case cpu_to_le32(DLM_RCOM_NAMES_REPLY): 579 581 fallthrough; 580 - case DLM_RCOM_STATUS: 582 + case cpu_to_le32(DLM_RCOM_STATUS): 581 583 fallthrough; 582 - case DLM_RCOM_STATUS_REPLY: 584 + case cpu_to_le32(DLM_RCOM_STATUS_REPLY): 583 585 node = nodeid2node(nodeid, 0); 584 586 if (node) { 585 587 spin_lock(&node->state_lock); ··· 739 741 * 740 742 * length already checked. 741 743 */ 742 - switch (le32_to_cpu(p->rcom.rc_type)) { 743 - case DLM_RCOM_NAMES: 744 + switch (p->rcom.rc_type) { 745 + case cpu_to_le32(DLM_RCOM_NAMES): 744 746 fallthrough; 745 - case DLM_RCOM_NAMES_REPLY: 747 + case cpu_to_le32(DLM_RCOM_NAMES_REPLY): 746 748 fallthrough; 747 - case DLM_RCOM_STATUS: 749 + case cpu_to_le32(DLM_RCOM_STATUS): 748 750 fallthrough; 749 - case DLM_RCOM_STATUS_REPLY: 751 + case cpu_to_le32(DLM_RCOM_STATUS_REPLY): 750 752 break; 751 753 default: 752 754 log_print("unsupported rcom type received: %u, will skip this message from node %d", ··· 1018 1020 uint32_t seq) 1019 1021 { 1020 1022 opts->o_header.h_cmd = DLM_OPTS; 1021 - opts->o_header.h_version = (DLM_HEADER_MAJOR | DLM_HEADER_MINOR); 1022 - opts->o_header.h_nodeid = dlm_our_nodeid(); 1023 - opts->o_header.h_length = DLM_MIDCOMMS_OPT_LEN + inner_len; 1024 - opts->o_header.u.h_seq = seq; 1025 - header_out(&opts->o_header); 1023 + opts->o_header.h_version = cpu_to_le32(DLM_HEADER_MAJOR | DLM_HEADER_MINOR); 1024 + opts->o_header.h_nodeid = cpu_to_le32(dlm_our_nodeid()); 1025 + opts->o_header.h_length = cpu_to_le16(DLM_MIDCOMMS_OPT_LEN + inner_len); 1026 + opts->o_header.u.h_seq = cpu_to_le32(seq); 1026 1027 } 1027 1028 1028 1029 static void midcomms_new_msg_cb(void *data) ··· 1059 1062 return msg; 1060 1063 } 1061 1064 1065 + /* avoid false positive for nodes_srcu, unlock happens in 1066 + * dlm_midcomms_commit_mhandle which is a must call if success 1067 + */ 1068 + #ifndef __CHECKER__ 1062 1069 struct dlm_mhandle *dlm_midcomms_get_mhandle(int nodeid, int len, 1063 1070 gfp_t allocation, char **ppc) 1064 1071 { ··· 1128 1127 srcu_read_unlock(&nodes_srcu, idx); 1129 1128 return NULL; 1130 1129 } 1130 + #endif 1131 1131 1132 1132 static void dlm_midcomms_commit_msg_3_2(struct dlm_mhandle *mh) 1133 1133 { ··· 1138 1136 dlm_lowcomms_commit_msg(mh->msg); 1139 1137 } 1140 1138 1139 + /* avoid false positive for nodes_srcu, lock was happen in 1140 + * dlm_midcomms_get_mhandle 1141 + */ 1142 + #ifndef __CHECKER__ 1141 1143 void dlm_midcomms_commit_mhandle(struct dlm_mhandle *mh) 1142 1144 { 1143 1145 switch (mh->node->version) { ··· 1163 1157 break; 1164 1158 } 1165 1159 } 1160 + #endif 1166 1161 1167 1162 int dlm_midcomms_start(void) 1168 1163 { ··· 1413 1406 if (nodeid == dlm_our_nodeid()) 1414 1407 return 0; 1415 1408 1409 + dlm_stop_lockspaces_check(); 1410 + 1416 1411 idx = srcu_read_lock(&nodes_srcu); 1417 1412 /* Abort pending close/remove operation */ 1418 1413 node = nodeid2node(nodeid, 0); ··· 1464 1455 switch (h->h_cmd) { 1465 1456 case DLM_OPTS: 1466 1457 if (!h->u.h_seq) 1467 - h->u.h_seq = rd->node->seq_send++; 1458 + h->u.h_seq = cpu_to_le32(rd->node->seq_send++); 1468 1459 break; 1469 1460 default: 1470 1461 break;
+80 -98
fs/dlm/plock.c
··· 13 13 #include "dlm_internal.h" 14 14 #include "lockspace.h" 15 15 16 - static spinlock_t ops_lock; 17 - static struct list_head send_list; 18 - static struct list_head recv_list; 19 - static wait_queue_head_t send_wq; 20 - static wait_queue_head_t recv_wq; 16 + static DEFINE_SPINLOCK(ops_lock); 17 + static LIST_HEAD(send_list); 18 + static LIST_HEAD(recv_list); 19 + static DECLARE_WAIT_QUEUE_HEAD(send_wq); 20 + static DECLARE_WAIT_QUEUE_HEAD(recv_wq); 21 + 22 + struct plock_async_data { 23 + void *fl; 24 + void *file; 25 + struct file_lock flc; 26 + int (*callback)(struct file_lock *fl, int result); 27 + }; 21 28 22 29 struct plock_op { 23 30 struct list_head list; 24 31 int done; 25 32 struct dlm_plock_info info; 33 + /* if set indicates async handling */ 34 + struct plock_async_data *data; 26 35 }; 27 - 28 - struct plock_xop { 29 - struct plock_op xop; 30 - int (*callback)(struct file_lock *fl, int result); 31 - void *fl; 32 - void *file; 33 - struct file_lock flc; 34 - }; 35 - 36 36 37 37 static inline void set_version(struct dlm_plock_info *info) 38 38 { ··· 58 58 return 0; 59 59 } 60 60 61 + static void dlm_release_plock_op(struct plock_op *op) 62 + { 63 + kfree(op->data); 64 + kfree(op); 65 + } 66 + 61 67 static void send_op(struct plock_op *op) 62 68 { 63 69 set_version(&op->info); 64 - INIT_LIST_HEAD(&op->list); 65 70 spin_lock(&ops_lock); 66 71 list_add_tail(&op->list, &send_list); 67 72 spin_unlock(&ops_lock); ··· 106 101 int dlm_posix_lock(dlm_lockspace_t *lockspace, u64 number, struct file *file, 107 102 int cmd, struct file_lock *fl) 108 103 { 104 + struct plock_async_data *op_data; 109 105 struct dlm_ls *ls; 110 106 struct plock_op *op; 111 - struct plock_xop *xop; 112 107 int rv; 113 108 114 109 ls = dlm_find_lockspace_local(lockspace); 115 110 if (!ls) 116 111 return -EINVAL; 117 112 118 - xop = kzalloc(sizeof(*xop), GFP_NOFS); 119 - if (!xop) { 113 + op = kzalloc(sizeof(*op), GFP_NOFS); 114 + if (!op) { 120 115 rv = -ENOMEM; 121 116 goto out; 122 117 } 123 118 124 - op = &xop->xop; 125 119 op->info.optype = DLM_PLOCK_OP_LOCK; 126 120 op->info.pid = fl->fl_pid; 127 121 op->info.ex = (fl->fl_type == F_WRLCK); ··· 129 125 op->info.number = number; 130 126 op->info.start = fl->fl_start; 131 127 op->info.end = fl->fl_end; 128 + /* async handling */ 132 129 if (fl->fl_lmops && fl->fl_lmops->lm_grant) { 130 + op_data = kzalloc(sizeof(*op_data), GFP_NOFS); 131 + if (!op_data) { 132 + dlm_release_plock_op(op); 133 + rv = -ENOMEM; 134 + goto out; 135 + } 136 + 133 137 /* fl_owner is lockd which doesn't distinguish 134 138 processes on the nfs client */ 135 139 op->info.owner = (__u64) fl->fl_pid; 136 - xop->callback = fl->fl_lmops->lm_grant; 137 - locks_init_lock(&xop->flc); 138 - locks_copy_lock(&xop->flc, fl); 139 - xop->fl = fl; 140 - xop->file = file; 140 + op_data->callback = fl->fl_lmops->lm_grant; 141 + locks_init_lock(&op_data->flc); 142 + locks_copy_lock(&op_data->flc, fl); 143 + op_data->fl = fl; 144 + op_data->file = file; 145 + 146 + op->data = op_data; 147 + 148 + send_op(op); 149 + rv = FILE_LOCK_DEFERRED; 150 + goto out; 141 151 } else { 142 152 op->info.owner = (__u64)(long) fl->fl_owner; 143 - xop->callback = NULL; 144 153 } 145 154 146 155 send_op(op); 147 156 148 - if (xop->callback == NULL) { 149 - rv = wait_event_interruptible(recv_wq, (op->done != 0)); 150 - if (rv == -ERESTARTSYS) { 151 - log_debug(ls, "dlm_posix_lock: wait killed %llx", 152 - (unsigned long long)number); 153 - spin_lock(&ops_lock); 154 - list_del(&op->list); 155 - spin_unlock(&ops_lock); 156 - kfree(xop); 157 - do_unlock_close(ls, number, file, fl); 158 - goto out; 159 - } 160 - } else { 161 - rv = FILE_LOCK_DEFERRED; 157 + rv = wait_event_interruptible(recv_wq, (op->done != 0)); 158 + if (rv == -ERESTARTSYS) { 159 + spin_lock(&ops_lock); 160 + list_del(&op->list); 161 + spin_unlock(&ops_lock); 162 + log_print("%s: wait interrupted %x %llx, op removed", 163 + __func__, ls->ls_global_id, 164 + (unsigned long long)number); 165 + dlm_release_plock_op(op); 166 + do_unlock_close(ls, number, file, fl); 162 167 goto out; 163 168 } 164 169 165 - spin_lock(&ops_lock); 166 - if (!list_empty(&op->list)) { 167 - log_error(ls, "dlm_posix_lock: op on list %llx", 168 - (unsigned long long)number); 169 - list_del(&op->list); 170 - } 171 - spin_unlock(&ops_lock); 170 + WARN_ON(!list_empty(&op->list)); 172 171 173 172 rv = op->info.rv; 174 173 ··· 181 174 (unsigned long long)number); 182 175 } 183 176 184 - kfree(xop); 177 + dlm_release_plock_op(op); 185 178 out: 186 179 dlm_put_lockspace(ls); 187 180 return rv; ··· 191 184 /* Returns failure iff a successful lock operation should be canceled */ 192 185 static int dlm_plock_callback(struct plock_op *op) 193 186 { 187 + struct plock_async_data *op_data = op->data; 194 188 struct file *file; 195 189 struct file_lock *fl; 196 190 struct file_lock *flc; 197 191 int (*notify)(struct file_lock *fl, int result) = NULL; 198 - struct plock_xop *xop = (struct plock_xop *)op; 199 192 int rv = 0; 200 193 201 - spin_lock(&ops_lock); 202 - if (!list_empty(&op->list)) { 203 - log_print("dlm_plock_callback: op on list %llx", 204 - (unsigned long long)op->info.number); 205 - list_del(&op->list); 206 - } 207 - spin_unlock(&ops_lock); 194 + WARN_ON(!list_empty(&op->list)); 208 195 209 196 /* check if the following 2 are still valid or make a copy */ 210 - file = xop->file; 211 - flc = &xop->flc; 212 - fl = xop->fl; 213 - notify = xop->callback; 197 + file = op_data->file; 198 + flc = &op_data->flc; 199 + fl = op_data->fl; 200 + notify = op_data->callback; 214 201 215 202 if (op->info.rv) { 216 203 notify(fl, op->info.rv); ··· 235 234 } 236 235 237 236 out: 238 - kfree(xop); 237 + dlm_release_plock_op(op); 239 238 return rv; 240 239 } 241 240 ··· 291 290 send_op(op); 292 291 wait_event(recv_wq, (op->done != 0)); 293 292 294 - spin_lock(&ops_lock); 295 - if (!list_empty(&op->list)) { 296 - log_error(ls, "dlm_posix_unlock: op on list %llx", 297 - (unsigned long long)number); 298 - list_del(&op->list); 299 - } 300 - spin_unlock(&ops_lock); 293 + WARN_ON(!list_empty(&op->list)); 301 294 302 295 rv = op->info.rv; 303 296 ··· 299 304 rv = 0; 300 305 301 306 out_free: 302 - kfree(op); 307 + dlm_release_plock_op(op); 303 308 out: 304 309 dlm_put_lockspace(ls); 305 310 fl->fl_flags = fl_flags; ··· 339 344 send_op(op); 340 345 wait_event(recv_wq, (op->done != 0)); 341 346 342 - spin_lock(&ops_lock); 343 - if (!list_empty(&op->list)) { 344 - log_error(ls, "dlm_posix_get: op on list %llx", 345 - (unsigned long long)number); 346 - list_del(&op->list); 347 - } 348 - spin_unlock(&ops_lock); 347 + WARN_ON(!list_empty(&op->list)); 349 348 350 349 /* info.rv from userspace is 1 for conflict, 0 for no-conflict, 351 350 -ENOENT if there are no locks on the file */ ··· 359 370 rv = 0; 360 371 } 361 372 362 - kfree(op); 373 + dlm_release_plock_op(op); 363 374 out: 364 375 dlm_put_lockspace(ls); 365 376 return rv; ··· 395 406 (the process did not make an unlock call). */ 396 407 397 408 if (op->info.flags & DLM_PLOCK_FL_CLOSE) 398 - kfree(op); 409 + dlm_release_plock_op(op); 399 410 400 411 if (copy_to_user(u, &info, sizeof(info))) 401 412 return -EFAULT; ··· 407 418 static ssize_t dev_write(struct file *file, const char __user *u, size_t count, 408 419 loff_t *ppos) 409 420 { 421 + struct plock_op *op = NULL, *iter; 410 422 struct dlm_plock_info info; 411 - struct plock_op *op; 412 - int found = 0, do_callback = 0; 423 + int do_callback = 0; 413 424 414 425 if (count != sizeof(info)) 415 426 return -EINVAL; ··· 421 432 return -EINVAL; 422 433 423 434 spin_lock(&ops_lock); 424 - list_for_each_entry(op, &recv_list, list) { 425 - if (op->info.fsid == info.fsid && 426 - op->info.number == info.number && 427 - op->info.owner == info.owner) { 428 - struct plock_xop *xop = (struct plock_xop *)op; 429 - list_del_init(&op->list); 430 - memcpy(&op->info, &info, sizeof(info)); 431 - if (xop->callback) 435 + list_for_each_entry(iter, &recv_list, list) { 436 + if (iter->info.fsid == info.fsid && 437 + iter->info.number == info.number && 438 + iter->info.owner == info.owner) { 439 + list_del_init(&iter->list); 440 + memcpy(&iter->info, &info, sizeof(info)); 441 + if (iter->data) 432 442 do_callback = 1; 433 443 else 434 - op->done = 1; 435 - found = 1; 444 + iter->done = 1; 445 + op = iter; 436 446 break; 437 447 } 438 448 } 439 449 spin_unlock(&ops_lock); 440 450 441 - if (found) { 451 + if (op) { 442 452 if (do_callback) 443 453 dlm_plock_callback(op); 444 454 else 445 455 wake_up(&recv_wq); 446 456 } else 447 - log_print("dev_write no op %x %llx", info.fsid, 448 - (unsigned long long)info.number); 457 + log_print("%s: no op %x %llx - may got interrupted?", __func__, 458 + info.fsid, (unsigned long long)info.number); 449 459 return count; 450 460 } 451 461 ··· 479 491 int dlm_plock_init(void) 480 492 { 481 493 int rv; 482 - 483 - spin_lock_init(&ops_lock); 484 - INIT_LIST_HEAD(&send_list); 485 - INIT_LIST_HEAD(&recv_list); 486 - init_waitqueue_head(&send_wq); 487 - init_waitqueue_head(&recv_wq); 488 494 489 495 rv = misc_register(&plock_dev_misc); 490 496 if (rv)
+61 -59
fs/dlm/rcom.c
··· 34 34 35 35 rc = (struct dlm_rcom *) mb; 36 36 37 - rc->rc_header.h_version = (DLM_HEADER_MAJOR | DLM_HEADER_MINOR); 38 - rc->rc_header.u.h_lockspace = ls->ls_global_id; 39 - rc->rc_header.h_nodeid = dlm_our_nodeid(); 40 - rc->rc_header.h_length = mb_len; 37 + rc->rc_header.h_version = cpu_to_le32(DLM_HEADER_MAJOR | DLM_HEADER_MINOR); 38 + rc->rc_header.u.h_lockspace = cpu_to_le32(ls->ls_global_id); 39 + rc->rc_header.h_nodeid = cpu_to_le32(dlm_our_nodeid()); 40 + rc->rc_header.h_length = cpu_to_le16(mb_len); 41 41 rc->rc_header.h_cmd = DLM_RCOM; 42 42 43 - rc->rc_type = type; 43 + rc->rc_type = cpu_to_le32(type); 44 44 45 45 spin_lock(&ls->ls_recover_lock); 46 - rc->rc_seq = ls->ls_recover_seq; 46 + rc->rc_seq = cpu_to_le64(ls->ls_recover_seq); 47 47 spin_unlock(&ls->ls_recover_lock); 48 48 49 49 *rc_ret = rc; ··· 91 91 92 92 static void send_rcom(struct dlm_mhandle *mh, struct dlm_rcom *rc) 93 93 { 94 - dlm_rcom_out(rc); 95 94 dlm_midcomms_commit_mhandle(mh); 96 95 } 97 96 98 97 static void send_rcom_stateless(struct dlm_msg *msg, struct dlm_rcom *rc) 99 98 { 100 - dlm_rcom_out(rc); 101 99 dlm_lowcomms_commit_msg(msg); 102 100 dlm_lowcomms_put_msg(msg); 103 101 } ··· 125 127 { 126 128 struct rcom_config *rf = (struct rcom_config *) rc->rc_buf; 127 129 128 - if ((rc->rc_header.h_version & 0xFFFF0000) != DLM_HEADER_MAJOR) { 130 + if ((le32_to_cpu(rc->rc_header.h_version) & 0xFFFF0000) != DLM_HEADER_MAJOR) { 129 131 log_error(ls, "version mismatch: %x nodeid %d: %x", 130 132 DLM_HEADER_MAJOR | DLM_HEADER_MINOR, nodeid, 131 - rc->rc_header.h_version); 133 + le32_to_cpu(rc->rc_header.h_version)); 132 134 return -EPROTO; 133 135 } 134 136 ··· 143 145 return 0; 144 146 } 145 147 146 - static void allow_sync_reply(struct dlm_ls *ls, uint64_t *new_seq) 148 + static void allow_sync_reply(struct dlm_ls *ls, __le64 *new_seq) 147 149 { 148 150 spin_lock(&ls->ls_rcom_spin); 149 - *new_seq = ++ls->ls_rcom_seq; 151 + *new_seq = cpu_to_le64(++ls->ls_rcom_seq); 150 152 set_bit(LSFL_RCOM_WAIT, &ls->ls_flags); 151 153 spin_unlock(&ls->ls_rcom_spin); 152 154 } ··· 180 182 181 183 if (nodeid == dlm_our_nodeid()) { 182 184 rc = ls->ls_recover_buf; 183 - rc->rc_result = dlm_recover_status(ls); 185 + rc->rc_result = cpu_to_le32(dlm_recover_status(ls)); 184 186 goto out; 185 187 } 186 188 ··· 206 208 207 209 rc = ls->ls_recover_buf; 208 210 209 - if (rc->rc_result == -ESRCH) { 211 + if (rc->rc_result == cpu_to_le32(-ESRCH)) { 210 212 /* we pretend the remote lockspace exists with 0 status */ 211 213 log_debug(ls, "remote node %d not ready", nodeid); 212 214 rc->rc_result = 0; ··· 225 227 struct dlm_rcom *rc; 226 228 struct rcom_status *rs; 227 229 uint32_t status; 228 - int nodeid = rc_in->rc_header.h_nodeid; 230 + int nodeid = le32_to_cpu(rc_in->rc_header.h_nodeid); 229 231 int len = sizeof(struct rcom_config); 230 232 struct dlm_msg *msg; 231 233 int num_slots = 0; ··· 257 259 258 260 rc->rc_id = rc_in->rc_id; 259 261 rc->rc_seq_reply = rc_in->rc_seq; 260 - rc->rc_result = status; 262 + rc->rc_result = cpu_to_le32(status); 261 263 262 264 set_rcom_config(ls, (struct rcom_config *)rc->rc_buf, num_slots); 263 265 ··· 285 287 { 286 288 spin_lock(&ls->ls_rcom_spin); 287 289 if (!test_bit(LSFL_RCOM_WAIT, &ls->ls_flags) || 288 - rc_in->rc_id != ls->ls_rcom_seq) { 290 + le64_to_cpu(rc_in->rc_id) != ls->ls_rcom_seq) { 289 291 log_debug(ls, "reject reply %d from %d seq %llx expect %llx", 290 - rc_in->rc_type, rc_in->rc_header.h_nodeid, 291 - (unsigned long long)rc_in->rc_id, 292 + le32_to_cpu(rc_in->rc_type), 293 + le32_to_cpu(rc_in->rc_header.h_nodeid), 294 + (unsigned long long)le64_to_cpu(rc_in->rc_id), 292 295 (unsigned long long)ls->ls_rcom_seq); 293 296 goto out; 294 297 } 295 - memcpy(ls->ls_recover_buf, rc_in, rc_in->rc_header.h_length); 298 + memcpy(ls->ls_recover_buf, rc_in, 299 + le16_to_cpu(rc_in->rc_header.h_length)); 296 300 set_bit(LSFL_RCOM_READY, &ls->ls_flags); 297 301 clear_bit(LSFL_RCOM_WAIT, &ls->ls_flags); 298 302 wake_up(&ls->ls_wait_general); ··· 336 336 int error, inlen, outlen, nodeid; 337 337 struct dlm_msg *msg; 338 338 339 - nodeid = rc_in->rc_header.h_nodeid; 340 - inlen = rc_in->rc_header.h_length - sizeof(struct dlm_rcom); 339 + nodeid = le32_to_cpu(rc_in->rc_header.h_nodeid); 340 + inlen = le16_to_cpu(rc_in->rc_header.h_length) - 341 + sizeof(struct dlm_rcom); 341 342 outlen = DLM_MAX_APP_BUFSIZE - sizeof(struct dlm_rcom); 342 343 343 344 error = create_rcom_stateless(ls, nodeid, DLM_RCOM_NAMES_REPLY, outlen, ··· 365 364 if (error) 366 365 goto out; 367 366 memcpy(rc->rc_buf, r->res_name, r->res_length); 368 - rc->rc_id = (unsigned long) r->res_id; 367 + rc->rc_id = cpu_to_le64(r->res_id); 369 368 370 369 send_rcom(mh, rc); 371 370 out: ··· 376 375 { 377 376 struct dlm_rcom *rc; 378 377 struct dlm_mhandle *mh; 379 - int error, ret_nodeid, nodeid = rc_in->rc_header.h_nodeid; 380 - int len = rc_in->rc_header.h_length - sizeof(struct dlm_rcom); 378 + int error, ret_nodeid, nodeid = le32_to_cpu(rc_in->rc_header.h_nodeid); 379 + int len = le16_to_cpu(rc_in->rc_header.h_length) - 380 + sizeof(struct dlm_rcom); 381 381 382 382 /* Old code would send this special id to trigger a debug dump. */ 383 - if (rc_in->rc_id == 0xFFFFFFFF) { 383 + if (rc_in->rc_id == cpu_to_le64(0xFFFFFFFF)) { 384 384 log_error(ls, "receive_rcom_lookup dump from %d", nodeid); 385 385 dlm_dump_rsb_name(ls, rc_in->rc_buf, len); 386 386 return; ··· 395 393 DLM_LU_RECOVER_MASTER, &ret_nodeid, NULL); 396 394 if (error) 397 395 ret_nodeid = error; 398 - rc->rc_result = ret_nodeid; 396 + rc->rc_result = cpu_to_le32(ret_nodeid); 399 397 rc->rc_id = rc_in->rc_id; 400 398 rc->rc_seq_reply = rc_in->rc_seq; 401 399 ··· 454 452 455 453 rl = (struct rcom_lock *) rc->rc_buf; 456 454 pack_rcom_lock(r, lkb, rl); 457 - rc->rc_id = (unsigned long) r; 455 + rc->rc_id = cpu_to_le64((uintptr_t)r); 458 456 459 457 send_rcom(mh, rc); 460 458 out: ··· 466 464 { 467 465 struct dlm_rcom *rc; 468 466 struct dlm_mhandle *mh; 469 - int error, nodeid = rc_in->rc_header.h_nodeid; 467 + int error, nodeid = le32_to_cpu(rc_in->rc_header.h_nodeid); 470 468 471 469 dlm_recover_master_copy(ls, rc_in); 472 470 ··· 502 500 503 501 rc = (struct dlm_rcom *) mb; 504 502 505 - rc->rc_header.h_version = (DLM_HEADER_MAJOR | DLM_HEADER_MINOR); 503 + rc->rc_header.h_version = cpu_to_le32(DLM_HEADER_MAJOR | DLM_HEADER_MINOR); 506 504 rc->rc_header.u.h_lockspace = rc_in->rc_header.u.h_lockspace; 507 - rc->rc_header.h_nodeid = dlm_our_nodeid(); 508 - rc->rc_header.h_length = mb_len; 505 + rc->rc_header.h_nodeid = cpu_to_le32(dlm_our_nodeid()); 506 + rc->rc_header.h_length = cpu_to_le16(mb_len); 509 507 rc->rc_header.h_cmd = DLM_RCOM; 510 508 511 - rc->rc_type = DLM_RCOM_STATUS_REPLY; 509 + rc->rc_type = cpu_to_le32(DLM_RCOM_STATUS_REPLY); 512 510 rc->rc_id = rc_in->rc_id; 513 511 rc->rc_seq_reply = rc_in->rc_seq; 514 - rc->rc_result = -ESRCH; 512 + rc->rc_result = cpu_to_le32(-ESRCH); 515 513 516 514 rf = (struct rcom_config *) rc->rc_buf; 517 515 rf->rf_lvblen = cpu_to_le32(~0U); 518 516 519 - dlm_rcom_out(rc); 520 517 dlm_midcomms_commit_mhandle(mh); 521 518 522 519 return 0; ··· 574 573 uint64_t seq; 575 574 576 575 switch (rc->rc_type) { 577 - case DLM_RCOM_STATUS_REPLY: 576 + case cpu_to_le32(DLM_RCOM_STATUS_REPLY): 578 577 reply = 1; 579 578 break; 580 - case DLM_RCOM_NAMES: 579 + case cpu_to_le32(DLM_RCOM_NAMES): 581 580 names = 1; 582 581 break; 583 - case DLM_RCOM_NAMES_REPLY: 582 + case cpu_to_le32(DLM_RCOM_NAMES_REPLY): 584 583 names = 1; 585 584 reply = 1; 586 585 break; 587 - case DLM_RCOM_LOOKUP: 586 + case cpu_to_le32(DLM_RCOM_LOOKUP): 588 587 lookup = 1; 589 588 break; 590 - case DLM_RCOM_LOOKUP_REPLY: 589 + case cpu_to_le32(DLM_RCOM_LOOKUP_REPLY): 591 590 lookup = 1; 592 591 reply = 1; 593 592 break; 594 - case DLM_RCOM_LOCK: 593 + case cpu_to_le32(DLM_RCOM_LOCK): 595 594 lock = 1; 596 595 break; 597 - case DLM_RCOM_LOCK_REPLY: 596 + case cpu_to_le32(DLM_RCOM_LOCK_REPLY): 598 597 lock = 1; 599 598 reply = 1; 600 599 break; ··· 606 605 seq = ls->ls_recover_seq; 607 606 spin_unlock(&ls->ls_recover_lock); 608 607 609 - if (stop && (rc->rc_type != DLM_RCOM_STATUS)) 608 + if (stop && (rc->rc_type != cpu_to_le32(DLM_RCOM_STATUS))) 610 609 goto ignore; 611 610 612 - if (reply && (rc->rc_seq_reply != seq)) 611 + if (reply && (le64_to_cpu(rc->rc_seq_reply) != seq)) 613 612 goto ignore; 614 613 615 614 if (!(status & DLM_RS_NODES) && (names || lookup || lock)) ··· 619 618 goto ignore; 620 619 621 620 switch (rc->rc_type) { 622 - case DLM_RCOM_STATUS: 621 + case cpu_to_le32(DLM_RCOM_STATUS): 623 622 receive_rcom_status(ls, rc); 624 623 break; 625 624 626 - case DLM_RCOM_NAMES: 625 + case cpu_to_le32(DLM_RCOM_NAMES): 627 626 receive_rcom_names(ls, rc); 628 627 break; 629 628 630 - case DLM_RCOM_LOOKUP: 629 + case cpu_to_le32(DLM_RCOM_LOOKUP): 631 630 receive_rcom_lookup(ls, rc); 632 631 break; 633 632 634 - case DLM_RCOM_LOCK: 635 - if (rc->rc_header.h_length < lock_size) 633 + case cpu_to_le32(DLM_RCOM_LOCK): 634 + if (le16_to_cpu(rc->rc_header.h_length) < lock_size) 636 635 goto Eshort; 637 636 receive_rcom_lock(ls, rc); 638 637 break; 639 638 640 - case DLM_RCOM_STATUS_REPLY: 639 + case cpu_to_le32(DLM_RCOM_STATUS_REPLY): 641 640 receive_sync_reply(ls, rc); 642 641 break; 643 642 644 - case DLM_RCOM_NAMES_REPLY: 643 + case cpu_to_le32(DLM_RCOM_NAMES_REPLY): 645 644 receive_sync_reply(ls, rc); 646 645 break; 647 646 648 - case DLM_RCOM_LOOKUP_REPLY: 647 + case cpu_to_le32(DLM_RCOM_LOOKUP_REPLY): 649 648 receive_rcom_lookup_reply(ls, rc); 650 649 break; 651 650 652 - case DLM_RCOM_LOCK_REPLY: 653 - if (rc->rc_header.h_length < lock_size) 651 + case cpu_to_le32(DLM_RCOM_LOCK_REPLY): 652 + if (le16_to_cpu(rc->rc_header.h_length) < lock_size) 654 653 goto Eshort; 655 654 dlm_recover_process_copy(ls, rc); 656 655 break; 657 656 658 657 default: 659 - log_error(ls, "receive_rcom bad type %d", rc->rc_type); 658 + log_error(ls, "receive_rcom bad type %d", 659 + le32_to_cpu(rc->rc_type)); 660 660 } 661 661 return; 662 662 663 663 ignore: 664 664 log_limit(ls, "dlm_receive_rcom ignore msg %d " 665 665 "from %d %llu %llu recover seq %llu sts %x gen %u", 666 - rc->rc_type, 666 + le32_to_cpu(rc->rc_type), 667 667 nodeid, 668 - (unsigned long long)rc->rc_seq, 669 - (unsigned long long)rc->rc_seq_reply, 668 + (unsigned long long)le64_to_cpu(rc->rc_seq), 669 + (unsigned long long)le64_to_cpu(rc->rc_seq_reply), 670 670 (unsigned long long)seq, 671 671 status, ls->ls_generation); 672 672 return; 673 673 Eshort: 674 674 log_error(ls, "recovery message %d from %d is too short", 675 - rc->rc_type, nodeid); 675 + le32_to_cpu(rc->rc_type), nodeid); 676 676 } 677 677
+24 -25
fs/dlm/recover.c
··· 114 114 if (save_slots) 115 115 dlm_slot_save(ls, rc, memb); 116 116 117 - if (rc->rc_result & wait_status) 117 + if (le32_to_cpu(rc->rc_result) & wait_status) 118 118 break; 119 119 if (delay < 1000) 120 120 delay += 20; ··· 141 141 if (error) 142 142 break; 143 143 144 - if (rc->rc_result & wait_status) 144 + if (le32_to_cpu(rc->rc_result) & wait_status) 145 145 break; 146 146 if (delay < 1000) 147 147 delay += 20; ··· 568 568 struct dlm_rsb *r; 569 569 int ret_nodeid, new_master; 570 570 571 - r = recover_idr_find(ls, rc->rc_id); 571 + r = recover_idr_find(ls, le64_to_cpu(rc->rc_id)); 572 572 if (!r) { 573 573 log_error(ls, "dlm_recover_master_reply no id %llx", 574 - (unsigned long long)rc->rc_id); 574 + (unsigned long long)le64_to_cpu(rc->rc_id)); 575 575 goto out; 576 576 } 577 577 578 - ret_nodeid = rc->rc_result; 578 + ret_nodeid = le32_to_cpu(rc->rc_result); 579 579 580 580 if (ret_nodeid == dlm_our_nodeid()) 581 581 new_master = 0; ··· 732 732 733 733 static void recover_lvb(struct dlm_rsb *r) 734 734 { 735 - struct dlm_lkb *lkb, *high_lkb = NULL; 735 + struct dlm_lkb *big_lkb = NULL, *iter, *high_lkb = NULL; 736 736 uint32_t high_seq = 0; 737 737 int lock_lvb_exists = 0; 738 - int big_lock_exists = 0; 739 738 int lvblen = r->res_ls->ls_lvblen; 740 739 741 740 if (!rsb_flag(r, RSB_NEW_MASTER2) && ··· 750 751 /* we are the new master, so figure out if VALNOTVALID should 751 752 be set, and set the rsb lvb from the best lkb available. */ 752 753 753 - list_for_each_entry(lkb, &r->res_grantqueue, lkb_statequeue) { 754 - if (!(lkb->lkb_exflags & DLM_LKF_VALBLK)) 754 + list_for_each_entry(iter, &r->res_grantqueue, lkb_statequeue) { 755 + if (!(iter->lkb_exflags & DLM_LKF_VALBLK)) 755 756 continue; 756 757 757 758 lock_lvb_exists = 1; 758 759 759 - if (lkb->lkb_grmode > DLM_LOCK_CR) { 760 - big_lock_exists = 1; 760 + if (iter->lkb_grmode > DLM_LOCK_CR) { 761 + big_lkb = iter; 761 762 goto setflag; 762 763 } 763 764 764 - if (((int)lkb->lkb_lvbseq - (int)high_seq) >= 0) { 765 - high_lkb = lkb; 766 - high_seq = lkb->lkb_lvbseq; 765 + if (((int)iter->lkb_lvbseq - (int)high_seq) >= 0) { 766 + high_lkb = iter; 767 + high_seq = iter->lkb_lvbseq; 767 768 } 768 769 } 769 770 770 - list_for_each_entry(lkb, &r->res_convertqueue, lkb_statequeue) { 771 - if (!(lkb->lkb_exflags & DLM_LKF_VALBLK)) 771 + list_for_each_entry(iter, &r->res_convertqueue, lkb_statequeue) { 772 + if (!(iter->lkb_exflags & DLM_LKF_VALBLK)) 772 773 continue; 773 774 774 775 lock_lvb_exists = 1; 775 776 776 - if (lkb->lkb_grmode > DLM_LOCK_CR) { 777 - big_lock_exists = 1; 777 + if (iter->lkb_grmode > DLM_LOCK_CR) { 778 + big_lkb = iter; 778 779 goto setflag; 779 780 } 780 781 781 - if (((int)lkb->lkb_lvbseq - (int)high_seq) >= 0) { 782 - high_lkb = lkb; 783 - high_seq = lkb->lkb_lvbseq; 782 + if (((int)iter->lkb_lvbseq - (int)high_seq) >= 0) { 783 + high_lkb = iter; 784 + high_seq = iter->lkb_lvbseq; 784 785 } 785 786 } 786 787 ··· 789 790 goto out; 790 791 791 792 /* lvb is invalidated if only NL/CR locks remain */ 792 - if (!big_lock_exists) 793 + if (!big_lkb) 793 794 rsb_set_flag(r, RSB_VALNOTVALID); 794 795 795 796 if (!r->res_lvbptr) { ··· 798 799 goto out; 799 800 } 800 801 801 - if (big_lock_exists) { 802 - r->res_lvbseq = lkb->lkb_lvbseq; 803 - memcpy(r->res_lvbptr, lkb->lkb_lvbptr, lvblen); 802 + if (big_lkb) { 803 + r->res_lvbseq = big_lkb->lkb_lvbseq; 804 + memcpy(r->res_lvbptr, big_lkb->lkb_lvbptr, lvblen); 804 805 } else if (high_lkb) { 805 806 r->res_lvbseq = high_lkb->lkb_lvbseq; 806 807 memcpy(r->res_lvbptr, high_lkb->lkb_lvbptr, lvblen);
+12 -8
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; ··· 33 32 void dlm_add_requestqueue(struct dlm_ls *ls, int nodeid, struct dlm_message *ms) 34 33 { 35 34 struct rq_entry *e; 36 - int length = ms->m_header.h_length - sizeof(struct dlm_message); 35 + int length = le16_to_cpu(ms->m_header.h_length) - 36 + sizeof(struct dlm_message); 37 37 38 38 e = kmalloc(sizeof(struct rq_entry) + length, GFP_NOFS); 39 39 if (!e) { ··· 44 42 45 43 e->recover_seq = ls->ls_recover_seq & 0xFFFFFFFF; 46 44 e->nodeid = nodeid; 47 - memcpy(&e->request, ms, ms->m_header.h_length); 45 + memcpy(&e->request, ms, le16_to_cpu(ms->m_header.h_length)); 48 46 49 47 atomic_inc(&ls->ls_requestqueue_cnt); 50 48 mutex_lock(&ls->ls_requestqueue_mutex); ··· 84 82 85 83 log_limit(ls, "dlm_process_requestqueue msg %d from %d " 86 84 "lkid %x remid %x result %d seq %u", 87 - ms->m_type, ms->m_header.h_nodeid, 88 - ms->m_lkid, ms->m_remid, ms->m_result, 85 + le32_to_cpu(ms->m_type), 86 + le32_to_cpu(ms->m_header.h_nodeid), 87 + le32_to_cpu(ms->m_lkid), le32_to_cpu(ms->m_remid), 88 + from_dlm_errno(le32_to_cpu(ms->m_result)), 89 89 e->recover_seq); 90 90 91 91 dlm_receive_message_saved(ls, &e->request, e->recover_seq); ··· 128 124 129 125 static int purge_request(struct dlm_ls *ls, struct dlm_message *ms, int nodeid) 130 126 { 131 - uint32_t type = ms->m_type; 127 + __le32 type = ms->m_type; 132 128 133 129 /* the ls is being cleaned up and freed by release_lockspace */ 134 130 if (!atomic_read(&ls->ls_count)) ··· 140 136 /* directory operations are always purged because the directory is 141 137 always rebuilt during recovery and the lookups resent */ 142 138 143 - if (type == DLM_MSG_REMOVE || 144 - type == DLM_MSG_LOOKUP || 145 - type == DLM_MSG_LOOKUP_REPLY) 139 + if (type == cpu_to_le32(DLM_MSG_REMOVE) || 140 + type == cpu_to_le32(DLM_MSG_LOOKUP) || 141 + type == cpu_to_le32(DLM_MSG_LOOKUP_REPLY)) 146 142 return 1; 147 143 148 144 if (!dlm_no_directory(ls))
+8 -8
fs/dlm/user.c
··· 108 108 kb->i.lock.parent = kb32->i.lock.parent; 109 109 kb->i.lock.xid = kb32->i.lock.xid; 110 110 kb->i.lock.timeout = kb32->i.lock.timeout; 111 - kb->i.lock.castparam = (void *)(long)kb32->i.lock.castparam; 112 - kb->i.lock.castaddr = (void *)(long)kb32->i.lock.castaddr; 113 - kb->i.lock.bastparam = (void *)(long)kb32->i.lock.bastparam; 114 - kb->i.lock.bastaddr = (void *)(long)kb32->i.lock.bastaddr; 115 - kb->i.lock.lksb = (void *)(long)kb32->i.lock.lksb; 111 + kb->i.lock.castparam = (__user void *)(long)kb32->i.lock.castparam; 112 + kb->i.lock.castaddr = (__user void *)(long)kb32->i.lock.castaddr; 113 + kb->i.lock.bastparam = (__user void *)(long)kb32->i.lock.bastparam; 114 + kb->i.lock.bastaddr = (__user void *)(long)kb32->i.lock.bastaddr; 115 + kb->i.lock.lksb = (__user void *)(long)kb32->i.lock.lksb; 116 116 memcpy(kb->i.lock.lvb, kb32->i.lock.lvb, DLM_USER_LVB_LEN); 117 117 memcpy(kb->i.lock.name, kb32->i.lock.name, namelen); 118 118 } ··· 127 127 res32->version[1] = res->version[1]; 128 128 res32->version[2] = res->version[2]; 129 129 130 - res32->user_astaddr = (__u32)(long)res->user_astaddr; 131 - res32->user_astparam = (__u32)(long)res->user_astparam; 132 - res32->user_lksb = (__u32)(long)res->user_lksb; 130 + res32->user_astaddr = (__u32)(__force long)res->user_astaddr; 131 + res32->user_astparam = (__u32)(__force long)res->user_astparam; 132 + res32->user_lksb = (__u32)(__force long)res->user_lksb; 133 133 res32->bast_mode = res->bast_mode; 134 134 135 135 res32->lvb_offset = res->lvb_offset;
+2 -90
fs/dlm/util.c
··· 20 20 #define DLM_ERRNO_ETIMEDOUT 110 21 21 #define DLM_ERRNO_EINPROGRESS 115 22 22 23 - void 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 - 32 - void 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 23 /* higher errno values are inconsistent across architectures, so select 42 24 one set of values for on the wire */ 43 25 44 - static int to_dlm_errno(int err) 26 + int to_dlm_errno(int err) 45 27 { 46 28 switch (err) { 47 29 case -EDEADLK: ··· 44 62 return err; 45 63 } 46 64 47 - static int from_dlm_errno(int err) 65 + int from_dlm_errno(int err) 48 66 { 49 67 switch (err) { 50 68 case -DLM_ERRNO_EDEADLK: ··· 63 81 return -EINPROGRESS; 64 82 } 65 83 return err; 66 - } 67 - 68 - void dlm_message_out(struct dlm_message *ms) 69 - { 70 - header_out(&ms->m_header); 71 - 72 - ms->m_type = cpu_to_le32(ms->m_type); 73 - ms->m_nodeid = cpu_to_le32(ms->m_nodeid); 74 - ms->m_pid = cpu_to_le32(ms->m_pid); 75 - ms->m_lkid = cpu_to_le32(ms->m_lkid); 76 - ms->m_remid = cpu_to_le32(ms->m_remid); 77 - ms->m_parent_lkid = cpu_to_le32(ms->m_parent_lkid); 78 - ms->m_parent_remid = cpu_to_le32(ms->m_parent_remid); 79 - ms->m_exflags = cpu_to_le32(ms->m_exflags); 80 - ms->m_sbflags = cpu_to_le32(ms->m_sbflags); 81 - ms->m_flags = cpu_to_le32(ms->m_flags); 82 - ms->m_lvbseq = cpu_to_le32(ms->m_lvbseq); 83 - ms->m_hash = cpu_to_le32(ms->m_hash); 84 - ms->m_status = cpu_to_le32(ms->m_status); 85 - ms->m_grmode = cpu_to_le32(ms->m_grmode); 86 - ms->m_rqmode = cpu_to_le32(ms->m_rqmode); 87 - ms->m_bastmode = cpu_to_le32(ms->m_bastmode); 88 - ms->m_asts = cpu_to_le32(ms->m_asts); 89 - ms->m_result = cpu_to_le32(to_dlm_errno(ms->m_result)); 90 - } 91 - 92 - void dlm_message_in(struct dlm_message *ms) 93 - { 94 - header_in(&ms->m_header); 95 - 96 - ms->m_type = le32_to_cpu(ms->m_type); 97 - ms->m_nodeid = le32_to_cpu(ms->m_nodeid); 98 - ms->m_pid = le32_to_cpu(ms->m_pid); 99 - ms->m_lkid = le32_to_cpu(ms->m_lkid); 100 - ms->m_remid = le32_to_cpu(ms->m_remid); 101 - ms->m_parent_lkid = le32_to_cpu(ms->m_parent_lkid); 102 - ms->m_parent_remid = le32_to_cpu(ms->m_parent_remid); 103 - ms->m_exflags = le32_to_cpu(ms->m_exflags); 104 - ms->m_sbflags = le32_to_cpu(ms->m_sbflags); 105 - ms->m_flags = le32_to_cpu(ms->m_flags); 106 - ms->m_lvbseq = le32_to_cpu(ms->m_lvbseq); 107 - ms->m_hash = le32_to_cpu(ms->m_hash); 108 - ms->m_status = le32_to_cpu(ms->m_status); 109 - ms->m_grmode = le32_to_cpu(ms->m_grmode); 110 - ms->m_rqmode = le32_to_cpu(ms->m_rqmode); 111 - ms->m_bastmode = le32_to_cpu(ms->m_bastmode); 112 - ms->m_asts = le32_to_cpu(ms->m_asts); 113 - ms->m_result = from_dlm_errno(le32_to_cpu(ms->m_result)); 114 - } 115 - 116 - void dlm_rcom_out(struct dlm_rcom *rc) 117 - { 118 - header_out(&rc->rc_header); 119 - 120 - rc->rc_type = cpu_to_le32(rc->rc_type); 121 - rc->rc_result = cpu_to_le32(rc->rc_result); 122 - rc->rc_id = cpu_to_le64(rc->rc_id); 123 - rc->rc_seq = cpu_to_le64(rc->rc_seq); 124 - rc->rc_seq_reply = cpu_to_le64(rc->rc_seq_reply); 125 - } 126 - 127 - void dlm_rcom_in(struct dlm_rcom *rc) 128 - { 129 - header_in(&rc->rc_header); 130 - 131 - rc->rc_type = le32_to_cpu(rc->rc_type); 132 - rc->rc_result = le32_to_cpu(rc->rc_result); 133 - rc->rc_id = le64_to_cpu(rc->rc_id); 134 - rc->rc_seq = le64_to_cpu(rc->rc_seq); 135 - rc->rc_seq_reply = le64_to_cpu(rc->rc_seq_reply); 136 84 }
+2 -6
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); 16 - void dlm_rcom_out(struct dlm_rcom *rc); 17 - void dlm_rcom_in(struct dlm_rcom *rc); 18 - void header_out(struct dlm_header *hd); 19 - void header_in(struct dlm_header *hd); 14 + int to_dlm_errno(int err); 15 + int from_dlm_errno(int err); 20 16 21 17 #endif 22 18