aboutsummaryrefslogtreecommitdiffstats
path: root/fs/dlm/lock.c
diff options
context:
space:
mode:
authorDavid Teigland <teigland@redhat.com>2006-01-20 03:47:07 -0500
committerSteven Whitehouse <steve@chygwyn.com>2006-01-20 03:47:07 -0500
commit901359256b2666f52a3a7d3f31927677e91b3a2a (patch)
tree24d4ee2c1ad63a0e6c3a303ad67eac3342772c4f /fs/dlm/lock.c
parentec5800246607183a1d7fd0bae5f087c12439e9e7 (diff)
[DLM] Update DLM to the latest patch level
Signed-off-by: David Teigland <teigland@redhat.com> Signed-off-by: Steve Whitehouse <swhiteho@redhat.com>
Diffstat (limited to 'fs/dlm/lock.c')
-rw-r--r--fs/dlm/lock.c72
1 files changed, 36 insertions, 36 deletions
diff --git a/fs/dlm/lock.c b/fs/dlm/lock.c
index 81efb361f95d..29d3b95dbb63 100644
--- a/fs/dlm/lock.c
+++ b/fs/dlm/lock.c
@@ -215,15 +215,15 @@ static inline int is_master_copy(struct dlm_lkb *lkb)
215{ 215{
216 if (lkb->lkb_flags & DLM_IFL_MSTCPY) 216 if (lkb->lkb_flags & DLM_IFL_MSTCPY)
217 DLM_ASSERT(lkb->lkb_nodeid, dlm_print_lkb(lkb);); 217 DLM_ASSERT(lkb->lkb_nodeid, dlm_print_lkb(lkb););
218 return (lkb->lkb_flags & DLM_IFL_MSTCPY) ? TRUE : FALSE; 218 return (lkb->lkb_flags & DLM_IFL_MSTCPY) ? 1 : 0;
219} 219}
220 220
221static inline int middle_conversion(struct dlm_lkb *lkb) 221static inline int middle_conversion(struct dlm_lkb *lkb)
222{ 222{
223 if ((lkb->lkb_grmode==DLM_LOCK_PR && lkb->lkb_rqmode==DLM_LOCK_CW) || 223 if ((lkb->lkb_grmode==DLM_LOCK_PR && lkb->lkb_rqmode==DLM_LOCK_CW) ||
224 (lkb->lkb_rqmode==DLM_LOCK_PR && lkb->lkb_grmode==DLM_LOCK_CW)) 224 (lkb->lkb_rqmode==DLM_LOCK_PR && lkb->lkb_grmode==DLM_LOCK_CW))
225 return TRUE; 225 return 1;
226 return FALSE; 226 return 0;
227} 227}
228 228
229static inline int down_conversion(struct dlm_lkb *lkb) 229static inline int down_conversion(struct dlm_lkb *lkb)
@@ -269,7 +269,7 @@ static struct dlm_rsb *create_rsb(struct dlm_ls *ls, char *name, int len)
269 r->res_ls = ls; 269 r->res_ls = ls;
270 r->res_length = len; 270 r->res_length = len;
271 memcpy(r->res_name, name, len); 271 memcpy(r->res_name, name, len);
272 init_MUTEX(&r->res_sem); 272 mutex_init(&r->res_mutex);
273 273
274 INIT_LIST_HEAD(&r->res_lookup); 274 INIT_LIST_HEAD(&r->res_lookup);
275 INIT_LIST_HEAD(&r->res_grantqueue); 275 INIT_LIST_HEAD(&r->res_grantqueue);
@@ -712,7 +712,7 @@ static void add_to_waiters(struct dlm_lkb *lkb, int mstype)
712{ 712{
713 struct dlm_ls *ls = lkb->lkb_resource->res_ls; 713 struct dlm_ls *ls = lkb->lkb_resource->res_ls;
714 714
715 down(&ls->ls_waiters_sem); 715 mutex_lock(&ls->ls_waiters_mutex);
716 if (lkb->lkb_wait_type) { 716 if (lkb->lkb_wait_type) {
717 log_print("add_to_waiters error %d", lkb->lkb_wait_type); 717 log_print("add_to_waiters error %d", lkb->lkb_wait_type);
718 goto out; 718 goto out;
@@ -721,7 +721,7 @@ static void add_to_waiters(struct dlm_lkb *lkb, int mstype)
721 kref_get(&lkb->lkb_ref); 721 kref_get(&lkb->lkb_ref);
722 list_add(&lkb->lkb_wait_reply, &ls->ls_waiters); 722 list_add(&lkb->lkb_wait_reply, &ls->ls_waiters);
723 out: 723 out:
724 up(&ls->ls_waiters_sem); 724 mutex_unlock(&ls->ls_waiters_mutex);
725} 725}
726 726
727static int _remove_from_waiters(struct dlm_lkb *lkb) 727static int _remove_from_waiters(struct dlm_lkb *lkb)
@@ -745,9 +745,9 @@ static int remove_from_waiters(struct dlm_lkb *lkb)
745 struct dlm_ls *ls = lkb->lkb_resource->res_ls; 745 struct dlm_ls *ls = lkb->lkb_resource->res_ls;
746 int error; 746 int error;
747 747
748 down(&ls->ls_waiters_sem); 748 mutex_lock(&ls->ls_waiters_mutex);
749 error = _remove_from_waiters(lkb); 749 error = _remove_from_waiters(lkb);
750 up(&ls->ls_waiters_sem); 750 mutex_unlock(&ls->ls_waiters_mutex);
751 return error; 751 return error;
752} 752}
753 753
@@ -775,14 +775,14 @@ static int shrink_bucket(struct dlm_ls *ls, int b)
775 int count = 0, found; 775 int count = 0, found;
776 776
777 for (;;) { 777 for (;;) {
778 found = FALSE; 778 found = 0;
779 write_lock(&ls->ls_rsbtbl[b].lock); 779 write_lock(&ls->ls_rsbtbl[b].lock);
780 list_for_each_entry_reverse(r, &ls->ls_rsbtbl[b].toss, 780 list_for_each_entry_reverse(r, &ls->ls_rsbtbl[b].toss,
781 res_hashchain) { 781 res_hashchain) {
782 if (!time_after_eq(jiffies, r->res_toss_time + 782 if (!time_after_eq(jiffies, r->res_toss_time +
783 dlm_config.toss_secs * HZ)) 783 dlm_config.toss_secs * HZ))
784 continue; 784 continue;
785 found = TRUE; 785 found = 1;
786 break; 786 break;
787 } 787 }
788 788
@@ -1027,9 +1027,9 @@ static inline int first_in_list(struct dlm_lkb *lkb, struct list_head *head)
1027 struct dlm_lkb *first = list_entry(head->next, struct dlm_lkb, 1027 struct dlm_lkb *first = list_entry(head->next, struct dlm_lkb,
1028 lkb_statequeue); 1028 lkb_statequeue);
1029 if (lkb->lkb_id == first->lkb_id) 1029 if (lkb->lkb_id == first->lkb_id)
1030 return TRUE; 1030 return 1;
1031 1031
1032 return FALSE; 1032 return 0;
1033} 1033}
1034 1034
1035/* Return 1 if the locks' ranges overlap. If the lkb has no range then it is 1035/* Return 1 if the locks' ranges overlap. If the lkb has no range then it is
@@ -1038,13 +1038,13 @@ static inline int first_in_list(struct dlm_lkb *lkb, struct list_head *head)
1038static inline int ranges_overlap(struct dlm_lkb *lkb1, struct dlm_lkb *lkb2) 1038static inline int ranges_overlap(struct dlm_lkb *lkb1, struct dlm_lkb *lkb2)
1039{ 1039{
1040 if (!lkb1->lkb_range || !lkb2->lkb_range) 1040 if (!lkb1->lkb_range || !lkb2->lkb_range)
1041 return TRUE; 1041 return 1;
1042 1042
1043 if (lkb1->lkb_range[RQ_RANGE_END] < lkb2->lkb_range[GR_RANGE_START] || 1043 if (lkb1->lkb_range[RQ_RANGE_END] < lkb2->lkb_range[GR_RANGE_START] ||
1044 lkb1->lkb_range[RQ_RANGE_START] > lkb2->lkb_range[GR_RANGE_END]) 1044 lkb1->lkb_range[RQ_RANGE_START] > lkb2->lkb_range[GR_RANGE_END])
1045 return FALSE; 1045 return 0;
1046 1046
1047 return TRUE; 1047 return 1;
1048} 1048}
1049 1049
1050/* Check if the given lkb conflicts with another lkb on the queue. */ 1050/* Check if the given lkb conflicts with another lkb on the queue. */
@@ -1057,9 +1057,9 @@ static int queue_conflict(struct list_head *head, struct dlm_lkb *lkb)
1057 if (this == lkb) 1057 if (this == lkb)
1058 continue; 1058 continue;
1059 if (ranges_overlap(lkb, this) && !modes_compat(this, lkb)) 1059 if (ranges_overlap(lkb, this) && !modes_compat(this, lkb))
1060 return TRUE; 1060 return 1;
1061 } 1061 }
1062 return FALSE; 1062 return 0;
1063} 1063}
1064 1064
1065/* 1065/*
@@ -1103,7 +1103,7 @@ static int conversion_deadlock_detect(struct dlm_rsb *rsb, struct dlm_lkb *lkb)
1103 continue; 1103 continue;
1104 1104
1105 if (!modes_compat(this, lkb) && !modes_compat(lkb, this)) 1105 if (!modes_compat(this, lkb) && !modes_compat(lkb, this))
1106 return TRUE; 1106 return 1;
1107 } 1107 }
1108 1108
1109 /* if lkb is on the convert queue and is preventing the first 1109 /* if lkb is on the convert queue and is preventing the first
@@ -1114,10 +1114,10 @@ static int conversion_deadlock_detect(struct dlm_rsb *rsb, struct dlm_lkb *lkb)
1114 if (self && self != first) { 1114 if (self && self != first) {
1115 if (!modes_compat(lkb, first) && 1115 if (!modes_compat(lkb, first) &&
1116 !queue_conflict(&rsb->res_grantqueue, first)) 1116 !queue_conflict(&rsb->res_grantqueue, first))
1117 return TRUE; 1117 return 1;
1118 } 1118 }
1119 1119
1120 return FALSE; 1120 return 0;
1121} 1121}
1122 1122
1123/* 1123/*
@@ -1157,7 +1157,7 @@ static int _can_be_granted(struct dlm_rsb *r, struct dlm_lkb *lkb, int now)
1157 */ 1157 */
1158 1158
1159 if (lkb->lkb_exflags & DLM_LKF_EXPEDITE) 1159 if (lkb->lkb_exflags & DLM_LKF_EXPEDITE)
1160 return TRUE; 1160 return 1;
1161 1161
1162 /* 1162 /*
1163 * A shortcut. Without this, !queue_conflict(grantqueue, lkb) would be 1163 * A shortcut. Without this, !queue_conflict(grantqueue, lkb) would be
@@ -1200,7 +1200,7 @@ static int _can_be_granted(struct dlm_rsb *r, struct dlm_lkb *lkb, int now)
1200 */ 1200 */
1201 1201
1202 if (now && conv && !(lkb->lkb_exflags & DLM_LKF_QUECVT)) 1202 if (now && conv && !(lkb->lkb_exflags & DLM_LKF_QUECVT))
1203 return TRUE; 1203 return 1;
1204 1204
1205 /* 1205 /*
1206 * When using range locks the NOORDER flag is set to avoid the standard 1206 * When using range locks the NOORDER flag is set to avoid the standard
@@ -1208,7 +1208,7 @@ static int _can_be_granted(struct dlm_rsb *r, struct dlm_lkb *lkb, int now)
1208 */ 1208 */
1209 1209
1210 if (lkb->lkb_exflags & DLM_LKF_NOORDER) 1210 if (lkb->lkb_exflags & DLM_LKF_NOORDER)
1211 return TRUE; 1211 return 1;
1212 1212
1213 /* 1213 /*
1214 * 6-3: Once in that queue [CONVERTING], a conversion request cannot be 1214 * 6-3: Once in that queue [CONVERTING], a conversion request cannot be
@@ -1217,7 +1217,7 @@ static int _can_be_granted(struct dlm_rsb *r, struct dlm_lkb *lkb, int now)
1217 */ 1217 */
1218 1218
1219 if (!now && conv && first_in_list(lkb, &r->res_convertqueue)) 1219 if (!now && conv && first_in_list(lkb, &r->res_convertqueue))
1220 return TRUE; 1220 return 1;
1221 1221
1222 /* 1222 /*
1223 * 6-4: By default, a new request is immediately granted only if all 1223 * 6-4: By default, a new request is immediately granted only if all
@@ -1232,7 +1232,7 @@ static int _can_be_granted(struct dlm_rsb *r, struct dlm_lkb *lkb, int now)
1232 1232
1233 if (now && !conv && list_empty(&r->res_convertqueue) && 1233 if (now && !conv && list_empty(&r->res_convertqueue) &&
1234 list_empty(&r->res_waitqueue)) 1234 list_empty(&r->res_waitqueue))
1235 return TRUE; 1235 return 1;
1236 1236
1237 /* 1237 /*
1238 * 6-4: Once a lock request is in the queue of ungranted new requests, 1238 * 6-4: Once a lock request is in the queue of ungranted new requests,
@@ -1244,7 +1244,7 @@ static int _can_be_granted(struct dlm_rsb *r, struct dlm_lkb *lkb, int now)
1244 1244
1245 if (!now && !conv && list_empty(&r->res_convertqueue) && 1245 if (!now && !conv && list_empty(&r->res_convertqueue) &&
1246 first_in_list(lkb, &r->res_waitqueue)) 1246 first_in_list(lkb, &r->res_waitqueue))
1247 return TRUE; 1247 return 1;
1248 1248
1249 out: 1249 out:
1250 /* 1250 /*
@@ -1257,7 +1257,7 @@ static int _can_be_granted(struct dlm_rsb *r, struct dlm_lkb *lkb, int now)
1257 lkb->lkb_sbflags |= DLM_SBF_DEMOTED; 1257 lkb->lkb_sbflags |= DLM_SBF_DEMOTED;
1258 } 1258 }
1259 1259
1260 return FALSE; 1260 return 0;
1261} 1261}
1262 1262
1263/* 1263/*
@@ -1308,7 +1308,7 @@ static int grant_pending_convert(struct dlm_rsb *r, int high)
1308 1308
1309 list_for_each_entry_safe(lkb, s, &r->res_convertqueue, lkb_statequeue) { 1309 list_for_each_entry_safe(lkb, s, &r->res_convertqueue, lkb_statequeue) {
1310 demoted = is_demoted(lkb); 1310 demoted = is_demoted(lkb);
1311 if (can_be_granted(r, lkb, FALSE)) { 1311 if (can_be_granted(r, lkb, 0)) {
1312 grant_lock_pending(r, lkb); 1312 grant_lock_pending(r, lkb);
1313 grant_restart = 1; 1313 grant_restart = 1;
1314 } else { 1314 } else {
@@ -1333,7 +1333,7 @@ static int grant_pending_wait(struct dlm_rsb *r, int high)
1333 struct dlm_lkb *lkb, *s; 1333 struct dlm_lkb *lkb, *s;
1334 1334
1335 list_for_each_entry_safe(lkb, s, &r->res_waitqueue, lkb_statequeue) { 1335 list_for_each_entry_safe(lkb, s, &r->res_waitqueue, lkb_statequeue) {
1336 if (can_be_granted(r, lkb, FALSE)) 1336 if (can_be_granted(r, lkb, 0))
1337 grant_lock_pending(r, lkb); 1337 grant_lock_pending(r, lkb);
1338 else 1338 else
1339 high = max_t(int, lkb->lkb_rqmode, high); 1339 high = max_t(int, lkb->lkb_rqmode, high);
@@ -1705,7 +1705,7 @@ static int do_request(struct dlm_rsb *r, struct dlm_lkb *lkb)
1705{ 1705{
1706 int error = 0; 1706 int error = 0;
1707 1707
1708 if (can_be_granted(r, lkb, TRUE)) { 1708 if (can_be_granted(r, lkb, 1)) {
1709 grant_lock(r, lkb); 1709 grant_lock(r, lkb);
1710 queue_cast(r, lkb, 0); 1710 queue_cast(r, lkb, 0);
1711 goto out; 1711 goto out;
@@ -1733,7 +1733,7 @@ static int do_convert(struct dlm_rsb *r, struct dlm_lkb *lkb)
1733 1733
1734 /* changing an existing lock may allow others to be granted */ 1734 /* changing an existing lock may allow others to be granted */
1735 1735
1736 if (can_be_granted(r, lkb, TRUE)) { 1736 if (can_be_granted(r, lkb, 1)) {
1737 grant_lock(r, lkb); 1737 grant_lock(r, lkb);
1738 queue_cast(r, lkb, 0); 1738 queue_cast(r, lkb, 0);
1739 grant_pending_locks(r); 1739 grant_pending_locks(r);
@@ -2556,7 +2556,7 @@ static void receive_convert(struct dlm_ls *ls, struct dlm_message *ms)
2556{ 2556{
2557 struct dlm_lkb *lkb; 2557 struct dlm_lkb *lkb;
2558 struct dlm_rsb *r; 2558 struct dlm_rsb *r;
2559 int error, reply = TRUE; 2559 int error, reply = 1;
2560 2560
2561 error = find_lkb(ls, ms->m_remid, &lkb); 2561 error = find_lkb(ls, ms->m_remid, &lkb);
2562 if (error) 2562 if (error)
@@ -3205,7 +3205,7 @@ void dlm_recover_waiters_pre(struct dlm_ls *ls)
3205{ 3205{
3206 struct dlm_lkb *lkb, *safe; 3206 struct dlm_lkb *lkb, *safe;
3207 3207
3208 down(&ls->ls_waiters_sem); 3208 mutex_lock(&ls->ls_waiters_mutex);
3209 3209
3210 list_for_each_entry_safe(lkb, safe, &ls->ls_waiters, lkb_wait_reply) { 3210 list_for_each_entry_safe(lkb, safe, &ls->ls_waiters, lkb_wait_reply) {
3211 log_debug(ls, "pre recover waiter lkid %x type %d flags %x", 3211 log_debug(ls, "pre recover waiter lkid %x type %d flags %x",
@@ -3253,7 +3253,7 @@ void dlm_recover_waiters_pre(struct dlm_ls *ls)
3253 lkb->lkb_wait_type); 3253 lkb->lkb_wait_type);
3254 } 3254 }
3255 } 3255 }
3256 up(&ls->ls_waiters_sem); 3256 mutex_unlock(&ls->ls_waiters_mutex);
3257} 3257}
3258 3258
3259static int remove_resend_waiter(struct dlm_ls *ls, struct dlm_lkb **lkb_ret) 3259static int remove_resend_waiter(struct dlm_ls *ls, struct dlm_lkb **lkb_ret)
@@ -3261,7 +3261,7 @@ static int remove_resend_waiter(struct dlm_ls *ls, struct dlm_lkb **lkb_ret)
3261 struct dlm_lkb *lkb; 3261 struct dlm_lkb *lkb;
3262 int rv = 0; 3262 int rv = 0;
3263 3263
3264 down(&ls->ls_waiters_sem); 3264 mutex_lock(&ls->ls_waiters_mutex);
3265 list_for_each_entry(lkb, &ls->ls_waiters, lkb_wait_reply) { 3265 list_for_each_entry(lkb, &ls->ls_waiters, lkb_wait_reply) {
3266 if (lkb->lkb_flags & DLM_IFL_RESEND) { 3266 if (lkb->lkb_flags & DLM_IFL_RESEND) {
3267 rv = lkb->lkb_wait_type; 3267 rv = lkb->lkb_wait_type;
@@ -3270,7 +3270,7 @@ static int remove_resend_waiter(struct dlm_ls *ls, struct dlm_lkb **lkb_ret)
3270 break; 3270 break;
3271 } 3271 }
3272 } 3272 }
3273 up(&ls->ls_waiters_sem); 3273 mutex_unlock(&ls->ls_waiters_mutex);
3274 3274
3275 if (!rv) 3275 if (!rv)
3276 lkb = NULL; 3276 lkb = NULL;