Skip to content

Commit

Permalink
[DLM] Remove range locks from the DLM
Browse files Browse the repository at this point in the history
This patch removes support for range locking from the DLM

Signed-off-by: David Teigland <teigland@redhat.com>
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
  • Loading branch information
David Teigland authored and Steven Whitehouse committed Feb 23, 2006
1 parent d35462b commit 3bcd368
Show file tree
Hide file tree
Showing 10 changed files with 13 additions and 170 deletions.
14 changes: 0 additions & 14 deletions fs/dlm/debug_fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,6 @@ static void print_lock(struct seq_file *s, struct dlm_lkb *lkb,
|| lkb->lkb_status == DLM_LKSTS_WAITING)
seq_printf(s, " (%s)", print_lockmode(lkb->lkb_rqmode));

if (lkb->lkb_range) {
/* FIXME: this warns on Alpha */
if (lkb->lkb_status == DLM_LKSTS_CONVERT
|| lkb->lkb_status == DLM_LKSTS_GRANTED)
seq_printf(s, " %llx-%llx",
lkb->lkb_range[GR_RANGE_START],
lkb->lkb_range[GR_RANGE_END]);
if (lkb->lkb_status == DLM_LKSTS_CONVERT
|| lkb->lkb_status == DLM_LKSTS_WAITING)
seq_printf(s, " (%llx-%llx)",
lkb->lkb_range[RQ_RANGE_START],
lkb->lkb_range[RQ_RANGE_END]);
}

if (lkb->lkb_nodeid) {
if (lkb->lkb_nodeid != res->res_nodeid)
seq_printf(s, " Remote: %3d %08x", lkb->lkb_nodeid,
Expand Down
6 changes: 2 additions & 4 deletions fs/dlm/device.c
Original file line number Diff line number Diff line change
Expand Up @@ -532,8 +532,7 @@ static int dlm_close(struct inode *inode, struct file *file)
status = dlm_lock(f->fi_ls->ls_lockspace,
old_li->li_grmode, &li.li_lksb,
DLM_LKF_CONVERT|DLM_LKF_ORPHAN,
NULL, 0, 0, ast_routine, NULL,
NULL, NULL);
NULL, 0, 0, ast_routine, NULL, NULL);
if (status != 0)
printk("dlm: Error orphaning lock %x: %d\n",
old_li->li_lksb.sb_lkid, status);
Expand Down Expand Up @@ -878,8 +877,7 @@ static int do_user_lock(struct file_info *fi, uint8_t cmd,
ast_routine,
li,
(li->li_pend_bastaddr || li->li_bastaddr) ?
bast_routine : NULL,
kparams->range.ra_end ? &kparams->range : NULL);
bast_routine : NULL);
if (status)
goto out_err;

Expand Down
12 changes: 0 additions & 12 deletions fs/dlm/dlm_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ struct dlm_args {
void *bastaddr;
int mode;
struct dlm_lksb *lksb;
struct dlm_range *range;
};


Expand Down Expand Up @@ -195,13 +194,6 @@ struct dlm_args {
#define AST_COMP 1
#define AST_BAST 2

/* lkb_range[] */

#define GR_RANGE_START 0
#define GR_RANGE_END 1
#define RQ_RANGE_START 2
#define RQ_RANGE_END 3

/* lkb_status */

#define DLM_LKSTS_WAITING 1
Expand All @@ -212,7 +204,6 @@ struct dlm_args {

#define DLM_IFL_MSTCPY 0x00010000
#define DLM_IFL_RESEND 0x00020000
#define DLM_IFL_RANGE 0x00000001

struct dlm_lkb {
struct dlm_rsb *lkb_resource; /* the rsb */
Expand Down Expand Up @@ -241,7 +232,6 @@ struct dlm_lkb {
struct list_head lkb_wait_reply; /* waiting for remote reply */
struct list_head lkb_astqueue; /* need ast to be sent */

uint64_t *lkb_range; /* array of gr/rq ranges */
char *lkb_lvbptr;
struct dlm_lksb *lkb_lksb; /* caller's status block */
void *lkb_astaddr; /* caller's ast function */
Expand Down Expand Up @@ -360,7 +350,6 @@ struct dlm_message {
int m_bastmode;
int m_asts;
int m_result; /* 0 or -EXXX */
uint64_t m_range[2];
char m_extra[0]; /* name or lvb */
};

Expand Down Expand Up @@ -413,7 +402,6 @@ struct rcom_lock {
int8_t rl_asts;
uint16_t rl_wait_type;
uint16_t rl_namelen;
uint64_t rl_range[4];
char rl_name[DLM_RESNAME_MAXLEN];
char rl_lvb[0];
};
Expand Down
103 changes: 9 additions & 94 deletions fs/dlm/lock.c
Original file line number Diff line number Diff line change
Expand Up @@ -606,8 +606,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 {
Expand Down Expand Up @@ -988,11 +986,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)
Expand Down Expand Up @@ -1032,21 +1025,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)
Expand All @@ -1056,7 +1034,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;
Expand Down Expand Up @@ -1099,9 +1077,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;
}
Expand Down Expand Up @@ -1203,8 +1178,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)
Expand Down Expand Up @@ -1358,8 +1333,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) {
Expand All @@ -1379,7 +1353,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;
}
Expand Down Expand Up @@ -1530,8 +1504,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;

Expand Down Expand Up @@ -1590,7 +1563,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;
Expand Down Expand Up @@ -1637,26 +1609,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;
Expand Down Expand Up @@ -1805,7 +1757,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)
{
Expand Down Expand Up @@ -1962,8 +1914,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;
Expand All @@ -1985,7 +1936,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;

Expand Down Expand Up @@ -2154,11 +2105,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);

Expand Down Expand Up @@ -2402,20 +2348,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)
{
Expand Down Expand Up @@ -2445,9 +2377,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;

Expand All @@ -2470,13 +2399,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;

Expand Down Expand Up @@ -3476,13 +3398,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)
Expand Down
16 changes: 0 additions & 16 deletions fs/dlm/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,22 +50,6 @@ void free_lvb(char *p)
kfree(p);
}

uint64_t *allocate_range(struct dlm_ls *ls)
{
int ralen = 4*sizeof(uint64_t);
uint64_t *p;

p = kmalloc(ralen, GFP_KERNEL);
if (p)
memset(p, 0, ralen);
return p;
}

void free_range(uint64_t *p)
{
kfree(p);
}

/* FIXME: have some minimal space built-in to rsb for the name and
kmalloc a separate name if needed, like dentries are done */

Expand Down
2 changes: 0 additions & 2 deletions fs/dlm/memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ struct dlm_direntry *allocate_direntry(struct dlm_ls *ls, int namelen);
void free_direntry(struct dlm_direntry *de);
char *allocate_lvb(struct dlm_ls *ls);
void free_lvb(char *l);
uint64_t *allocate_range(struct dlm_ls *ls);
void free_range(uint64_t *l);

#endif /* __MEMORY_DOT_H__ */

3 changes: 0 additions & 3 deletions fs/dlm/rcom.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,6 @@ static void pack_rcom_lock(struct dlm_rsb *r, struct dlm_lkb *lkb,
if (lkb->lkb_astaddr)
rl->rl_asts |= AST_COMP;

if (lkb->lkb_range)
memcpy(rl->rl_range, lkb->lkb_range, 4*sizeof(uint64_t));

rl->rl_namelen = r->res_length;
memcpy(rl->rl_name, r->res_name, r->res_length);

Expand Down
Loading

0 comments on commit 3bcd368

Please sign in to comment.