[GFS2] Speed up lock_dlm's locking (move sprintf)
The following patch speeds up lock_dlm's locking by moving the sprintf out from the lock acquisition path and into the lock creation path. This reduces the amount of CPU time used in acquiring locks by a fair amount. Signed-off-by: Steven Whitehouse <swhiteho@redhat.com> Acked-by: David Teigland <teigland@redhat.com>
This commit is contained in:
@@ -151,7 +151,7 @@ static inline unsigned int make_flags(struct gdlm_lock *lp,
|
|||||||
|
|
||||||
/* make_strname - convert GFS lock numbers to a string */
|
/* make_strname - convert GFS lock numbers to a string */
|
||||||
|
|
||||||
static inline void make_strname(struct lm_lockname *lockname,
|
static inline void make_strname(const struct lm_lockname *lockname,
|
||||||
struct gdlm_strname *str)
|
struct gdlm_strname *str)
|
||||||
{
|
{
|
||||||
sprintf(str->name, "%8x%16llx", lockname->ln_type,
|
sprintf(str->name, "%8x%16llx", lockname->ln_type,
|
||||||
@@ -169,6 +169,7 @@ static int gdlm_create_lp(struct gdlm_ls *ls, struct lm_lockname *name,
|
|||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
lp->lockname = *name;
|
lp->lockname = *name;
|
||||||
|
make_strname(name, &lp->strname);
|
||||||
lp->ls = ls;
|
lp->ls = ls;
|
||||||
lp->cur = DLM_LOCK_IV;
|
lp->cur = DLM_LOCK_IV;
|
||||||
lp->lvb = NULL;
|
lp->lvb = NULL;
|
||||||
@@ -227,7 +228,6 @@ void gdlm_put_lock(void *lock)
|
|||||||
unsigned int gdlm_do_lock(struct gdlm_lock *lp)
|
unsigned int gdlm_do_lock(struct gdlm_lock *lp)
|
||||||
{
|
{
|
||||||
struct gdlm_ls *ls = lp->ls;
|
struct gdlm_ls *ls = lp->ls;
|
||||||
struct gdlm_strname str;
|
|
||||||
int error, bast = 1;
|
int error, bast = 1;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -249,8 +249,6 @@ unsigned int gdlm_do_lock(struct gdlm_lock *lp)
|
|||||||
if (test_bit(LFL_NOBAST, &lp->flags))
|
if (test_bit(LFL_NOBAST, &lp->flags))
|
||||||
bast = 0;
|
bast = 0;
|
||||||
|
|
||||||
make_strname(&lp->lockname, &str);
|
|
||||||
|
|
||||||
set_bit(LFL_ACTIVE, &lp->flags);
|
set_bit(LFL_ACTIVE, &lp->flags);
|
||||||
|
|
||||||
log_debug("lk %x,%llx id %x %d,%d %x", lp->lockname.ln_type,
|
log_debug("lk %x,%llx id %x %d,%d %x", lp->lockname.ln_type,
|
||||||
@@ -258,8 +256,8 @@ unsigned int gdlm_do_lock(struct gdlm_lock *lp)
|
|||||||
lp->cur, lp->req, lp->lkf);
|
lp->cur, lp->req, lp->lkf);
|
||||||
|
|
||||||
error = dlm_lock(ls->dlm_lockspace, lp->req, &lp->lksb, lp->lkf,
|
error = dlm_lock(ls->dlm_lockspace, lp->req, &lp->lksb, lp->lkf,
|
||||||
str.name, str.namelen, 0, gdlm_ast, lp,
|
lp->strname.name, lp->strname.namelen, 0, gdlm_ast,
|
||||||
bast ? gdlm_bast : NULL);
|
lp, bast ? gdlm_bast : NULL);
|
||||||
|
|
||||||
if ((error == -EAGAIN) && (lp->lkf & DLM_LKF_NOQUEUE)) {
|
if ((error == -EAGAIN) && (lp->lkf & DLM_LKF_NOQUEUE)) {
|
||||||
lp->lksb.sb_status = -EAGAIN;
|
lp->lksb.sb_status = -EAGAIN;
|
||||||
|
@@ -106,6 +106,7 @@ enum {
|
|||||||
struct gdlm_lock {
|
struct gdlm_lock {
|
||||||
struct gdlm_ls *ls;
|
struct gdlm_ls *ls;
|
||||||
struct lm_lockname lockname;
|
struct lm_lockname lockname;
|
||||||
|
struct gdlm_strname strname;
|
||||||
char *lvb;
|
char *lvb;
|
||||||
struct dlm_lksb lksb;
|
struct dlm_lksb lksb;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user