Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3bcd3687 authored by David Teigland's avatar David Teigland Committed by Steven Whitehouse
Browse files

[DLM] Remove range locks from the DLM



This patch removes support for range locking from the DLM

Signed-off-by: default avatarDavid Teigland <teigland@redhat.com>
Signed-off-by: default avatarSteven Whitehouse <swhiteho@redhat.com>
parent d35462b4
Loading
Loading
Loading
Loading
+0 −14
Original line number Original line Diff line number Diff line
@@ -59,20 +59,6 @@ static void print_lock(struct seq_file *s, struct dlm_lkb *lkb,
	    || lkb->lkb_status == DLM_LKSTS_WAITING)
	    || lkb->lkb_status == DLM_LKSTS_WAITING)
		seq_printf(s, " (%s)", print_lockmode(lkb->lkb_rqmode));
		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) {
		if (lkb->lkb_nodeid != res->res_nodeid)
		if (lkb->lkb_nodeid != res->res_nodeid)
			seq_printf(s, " Remote: %3d %08x", lkb->lkb_nodeid,
			seq_printf(s, " Remote: %3d %08x", lkb->lkb_nodeid,
+2 −4
Original line number Original line Diff line number Diff line
@@ -532,8 +532,7 @@ static int dlm_close(struct inode *inode, struct file *file)
			status = dlm_lock(f->fi_ls->ls_lockspace,
			status = dlm_lock(f->fi_ls->ls_lockspace,
					  old_li->li_grmode, &li.li_lksb,
					  old_li->li_grmode, &li.li_lksb,
					  DLM_LKF_CONVERT|DLM_LKF_ORPHAN,
					  DLM_LKF_CONVERT|DLM_LKF_ORPHAN,
					  NULL, 0, 0, ast_routine, NULL,
					  NULL, 0, 0, ast_routine, NULL, NULL);
					  NULL, NULL);
			if (status != 0)
			if (status != 0)
				printk("dlm: Error orphaning lock %x: %d\n",
				printk("dlm: Error orphaning lock %x: %d\n",
				       old_li->li_lksb.sb_lkid, status);
				       old_li->li_lksb.sb_lkid, status);
@@ -878,8 +877,7 @@ static int do_user_lock(struct file_info *fi, uint8_t cmd,
			  ast_routine,
			  ast_routine,
			  li,
			  li,
			  (li->li_pend_bastaddr || li->li_bastaddr) ?
			  (li->li_pend_bastaddr || li->li_bastaddr) ?
			   bast_routine : NULL,
			   bast_routine : NULL);
			  kparams->range.ra_end ? &kparams->range : NULL);
	if (status)
	if (status)
		goto out_err;
		goto out_err;


+0 −12
Original line number Original line Diff line number Diff line
@@ -146,7 +146,6 @@ struct dlm_args {
	void			*bastaddr;
	void			*bastaddr;
	int			mode;
	int			mode;
	struct dlm_lksb		*lksb;
	struct dlm_lksb		*lksb;
	struct dlm_range	*range;
};
};




@@ -195,13 +194,6 @@ struct dlm_args {
#define AST_COMP		1
#define AST_COMP		1
#define AST_BAST		2
#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 */
/* lkb_status */


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


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


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


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


@@ -413,7 +402,6 @@ struct rcom_lock {
	int8_t			rl_asts;
	int8_t			rl_asts;
	uint16_t		rl_wait_type;
	uint16_t		rl_wait_type;
	uint16_t		rl_namelen;
	uint16_t		rl_namelen;
	uint64_t		rl_range[4];
	char			rl_name[DLM_RESNAME_MAXLEN];
	char			rl_name[DLM_RESNAME_MAXLEN];
	char			rl_lvb[0];
	char			rl_lvb[0];
};
};
+9 −94
Original line number Original line Diff line number Diff line
@@ -606,8 +606,6 @@ static int put_lkb(struct dlm_lkb *lkb)
		/* for local/process lkbs, lvbptr points to caller's lksb */
		/* for local/process lkbs, lvbptr points to caller's lksb */
		if (lkb->lkb_lvbptr && is_master_copy(lkb))
		if (lkb->lkb_lvbptr && is_master_copy(lkb))
			free_lvb(lkb->lkb_lvbptr);
			free_lvb(lkb->lkb_lvbptr);
		if (lkb->lkb_range)
			free_range(lkb->lkb_range);
		free_lkb(lkb);
		free_lkb(lkb);
		return 1;
		return 1;
	} else {
	} else {
@@ -988,11 +986,6 @@ static void _grant_lock(struct dlm_rsb *r, struct dlm_lkb *lkb)
	}
	}


	lkb->lkb_rqmode = DLM_LOCK_IV;
	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)
