]> err.no Git - linux-2.6/blobdiff - fs/dlm/lock.c
[DLM] PATCH 2/3 dlm: lowcomms close
[linux-2.6] / fs / dlm / lock.c
index 29d3b95dbb63699224eaaeb53d70d31ed2e2e45a..85a0e73ba808cfa74a788e2f213485864a8e529e 100644 (file)
@@ -591,9 +591,11 @@ static void kill_lkb(struct kref *kref)
        DLM_ASSERT(!lkb->lkb_status, dlm_print_lkb(lkb););
 }
 
-static int put_lkb(struct dlm_lkb *lkb)
+/* __put_lkb() is used when an lkb may not have an rsb attached to
+   it so we need to provide the lockspace explicitly */
+
+static int __put_lkb(struct dlm_ls *ls, struct dlm_lkb *lkb)
 {
-       struct dlm_ls *ls = lkb->lkb_resource->res_ls;
        uint16_t bucket = lkb->lkb_id & 0xFFFF;
 
        write_lock(&ls->ls_lkbtbl[bucket].lock);
@@ -606,8 +608,6 @@ static int put_lkb(struct dlm_lkb *lkb)
                /* for local/process lkbs, lvbptr points to caller's lksb */
                if (lkb->lkb_lvbptr && is_master_copy(lkb))
                        free_lvb(lkb->lkb_lvbptr);
-               if (lkb->lkb_range)
-                       free_range(lkb->lkb_range);
                free_lkb(lkb);
                return 1;
        } else {
@@ -618,7 +618,13 @@ static int put_lkb(struct dlm_lkb *lkb)
 
 int dlm_put_lkb(struct dlm_lkb *lkb)
 {
-       return put_lkb(lkb);
+       struct dlm_ls *ls;
+
+       DLM_ASSERT(lkb->lkb_resource, dlm_print_lkb(lkb););
+       DLM_ASSERT(lkb->lkb_resource->res_ls, dlm_print_lkb(lkb););
+
+       ls = lkb->lkb_resource->res_ls;
+       return __put_lkb(ls, lkb);
 }
 
 /* This is only called to add a reference when the code already holds
@@ -988,11 +994,6 @@ static void _grant_lock(struct dlm_rsb *r, struct dlm_lkb *lkb)
        }
 
        lkb->lkb_rqmode = DLM_LOCK_IV;
-
-       if (lkb->lkb_range) {
-               lkb->lkb_range[GR_RANGE_START] = lkb->lkb_range[RQ_RANGE_START];
-               lkb->lkb_range[GR_RANGE_END] = lkb->lkb_range[RQ_RANGE_END];
-       }
 }
 
 static void grant_lock(struct dlm_rsb *r, struct dlm_lkb *lkb)
@@ -1032,21 +1033,6 @@ static inline int first_in_list(struct dlm_lkb *lkb, struct list_head *head)
        return 0;
 }
 
-/* Return 1 if the locks' ranges overlap.  If the lkb has no range then it is
-   assumed to cover 0-ffffffff.ffffffff */
-
-static inline int ranges_overlap(struct dlm_lkb *lkb1, struct dlm_lkb *lkb2)
-{
-       if (!lkb1->lkb_range || !lkb2->lkb_range)
-               return 1;
-
-       if (lkb1->lkb_range[RQ_RANGE_END] < lkb2->lkb_range[GR_RANGE_START] ||
-           lkb1->lkb_range[RQ_RANGE_START] > lkb2->lkb_range[GR_RANGE_END])
-               return 0;
-
-       return 1;
-}
-
 /* Check if the given lkb conflicts with another lkb on the queue. */
 
 static int queue_conflict(struct list_head *head, struct dlm_lkb *lkb)
@@ -1056,7 +1042,7 @@ static int queue_conflict(struct list_head *head, struct dlm_lkb *lkb)
        list_for_each_entry(this, head, lkb_statequeue) {
                if (this == lkb)
                        continue;
-               if (ranges_overlap(lkb, this) && !modes_compat(this, lkb))
+               if (!modes_compat(this, lkb))
                        return 1;
        }
        return 0;
@@ -1099,9 +1085,6 @@ static int conversion_deadlock_detect(struct dlm_rsb *rsb, struct dlm_lkb *lkb)
                        continue;
                }
 
