diff options
author | David Teigland <teigland@redhat.com> | 2007-04-02 13:12:55 -0400 |
---|---|---|
committer | Steven Whitehouse <swhiteho@redhat.com> | 2007-05-01 04:11:15 -0400 |
commit | ce03f12b37c0bd81ad707d3642241cc55c944711 (patch) | |
tree | 11f6eba9b44a29d0c203c99c47d351152d25529a /fs/dlm | |
parent | 72c2be776bd6eec5186e316e6d9dd4aab78d314d (diff) |
[DLM] change lkid format
A lock id is a uint32 and is used as an opaque reference to the lock. For
userland apps, the lkid is passed up, through libdlm, as the return value
from a write() on the dlm device. This created a problem when the high
bit was 1, making the lkid look like an error. This is fixed by changing
how the lkid is composed. The low 16 bits identified the hash bucket for
the lock and the high 16 bits were a per-bucket counter (which eventually
hit 0x8000 causing the problem). These are simply swapped around; the
number of hash table buckets is far below 0x8000, making all lkid's
positive when viewed as signed.
Signed-off-by: David Teigland <teigland@redhat.com>
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Diffstat (limited to 'fs/dlm')
-rw-r--r-- | fs/dlm/lock.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/fs/dlm/lock.c b/fs/dlm/lock.c index 9d26b3a39671..eac54d230fdc 100644 --- a/fs/dlm/lock.c +++ b/fs/dlm/lock.c | |||
@@ -580,7 +580,7 @@ static int create_lkb(struct dlm_ls *ls, struct dlm_lkb **lkb_ret) | |||
580 | /* counter can roll over so we must verify lkid is not in use */ | 580 | /* counter can roll over so we must verify lkid is not in use */ |
581 | 581 | ||
582 | while (lkid == 0) { | 582 | while (lkid == 0) { |
583 | lkid = bucket | (ls->ls_lkbtbl[bucket].counter++ << 16); | 583 | lkid = (bucket << 16) | ls->ls_lkbtbl[bucket].counter++; |
584 | 584 | ||
585 | list_for_each_entry(tmp, &ls->ls_lkbtbl[bucket].list, | 585 | list_for_each_entry(tmp, &ls->ls_lkbtbl[bucket].list, |
586 | lkb_idtbl_list) { | 586 | lkb_idtbl_list) { |
@@ -601,8 +601,8 @@ static int create_lkb(struct dlm_ls *ls, struct dlm_lkb **lkb_ret) | |||
601 | 601 | ||
602 | static struct dlm_lkb *__find_lkb(struct dlm_ls *ls, uint32_t lkid) | 602 | static struct dlm_lkb *__find_lkb(struct dlm_ls *ls, uint32_t lkid) |
603 | { | 603 | { |
604 | uint16_t bucket = lkid & 0xFFFF; | ||
605 | struct dlm_lkb *lkb; | 604 | struct dlm_lkb *lkb; |
605 | uint16_t bucket = (lkid >> 16); | ||
606 | 606 | ||
607 | list_for_each_entry(lkb, &ls->ls_lkbtbl[bucket].list, lkb_idtbl_list) { | 607 | list_for_each_entry(lkb, &ls->ls_lkbtbl[bucket].list, lkb_idtbl_list) { |
608 | if (lkb->lkb_id == lkid) | 608 | if (lkb->lkb_id == lkid) |
@@ -614,7 +614,7 @@ static struct dlm_lkb *__find_lkb(struct dlm_ls *ls, uint32_t lkid) | |||
614 | static int find_lkb(struct dlm_ls *ls, uint32_t lkid, struct dlm_lkb **lkb_ret) | 614 | static int find_lkb(struct dlm_ls *ls, uint32_t lkid, struct dlm_lkb **lkb_ret) |
615 | { | 615 | { |
616 | struct dlm_lkb *lkb; | 616 | struct dlm_lkb *lkb; |
617 | uint16_t bucket = lkid & 0xFFFF; | 617 | uint16_t bucket = (lkid >> 16); |
618 | 618 | ||
619 | if (bucket >= ls->ls_lkbtbl_size) | 619 | if (bucket >= ls->ls_lkbtbl_size) |
620 | return -EBADSLT; | 620 | return -EBADSLT; |
@@ -644,7 +644,7 @@ static void kill_lkb(struct kref *kref) | |||
644 | 644 | ||
645 | static int __put_lkb(struct dlm_ls *ls, struct dlm_lkb *lkb) | 645 | static int __put_lkb(struct dlm_ls *ls, struct dlm_lkb *lkb) |
646 | { | 646 | { |
647 | uint16_t bucket = lkb->lkb_id & 0xFFFF; | 647 | uint16_t bucket = (lkb->lkb_id >> 16); |
648 | 648 | ||
649 | write_lock(&ls->ls_lkbtbl[bucket].lock); | 649 | write_lock(&ls->ls_lkbtbl[bucket].lock); |
650 | if (kref_put(&lkb->lkb_ref, kill_lkb)) { | 650 | if (kref_put(&lkb->lkb_ref, kill_lkb)) { |