static 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)
	return 0;
	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. */
/* Check if the given lkb conflicts with another lkb on the queue. */


static int queue_conflict(struct list_head *head, struct dlm_lkb *lkb)
static 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)
	list_for_each_entry(this, head, lkb_statequeue) {
	list_for_each_entry(this, head, lkb_statequeue) {
		if (this == lkb)
		if (this == lkb)
			continue;
			continue;
		if (ranges_overlap(lkb, this) && !modes_compat(this, lkb))
		if (!modes_compat(this, lkb))
			return 1;
			return 1;
	}
	}
	return 0;
	return 0;
@@ -1099,9 +1077,6 @@ static int conversion_deadlock_detect(struct dlm_rsb *rsb, struct dlm_lkb *lkb)
			continue;
			continue;
		}
		}


		if (!ranges_overlap(lkb, this))
			continue;

		if (!modes_compat(this, lkb) && !modes_compat(lkb, this))
		if (!modes_compat(this, lkb) && !modes_compat(lkb, this))
			return 1;
			return 1;
	}
	}
@@ -1203,8 +1178,8 @@ static int _can_be_granted(struct dlm_rsb *r, struct dlm_lkb *lkb, int now)
		return 1;
		return 1;


	/*
	/*
	 * When using range locks the NOORDER flag is set to avoid the standard
	 * The NOORDER flag is set to avoid the standard vms rules on grant
	 * vms rules on grant order.
	 * order.
	 */
	 */


	if (lkb->lkb_exflags & DLM_LKF_NOORDER)
	if (lkb->lkb_exflags & DLM_LKF_NOORDER)