-               if (!ranges_overlap(lkb, this))
-                       continue;
-
                if (!modes_compat(this, lkb) && !modes_compat(lkb, this))
                        return 1;
        }
@@ -1203,8 +1186,8 @@ static int _can_be_granted(struct dlm_rsb *r, struct dlm_lkb *lkb, int now)
                return 1;
 
        /*
-        * When using range locks the NOORDER flag is set to avoid the standard
-        * vms rules on grant order.
+        * The NOORDER flag is set to avoid the standard vms rules on grant
+        * order.
         */
 
        if (lkb->lkb_exflags & DLM_LKF_NOORDER)
@@ -1358,8 +1341,7 @@ static void grant_pending_locks(struct dlm_rsb *r)
        /*
         * If there are locks left on the wait/convert queue then send blocking
         * ASTs to granted locks based on the largest requested mode (high)
-        * found above.  This can generate spurious blocking ASTs for range
-        * locks. FIXME: highbast < high comparison not valid for PR/CW.
+        * found above. FIXME: highbast < high comparison not valid for PR/CW.
         */
 
        list_for_each_entry_safe(lkb, s, &r->res_grantqueue, lkb_statequeue) {
@@ -1379,7 +1361,7 @@ static void send_bast_queue(struct dlm_rsb *r, struct list_head *head,
        list_for_each_entry(gr, head, lkb_statequeue) {
                if (gr->lkb_bastaddr &&
                    gr->lkb_highbast < lkb->lkb_rqmode &&
-                   ranges_overlap(lkb, gr) && !modes_compat(gr, lkb)) {
+                   !modes_compat(gr, lkb)) {
                        queue_bast(r, gr, lkb->lkb_rqmode);
                        gr->lkb_highbast = lkb->lkb_rqmode;
                }
@@ -1530,8 +1512,7 @@ static void confirm_master(struct dlm_rsb *r, int error)
 
 static int set_lock_args(int mode, struct dlm_lksb *lksb, uint32_t flags,
                         int namelen, uint32_t parent_lkid, void *ast,
-                        void *astarg, void *bast, struct dlm_range *range,
-                        struct dlm_args *args)
+                        void *astarg, void *bast, struct dlm_args *args)
 {
        int rv = -EINVAL;
 
@@ -1590,7 +1571,6 @@ static int set_lock_args(int mode, struct dlm_lksb *lksb, uint32_t flags,
        args->bastaddr = bast;
        args->mode = mode;
        args->lksb = lksb;
-       args->range = range;
        rv = 0;
  out:
        return rv;
@@ -1637,26 +1617,6 @@ static int validate_lock_args(struct dlm_ls *ls, struct dlm_lkb *lkb,
        lkb->lkb_lksb = args->lksb;
        lkb->lkb_lvbptr = args->lksb->sb_lvbptr;
        lkb->lkb_ownpid = (int) current->pid;
-
-       rv = 0;
-       if (!args->range)
-               goto out;
-
-       if (!lkb->lkb_range) {
-               rv = -ENOMEM;
-               lkb->lkb_range = allocate_range(ls);
-               if (!lkb->lkb_range)
-                       goto out;
-               /* This is needed for conversions that contain ranges
-                  where the original lock didn't but it's harmless for
-                  new locks too. */
-               lkb->lkb_range[GR_RANGE_START] = 0LL;
-               lkb->lkb_range[GR_RANGE_END] = 0xffffffffffffffffULL;
-       }
-
-       lkb->lkb_range[RQ_RANGE_START] = args->range->ra_start;
-       lkb->lkb_range[RQ_RANGE_END] = args->range->ra_end;
-       lkb->lkb_flags |= DLM_IFL_RANGE;
        rv = 0;
  out:
        return rv;
@@ -1805,7 +1765,7 @@ static int _request_lock(struct dlm_rsb *r, struct dlm_lkb *lkb)
        return error;
 }
 
-/* change some property of an existing lkb, e.g. mode, range */
+/* change some property of an existing lkb, e.g. mode */
 
 static int _convert_lock(struct dlm_rsb *r, struct dlm_lkb *lkb)
 {
@@ -1962,8 +1922,7 @@ int dlm_lock(dlm_lockspace_t *lockspace,
             uint32_t parent_lkid,
             void (*ast) (void *astarg),
             void *astarg,
-            void (*bast) (void *astarg, int mode),
-            struct dlm_range *range)
+            void (*bast) (void *astarg, int mode))
 {
        struct dlm_ls *ls;
        struct dlm_lkb *lkb;
@@ -1985,7 +1944,7 @@ int dlm_lock(dlm_lockspace_t *lockspace,
                goto out;
 
        error = set_lock_args(mode, lksb, flags, namelen, parent_lkid, ast,
-                             astarg, bast, range, &args);
+                             astarg, bast, &args);
        if (error)
                goto out_put;
 
@@ -1998,7 +1957,7 @@ int dlm_lock(dlm_lockspace_t *lockspace,
                error = 0;
  out_put:
        if (convert || error)
-               put_lkb(lkb);
+               __put_lkb(ls, lkb);
        if (error == -EAGAIN)
                error = 0;
  out:
@@ -2040,7 +1999,7 @@ int dlm_unlock(dlm_lockspace_t *lockspace,
        if (error == -DLM_EUNLOCK || error == -DLM_ECANCEL)
                error = 0;
  out_put:
-       put_lkb(lkb);
+       dlm_put_lkb(lkb);
  out:
        unlock_recovery(ls);
        dlm_put_lockspace(ls);
@@ -2154,11 +2113,6 @@ static void send_args(struct dlm_rsb *r, struct dlm_lkb *lkb,
        if (lkb->lkb_astaddr)
                ms->m_asts |= AST_COMP;
 
-       if (lkb->lkb_range) {
-               ms->m_range[0] = lkb->lkb_range[RQ_RANGE_START];
-               ms->m_range[1] = lkb->lkb_range[RQ_RANGE_END];
-       }
-
        if (ms->m_type == DLM_MSG_REQUEST || ms->m_type == DLM_MSG_LOOKUP)
                memcpy(ms->m_extra, r->res_name, r->res_length);
 
@@ -2402,20 +2356,6 @@ static int receive_extralen(struct dlm_message *ms)
        return (ms->m_header.h_length - sizeof(struct dlm_message));
 }
 
-static int receive_range(struct dlm_ls *ls, struct dlm_lkb *lkb,
-                        struct dlm_message *ms)
-{
-       if (lkb->lkb_flags & DLM_IFL_RANGE) {
-               if (!lkb->lkb_range)
-                       lkb->lkb_range = allocate_range(ls);
-               if (!lkb->lkb_range)
-                       return -ENOMEM;
-               lkb->lkb_range[RQ_RANGE_START] = ms->m_range[0];
-               lkb->lkb_range[RQ_RANGE_END] = ms->m_range[1];
-       }
-       return 0;
-}
-
 static int receive_lvb(struct dlm_ls *ls, struct dlm_lkb *lkb,
                       struct dlm_message *ms)
 {
@@ -2445,9 +2385,6 @@ static int receive_request_args(struct dlm_ls *ls, struct dlm_lkb *lkb,
 
        DLM_ASSERT(is_master_copy(lkb), dlm_print_lkb(lkb););
 
-       if (receive_range(ls, lkb, ms))
-               return -ENOMEM;
-
        if (receive_lvb(ls, lkb, ms))
                return -ENOMEM;
 
@@ -2470,13 +2407,6 @@ static int receive_convert_args(struct dlm_ls *ls, struct dlm_lkb *lkb,
        if (lkb->lkb_status != DLM_LKSTS_GRANTED)
                return -EBUSY;
 
-       if (receive_range(ls, lkb, ms))
-               return -ENOMEM;
-       if (lkb->lkb_range) {
-               lkb->lkb_range[GR_RANGE_START] = 0LL;
-               lkb->lkb_range[GR_RANGE_END] = 0xffffffffffffffffULL;
-       }
-
        if (receive_lvb(ls, lkb, ms))
                return -ENOMEM;
 
@@ -2520,7 +2450,7 @@ static void receive_request(struct dlm_ls *ls, struct dlm_message *ms)
        lkb->lkb_flags |= DLM_IFL_MSTCPY;
        error = receive_request_args(ls, lkb, ms);
        if (error) {
-               put_lkb(lkb);
+               __put_lkb(ls, lkb);
                goto fail;
        }
 
@@ -2528,7 +2458,7 @@ static void receive_request(struct dlm_ls *ls, struct dlm_message *ms)
 
        error = find_rsb(ls, ms->m_extra, namelen, R_MASTER, &r);
        if (error) {
-               put_lkb(lkb);
+               __put_lkb(ls, lkb);
                goto fail;
        }
 
@@ -2544,7 +2474,7 @@ static void receive_request(struct dlm_ls *ls, struct dlm_message *ms)
        if (error == -EINPROGRESS)
                error = 0;
        if (error)
-               put_lkb(lkb);
+               dlm_put_lkb(lkb);
        return;
 
  fail:
@@ -2580,7 +2510,7 @@ static void receive_convert(struct dlm_ls *ls, struct dlm_message *ms)
 
        unlock_rsb(r);
        put_rsb(r);
-       put_lkb(lkb);
+       dlm_put_lkb(lkb);
        return;
 
  fail:
@@ -2614,7 +2544,7 @@ static void receive_unlock(struct dlm_ls *ls, struct dlm_message *ms)
 
        unlock_rsb(r);
        put_rsb(r);
-       put_lkb(lkb);
+       dlm_put_lkb(lkb);
        return;
 
  fail:
@@ -2644,7 +2574,7 @@ static void receive_cancel(struct dlm_ls *ls, struct dlm_message *ms)
 
        unlock_rsb(r);
        put_rsb(r);
-       put_lkb(lkb);
+       dlm_put_lkb(lkb);
        return;
 
  fail:
@@ -2676,7 +2606,7 @@ static void receive_grant(struct dlm_ls *ls, struct dlm_message *ms)
 
        unlock_rsb(r);
        put_rsb(r);
-       put_lkb(lkb);
+       dlm_put_lkb(lkb);
 }
 
 static void receive_bast(struct dlm_ls *ls, struct dlm_message *ms)
@@ -2701,7 +2631,7 @@ static void receive_bast(struct dlm_ls *ls, struct dlm_message *ms)
 
        unlock_rsb(r);
        put_rsb(r);
-       put_lkb(lkb);
+       dlm_put_lkb(lkb);
 }
 
 static void receive_lookup(struct dlm_ls *ls, struct dlm_message *ms)
@@ -2824,7 +2754,7 @@ static void receive_request_reply(struct dlm_ls *ls, struct dlm_message *ms)
        unlock_rsb(r);
        put_rsb(r);
  out:
-       put_lkb(lkb);
+       dlm_put_lkb(lkb);
 }
 
 static void __receive_convert_reply(struct dlm_rsb *r, struct dlm_lkb *lkb,
@@ -2891,7 +2821,7 @@ static void receive_convert_reply(struct dlm_ls *ls, struct dlm_message *ms)
 
        _receive_convert_reply(lkb, ms);
  out:
-       put_lkb(lkb);
+       dlm_put_lkb(lkb);
 }
 
 static void _receive_unlock_reply(struct dlm_lkb *lkb, struct dlm_message *ms)
@@ -2938,7 +2868,7 @@ static void receive_unlock_reply(struct dlm_ls *ls, struct dlm_message *ms)
 
        _receive_unlock_reply(lkb, ms);
  out:
-       put_lkb(lkb);
+       dlm_put_lkb(lkb);
 }
 
 static void _receive_cancel_reply(struct dlm_lkb *lkb, struct dlm_message *ms)
@@ -2985,7 +2915,7 @@ static void receive_cancel_reply(struct dlm_ls *ls, struct dlm_message *ms)
 
        _receive_cancel_reply(lkb, ms);
  out:
-       put_lkb(lkb);
+       dlm_put_lkb(lkb);
 }
 
 static void receive_lookup_reply(struct dlm_ls *ls, struct dlm_message *ms)
@@ -3032,7 +2962,7 @@ static void receive_lookup_reply(struct dlm_ls *ls, struct dlm_message *ms)
        unlock_rsb(r);
        put_rsb(r);
  out:
-       put_lkb(lkb);
+       dlm_put_lkb(lkb);
 }
 
 int dlm_receive_message(struct dlm_header *hd, int nodeid, int recovery)
@@ -3237,7 +3167,7 @@ void dlm_recover_waiters_pre(struct dlm_ls *ls)
                        ls->ls_stub_ms.m_result = -DLM_EUNLOCK;
                        _remove_from_waiters(lkb);
                        _receive_unlock_reply(lkb, &ls->ls_stub_ms);
-                       put_lkb(lkb);
+                       dlm_put_lkb(lkb);
                        break;
 
                case DLM_MSG_CANCEL:
@@ -3245,7 +3175,7 @@ void dlm_recover_waiters_pre(struct dlm_ls *ls)
                        ls->ls_stub_ms.m_result = -DLM_ECANCEL;
                        _remove_from_waiters(lkb);
                        _receive_cancel_reply(lkb, &ls->ls_stub_ms);
-                       put_lkb(lkb);
+                       dlm_put_lkb(lkb);
                        break;
 
                default:
@@ -3350,7 +3280,7 @@ static void purge_queue(struct dlm_rsb *r, struct list_head *queue,
                if (test(ls, lkb)) {
                        del_lkb(r, lkb);
                        /* this put should free the lkb */
-                       if (!put_lkb(lkb))
+                       if (!dlm_put_lkb(lkb))
                                log_error(ls, "purged lkb not released");
                }
        }
@@ -3476,13 +3406,6 @@ static int receive_rcom_lock_args(struct dlm_ls *ls, struct dlm_lkb *lkb,
        lkb->lkb_bastaddr = (void *) (long) (rl->rl_asts & AST_BAST);
        lkb->lkb_astaddr = (void *) (long) (rl->rl_asts & AST_COMP);
 
-       if (lkb->lkb_flags & DLM_IFL_RANGE) {
-               lkb->lkb_range = allocate_range(ls);
-               if (!lkb->lkb_range)
-                       return -ENOMEM;
-               memcpy(lkb->lkb_range, rl->rl_range, 4*sizeof(uint64_t));
-       }
-
        if (lkb->lkb_exflags & DLM_LKF_VALBLK) {
                lkb->lkb_lvbptr = allocate_lvb(ls);
                if (!lkb->lkb_lvbptr)
@@ -3541,7 +3464,7 @@ int dlm_recover_master_copy(struct dlm_ls *ls, struct dlm_rcom *rc)
 
        error = receive_rcom_lock_args(ls, lkb, r, rc);
        if (error) {
-               put_lkb(lkb);
+               __put_lkb(ls, lkb);
                goto out_unlock;
        }
 
@@ -3603,7 +3526,7 @@ int dlm_recover_process_copy(struct dlm_ls *ls, struct dlm_rcom *rc)
 
        unlock_rsb(r);
        put_rsb(r);
-       put_lkb(lkb);
+       dlm_put_lkb(lkb);
 
        return 0;
 }