From: David Teigland <teigland@redhat.com>
To: akpm@osdl.org
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH 3/7] dlm: fix unlock race
Date: Thu, 19 Jan 2006 15:30:50 -0600 [thread overview]
Message-ID: <20060119213050.GC31387@redhat.com> (raw)
Fix a race where an attempt to unlock a lock in the completion AST routine
could crash on SMP.
Signed-off-by: Patrick Caulfield <pcaulfie@redhat.com>
Signed-off-by: David Teigland <teigland@redhat.com>
Index: linux/drivers/dlm/device.c
===================================================================
--- linux.orig/drivers/dlm/device.c
+++ linux/drivers/dlm/device.c
@@ -53,6 +53,7 @@ static rwlock_t lockinfo_lock;
#define LI_FLAG_COMPLETE 1
#define LI_FLAG_FIRSTLOCK 2
#define LI_FLAG_PERSISTENT 3
+#define LI_FLAG_ONLIST 4
/* flags in ls_flags*/
#define LS_FLAG_DELETED 1
@@ -382,6 +383,7 @@ static void ast_routine(void *param)
spin_lock(&li->li_file->fi_li_lock);
list_del(&li->li_ownerqueue);
+ clear_bit(LI_FLAG_ONLIST, &li->li_flags);
spin_unlock(&li->li_file->fi_li_lock);
release_lockinfo(li);
return;
@@ -889,6 +891,7 @@ static int do_user_lock(struct file_info
spin_lock(&fi->fi_li_lock);
list_add(&li->li_ownerqueue, &fi->fi_li_list);
+ set_bit(LI_FLAG_ONLIST, &li->li_flags);
spin_unlock(&fi->fi_li_lock);
if (add_lockinfo(li))
printk(KERN_WARNING "Add lockinfo failed\n");
@@ -920,6 +923,7 @@ static int do_user_unlock(struct file_in
return -ENOMEM;
spin_lock(&fi->fi_li_lock);
list_add(&li->li_ownerqueue, &fi->fi_li_list);
+ set_bit(LI_FLAG_ONLIST, &li->li_flags);
spin_unlock(&fi->fi_li_lock);
}
@@ -934,6 +938,12 @@ static int do_user_unlock(struct file_in
if (kparams->flags & DLM_LKF_CANCEL && li->li_grmode != -1)
convert_cancel = 1;
+ /* Wait until dlm_lock() has completed */
+ if (!test_bit(LI_FLAG_ONLIST, &li->li_flags)) {
+ down(&li->li_firstlock);
+ up(&li->li_firstlock);
+ }
+
/* dlm_unlock() passes a 0 for castaddr which means don't overwrite
the existing li_castaddr as that's the completion routine for
unlocks. dlm_unlock_wait() specifies a new AST routine to be
@@ -949,6 +959,7 @@ static int do_user_unlock(struct file_in
if (!status && !convert_cancel) {
spin_lock(&fi->fi_li_lock);
list_del(&li->li_ownerqueue);
+ clear_bit(LI_FLAG_ONLIST, &li->li_flags);
spin_unlock(&fi->fi_li_lock);
}
reply other threads:[~2006-01-19 21:31 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20060119213050.GC31387@redhat.com \
--to=teigland@redhat.com \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.