aboutsummaryrefslogtreecommitdiffstats
path: root/fs/dlm/lock.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/dlm/lock.c')
-rw-r--r--fs/dlm/lock.c103
1 files changed, 9 insertions, 94 deletions
diff --git a/fs/dlm/lock.c b/fs/dlm/lock.c
index 29d3b95dbb63..80487703d582 100644
--- a/fs/dlm/lock.c
+++ b/fs/dlm/lock.c
@@ -606,8 +606,6 @@ static int put_lkb(struct dlm_lkb *lkb)
606 /* for local/process lkbs, lvbptr points to caller's lksb */ 606 /* for local/process lkbs, lvbptr points to caller's lksb */
607 if (lkb->lkb_lvbptr && is_master_copy(lkb)) 607 if (lkb->lkb_lvbptr && is_master_copy(lkb))
608 free_lvb(lkb->lkb_lvbptr); 608 free_lvb(lkb->lkb_lvbptr);
609 if (lkb->lkb_range)
610 free_range(lkb->lkb_range);
611 free_lkb(lkb); 609 free_lkb(lkb);
612 return 1; 610 return 1;
613 } else { 611 } else {
@@ -988,11 +986,6 @@ static void _grant_lock(struct dlm_rsb *r, struct dlm_lkb *lkb)
988 } 986 }
989 987
990 lkb->lkb_rqmode = DLM_LOCK_IV; 988 lkb->lkb_rqmode = DLM_LOCK_IV;
991
992 if (lkb->lkb_range) {
993 lkb->lkb_range[GR_RANGE_START] = lkb->lkb_range[RQ_RANGE_START];
994 lkb->lkb_range[GR_RANGE_END] = lkb->lkb_range[RQ_RANGE_END];
995 }
996} 989}
997 990
998static void grant_lock(struct dlm_rsb *r, struct dlm_lkb *lkb) 991static void grant_lock(struct dlm_rsb *r, struct dlm_lkb *lkb)
@@ -1032,21 +1025,6 @@ static inline int first_in_list(struct dlm_lkb *lkb, struct list_head *head)
1032 return 0; 1025 return 0;
1033} 1026}
1034 1027
1035/* Return 1 if the locks' ranges overlap. If the lkb has no range then it is
1036 assumed to cover 0-ffffffff.ffffffff */
1037
1038static inline int ranges_overlap(struct dlm_lkb *lkb1, struct dlm_lkb *lkb2)
1039{
1040 if (!lkb1->lkb_range || !lkb2->lkb_range)
1041 return 1;
1042
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])
1045 return 0;
1046
1047 return 1;
1048}
1049
1050/* Check if the given lkb conflicts with another lkb on the queue. */ 1028/* Check if the given lkb conflicts with another lkb on the queue. */
1051 1029
1052static int queue_conflict(struct list_head *head, struct dlm_lkb *lkb) 1030static int queue_conflict(struct list_head *head, struct dlm_lkb *lkb)
@@ -1056,7 +1034,7 @@ static int queue_conflict(struct list_head *head, struct dlm_lkb *lkb)
1056 list_for_each_entry(this, head, lkb_statequeue) { 1034 list_for_each_entry(this, head, lkb_statequeue) {
1057 if (this == lkb) 1035 if (this == lkb)
1058 continue; 1036 continue;
1059 if (ranges_overlap(lkb, this) && !modes_compat(this, lkb)) 1037 if (!modes_compat(this, lkb))
1060 return 1; 1038 return 1;
1061 } 1039 }
1062 return 0; 1040 return 0;
@@ -1099,9 +1077,6 @@ static int conversion_deadlock_detect(struct dlm_rsb *rsb, struct dlm_lkb *lkb)
1099 continue; 1077 continue;
1100 } 1078 }
1101 1079
1102 if (!ranges_overlap(lkb, this))
1103 continue;
1104
1105 if (!modes_compat(this, lkb) && !modes_compat(lkb, this)) 1080 if (!modes_compat(this, lkb) && !modes_compat(lkb, this))
1106 return 1; 1081 return 1;
1107 } 1082 }
@@ -1203,8 +1178,8 @@ static int _can_be_granted(struct dlm_rsb *r, struct dlm_lkb *lkb, int now)
1203 return 1; 1178 return 1;
1204 1179
1205 /* 1180 /*
1206 * When using range locks the NOORDER flag is set to avoid the standard 1181 * The NOORDER flag is set to avoid the standard vms rules on grant
1207 * vms rules on grant order. 1182 * order.
1208 */ 1183 */
1209 1184
1210 if (lkb->lkb_exflags & DLM_LKF_NOORDER) 1185 if (lkb->lkb_exflags & DLM_LKF_NOORDER)
@@ -1358,8 +1333,7 @@ static void grant_pending_locks(struct dlm_rsb *r)
1358 /* 1333 /*
1359 * If there are locks left on the wait/convert queue then send blocking 1334 * If there are locks left on the wait/convert queue then send blocking
1360 * ASTs to granted locks based on the largest requested mode (high) 1335 * ASTs to granted locks based on the largest requested mode (high)
1361 * found above. This can generate spurious blocking ASTs for range 1336 * found above. FIXME: highbast < high comparison not valid for PR/CW.
1362 * locks. FIXME: highbast < high comparison not valid for PR/CW.
1363 */ 1337 */
1364 1338
1365 list_for_each_entry_safe(lkb, s, &r->res_grantqueue, lkb_statequeue) { 1339 list_for_each_entry_safe(lkb, s, &r->res_grantqueue, lkb_statequeue) {
@@ -1379,7 +1353,7 @@ static void send_bast_queue(struct dlm_rsb *r, struct list_head *head,
1379 list_for_each_entry(gr, head, lkb_statequeue) { 1353 list_for_each_entry(gr, head, lkb_statequeue) {
1380 if (gr->lkb_bastaddr && 1354 if (gr->lkb_bastaddr &&
1381 gr->lkb_highbast < lkb->lkb_rqmode && 1355 gr->lkb_highbast < lkb->lkb_rqmode &&
1382 ranges_overlap(lkb, gr) && !modes_compat(gr, lkb)) { 1356 !modes_compat(gr, lkb)) {
1383 queue_bast(r, gr, lkb->lkb_rqmode); 1357 queue_bast(r, gr, lkb->lkb_rqmode);
1384 gr->lkb_highbast = lkb->lkb_rqmode; 1358 gr->lkb_highbast = lkb->lkb_rqmode;
1385 } 1359 }
@@ -1530,8 +1504,7 @@ static void confirm_master(struct dlm_rsb *r, int error)
1530 1504
1531static int set_lock_args(int mode, struct dlm_lksb *lksb, uint32_t flags, 1505static int set_lock_args(int mode, struct dlm_lksb *lksb, uint32_t flags,
1532 int namelen, uint32_t parent_lkid, void *ast, 1506 int namelen, uint32_t parent_lkid, void *ast,
1533 void *astarg, void *bast, struct dlm_range *range, 1507 void *astarg, void *bast, struct dlm_args *args)
1534 struct dlm_args *args)
1535{ 1508{
1536 int rv = -EINVAL; 1509 int rv = -EINVAL;
1537 1510
@@ -1590,7 +1563,6 @@ static int set_lock_args(int mode, struct dlm_lksb *lksb, uint32_t flags,
1590 args->bastaddr = bast; 1563 args->bastaddr = bast;
1591 args->mode = mode; 1564 args->mode = mode;
1592 args->lksb = lksb; 1565 args->lksb = lksb;
1593 args->range = range;
1594 rv = 0; 1566 rv = 0;
1595 out: 1567 out:
1596 return rv; 1568 return rv;
@@ -1637,26 +1609,6 @@ static int validate_lock_args(struct dlm_ls *ls, struct dlm_lkb *lkb,
1637 lkb->lkb_lksb = args->lksb; 1609 lkb->lkb_lksb = args->lksb;
1638 lkb->lkb_lvbptr = args->lksb->sb_lvbptr; 1610 lkb->lkb_lvbptr = args->lksb->sb_lvbptr;
1639 lkb->lkb_ownpid = (int) current->pid; 1611 lkb->lkb_ownpid = (int) current->pid;
1640
1641 rv = 0;
1642 if (!args->range)
1643 goto out;
1644
1645 if (!lkb->lkb_range) {
1646 rv = -ENOMEM;
1647 lkb->lkb_range = allocate_range(ls);
1648 if (!lkb->lkb_range)
1649 goto out;
1650 /* This is needed for conversions that contain ranges
1651 where the original lock didn't but it's harmless for
1652 new locks too. */
1653 lkb->lkb_range[GR_RANGE_START] = 0LL;
1654 lkb->lkb_range[GR_RANGE_END] = 0xffffffffffffffffULL;
1655 }
1656
1657 lkb->lkb_range[RQ_RANGE_START] = args->range->ra_start;
1658 lkb->lkb_range[RQ_RANGE_END] = args->range->ra_end;
1659 lkb->lkb_flags |= DLM_IFL_RANGE;
1660 rv = 0; 1612 rv = 0;
1661 out: 1613 out:
1662 return rv; 1614 return rv;
@@ -1805,7 +1757,7 @@ static int _request_lock(struct dlm_rsb *r, struct dlm_lkb *lkb)
1805 return error; 1757 return error;
1806} 1758}
1807 1759
1808/* change some property of an existing lkb, e.g. mode, range */ 1760/* change some property of an existing lkb, e.g. mode */
1809 1761
1810static int _convert_lock(struct dlm_rsb *r, struct dlm_lkb *lkb) 1762static int _convert_lock(struct dlm_rsb *r, struct dlm_lkb *lkb)
1811{ 1763{
@@ -1962,8 +1914,7 @@ int dlm_lock(dlm_lockspace_t *lockspace,
1962 uint32_t parent_lkid, 1914 uint32_t parent_lkid,
1963 void (*ast) (void *astarg), 1915 void (*ast) (void *astarg),
1964 void *astarg, 1916 void *astarg,
1965 void (*bast) (void *astarg, int mode), 1917 void (*bast) (void *astarg, int mode))
1966 struct dlm_range *range)
1967{ 1918{
1968 struct dlm_ls *ls; 1919 struct dlm_ls *ls;
1969 struct dlm_lkb *lkb; 1920 struct dlm_lkb *lkb;
@@ -1985,7 +1936,7 @@ int dlm_lock(dlm_lockspace_t *lockspace,
1985 goto out; 1936 goto out;
1986 1937
1987 error = set_lock_args(mode, lksb, flags, namelen, parent_lkid, ast, 1938 error = set_lock_args(mode, lksb, flags, namelen, parent_lkid, ast,
1988 astarg, bast, range, &args); 1939 astarg, bast, &args);
1989 if (error) 1940 if (error)
1990 goto out_put; 1941 goto out_put;
1991 1942
@@ -2154,11 +2105,6 @@ static void send_args(struct dlm_rsb *r, struct dlm_lkb *lkb,
2154 if (lkb->lkb_astaddr) 2105 if (lkb->lkb_astaddr)
2155 ms->m_asts |= AST_COMP; 2106 ms->m_asts |= AST_COMP;
2156 2107
2157 if (lkb->lkb_range) {
2158 ms->m_range[0] = lkb->lkb_range[RQ_RANGE_START];
2159 ms->m_range[1] = lkb->lkb_range[RQ_RANGE_END];
2160 }
2161
2162 if (ms->m_type == DLM_MSG_REQUEST || ms->m_type == DLM_MSG_LOOKUP) 2108 if (ms->m_type == DLM_MSG_REQUEST || ms->m_type == DLM_MSG_LOOKUP)
2163 memcpy(ms->m_extra, r->res_name, r->res_length); 2109 memcpy(ms->m_extra, r->res_name, r->res_length);
2164 2110
@@ -2402,20 +2348,6 @@ static int receive_extralen(struct dlm_message *ms)
2402 return (ms->m_header.h_length - sizeof(struct dlm_message)); 2348 return (ms->m_header.h_length - sizeof(struct dlm_message));
2403} 2349}
2404 2350
2405static int receive_range(struct dlm_ls *ls, struct dlm_lkb *lkb,
2406 struct dlm_message *ms)
2407{
2408 if (lkb->lkb_flags & DLM_IFL_RANGE) {
2409 if (!lkb->lkb_range)
2410 lkb->lkb_range = allocate_range(ls);
2411 if (!lkb->lkb_range)
2412 return -ENOMEM;
2413 lkb->lkb_range[RQ_RANGE_START] = ms->m_range[0];
2414 lkb->lkb_range[RQ_RANGE_END] = ms->m_range[1];
2415 }
2416 return 0;
2417}
2418
2419static int receive_lvb(struct dlm_ls *ls, struct dlm_lkb *lkb, 2351static int receive_lvb(struct dlm_ls *ls, struct dlm_lkb *lkb,
2420 struct dlm_message *ms) 2352 struct dlm_message *ms)
2421{ 2353{
@@ -2445,9 +2377,6 @@ static int receive_request_args(struct dlm_ls *ls, struct dlm_lkb *lkb,
2445 2377
2446 DLM_ASSERT(is_master_copy(lkb), dlm_print_lkb(lkb);); 2378 DLM_ASSERT(is_master_copy(lkb), dlm_print_lkb(lkb););
2447 2379
2448 if (receive_range(ls, lkb, ms))
2449 return -ENOMEM;
2450
2451 if (receive_lvb(ls, lkb, ms)) 2380 if (receive_lvb(ls, lkb, ms))
2452 return -ENOMEM; 2381 return -ENOMEM;
2453 2382
@@ -2470,13 +2399,6 @@ static int receive_convert_args(struct dlm_ls *ls, struct dlm_lkb *lkb,
2470 if (lkb->lkb_status != DLM_LKSTS_GRANTED) 2399 if (lkb->lkb_status != DLM_LKSTS_GRANTED)
2471 return -EBUSY; 2400 return -EBUSY;
2472 2401
2473 if (receive_range(ls, lkb, ms))
2474 return -ENOMEM;
2475 if (lkb->lkb_range) {
2476 lkb->lkb_range[GR_RANGE_START] = 0LL;
2477 lkb->lkb_range[GR_RANGE_END] = 0xffffffffffffffffULL;
2478 }
2479
2480 if (receive_lvb(ls, lkb, ms)) 2402 if (receive_lvb(ls, lkb, ms))
2481 return -ENOMEM; 2403 return -ENOMEM;
2482 2404
@@ -3476,13 +3398,6 @@ static int receive_rcom_lock_args(struct dlm_ls *ls, struct dlm_lkb *lkb,
3476 lkb->lkb_bastaddr = (void *) (long) (rl->rl_asts & AST_BAST); 3398 lkb->lkb_bastaddr = (void *) (long) (rl->rl_asts & AST_BAST);
3477 lkb->lkb_astaddr = (void *) (long) (rl->rl_asts & AST_COMP); 3399 lkb->lkb_astaddr = (void *) (long) (rl->rl_asts & AST_COMP);
3478 3400
3479 if (lkb->lkb_flags & DLM_IFL_RANGE) {
3480 lkb->lkb_range = allocate_range(ls);
3481 if (!lkb->lkb_range)
3482 return -ENOMEM;
3483 memcpy(lkb->lkb_range, rl->rl_range, 4*sizeof(uint64_t));
3484 }
3485
3486 if (lkb->lkb_exflags & DLM_LKF_VALBLK) { 3401 if (lkb->lkb_exflags & DLM_LKF_VALBLK) {
3487 lkb->lkb_lvbptr = allocate_lvb(ls); 3402 lkb->lkb_lvbptr = allocate_lvb(ls);
3488 if (!lkb->lkb_lvbptr) 3403 if (!lkb->lkb_lvbptr)