@@ -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
	 * If there are locks left on the wait/convert queue then send blocking
	 * ASTs to granted locks based on the largest requested mode (high)
	 * ASTs to granted locks based on the largest requested mode (high)
	 * found above.  This can generate spurious blocking ASTs for range
	 * found above. FIXME: highbast < high comparison not valid for PR/CW.
	 * locks. FIXME: highbast < high comparison not valid for PR/CW.
	 */
	 */


	list_for_each_entry_safe(lkb, s, &r->res_grantqueue, lkb_statequeue) {
	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,
	list_for_each_entry(gr, head, lkb_statequeue) {
	list_for_each_entry(gr, head, lkb_statequeue) {
		if (gr->lkb_bastaddr &&
		if (gr->lkb_bastaddr &&
		    gr->lkb_highbast < lkb->lkb_rqmode &&
		    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);
			queue_bast(r, gr, lkb->lkb_rqmode);
			gr->lkb_highbast = lkb->lkb_rqmode;
			gr->lkb_highbast = lkb->lkb_rqmode;
		}
		}
@@ -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,
static int set_lock_args(int mode, struct dlm_lksb *lksb, uint32_t flags,
			 int namelen, uint32_t parent_lkid, void *ast,
			 int namelen, uint32_t parent_lkid, void *ast,
			 void *astarg, void *bast, struct dlm_range *range,
			 void *astarg, void *bast, struct dlm_args *args)
			 struct dlm_args *args)
{
{
	int rv = -EINVAL;
	int rv = -EINVAL;


@@ -1590,7 +1563,6 @@ static int set_lock_args(int mode, struct dlm_lksb *lksb, uint32_t flags,
	args->bastaddr = bast;
	args->bastaddr = bast;
	args->mode = mode;
	args->mode = mode;
	args->lksb = lksb;
	args->lksb = lksb;
	args->range = range;
	rv = 0;
	rv = 0;
 out:
 out:
	return rv;
	return rv;
@@ -1637,26 +1609,6 @@ static int validate_lock_args(struct dlm_ls *ls, struct dlm_lkb *lkb,
	lkb->lkb_lksb = args->lksb;
	lkb->lkb_lksb = args->lksb;
	lkb->lkb_lvbptr = args->lksb->sb_lvbptr;
	lkb->lkb_lvbptr = args->lksb->sb_lvbptr;
	lkb->lkb_ownpid = (int) current->pid;
	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;
	rv = 0;
 out:
 out:
	return rv;
	return rv;
@@ -1805,7 +1757,7 @@ static int _request_lock(struct dlm_rsb *r, struct dlm_lkb *lkb)
	return error;
	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)
static int _convert_lock(struct dlm_rsb *r, struct dlm_lkb *lkb)
{
{
@@ -1962,8 +1914,7 @@ int dlm_lock(dlm_lockspace_t *lockspace,
	     uint32_t parent_lkid,
	     uint32_t parent_lkid,
	     void (*ast) (void *astarg),
	     void (*ast) (void *astarg),
	     void *astarg,
	     void *astarg,
	     void (*bast) (void *astarg, int mode),
	     void (*bast) (void *astarg, int mode))
	     struct dlm_range *range)
{
{
	struct dlm_ls *ls;
	struct dlm_ls *ls;
	struct dlm_lkb *lkb;
	struct dlm_lkb *lkb;
@@ -1985,7 +1936,7 @@ int dlm_lock(dlm_lockspace_t *lockspace,
		goto out;
		goto out;


	error = set_lock_args(mode, lksb, flags, namelen, parent_lkid, ast,
	error = set_lock_args(mode, lksb, flags, namelen, parent_lkid, ast,
			      astarg, bast, range, &args);
			      astarg, bast, &args);
	if (error)
	if (error)
		goto out_put;
		goto out_put;


@@ -2154,11 +2105,6 @@ static void send_args(struct dlm_rsb *r, struct dlm_lkb *lkb,
	if (lkb->lkb_astaddr)
	if (lkb->lkb_astaddr)
		ms->m_asts |= AST_COMP;
		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)
	if (ms->m_type == DLM_MSG_REQUEST || ms->m_type == DLM_MSG_LOOKUP)
		memcpy(ms->m_extra, r->res_name, r->res_length);
		memcpy(ms->m_extra, r->res_name, r->res_length);


@@ -2402,20 +2348,6 @@ static int receive_extralen(struct dlm_message *ms)
	return (ms->m_header.h_length - sizeof(struct dlm_message));
	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,
static int receive_lvb(struct dlm_ls *ls, struct dlm_lkb *lkb,
		       struct dlm_message *ms)
		       struct dlm_message *ms)
{
{
@@ -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););
	DLM_ASSERT(is_master_copy(lkb), dlm_print_lkb(lkb););


	if (receive_range(ls, lkb, ms))
		return -ENOMEM;

	if (receive_lvb(ls, lkb, ms))
	if (receive_lvb(ls, lkb, ms))
		return -ENOMEM;
		return -ENOMEM;


@@ -2470,13 +2399,6 @@ static int receive_convert_args(struct dlm_ls *ls, struct dlm_lkb *lkb,
	if (lkb->lkb_status != DLM_LKSTS_GRANTED)
	if (lkb->lkb_status != DLM_LKSTS_GRANTED)
		return -EBUSY;
		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))
	if (receive_lvb(ls, lkb, ms))
		return -ENOMEM;
		return -ENOMEM;


@@ -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_bastaddr = (void *) (long) (rl->rl_asts & AST_BAST);
	lkb->lkb_astaddr = (void *) (long) (rl->rl_asts & AST_COMP);
	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) {
	if (lkb->lkb_exflags & DLM_LKF_VALBLK) {
		lkb->lkb_lvbptr = allocate_lvb(ls);
		lkb->lkb_lvbptr = allocate_lvb(ls);
		if (!lkb->lkb_lvbptr)
		if (!lkb->lkb_lvbptr)
+0 −16
Original line number Original line Diff line number Diff line
@@ -50,22 +50,6 @@ void free_lvb(char *p)
	kfree(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
/* FIXME: have some minimal space built-in to rsb for the name and
   kmalloc a separate name if needed, like dentries are done */
   kmalloc a separate name if needed, like dentries are done */


Loading