mirror of https://gitee.com/openkylin/linux.git
ocfs2/dlm: fix a dead lock
When we have to take both dlm->master_lock and lockres->spinlock, take them in order lockres->spinlock and then dlm->master_lock. The patch fixes a violation of the rule. We can simply move taking dlm->master_lock to where we have dropped res->spinlock since when we access res->state and free mle memory we don't need master_lock's protection. Signed-off-by: Wengang Wang <wen.gang.wang@oracle.com> Cc: stable@kernel.org Signed-off-by: Joel Becker <joel.becker@oracle.com>
This commit is contained in:
parent
6eda3dd33f
commit
6d98c3ccb5
|
@ -3050,8 +3050,6 @@ int dlm_migrate_request_handler(struct o2net_msg *msg, u32 len, void *data,
|
||||||
/* check for pre-existing lock */
|
/* check for pre-existing lock */
|
||||||
spin_lock(&dlm->spinlock);
|
spin_lock(&dlm->spinlock);
|
||||||
res = __dlm_lookup_lockres(dlm, name, namelen, hash);
|
res = __dlm_lookup_lockres(dlm, name, namelen, hash);
|
||||||
spin_lock(&dlm->master_lock);
|
|
||||||
|
|
||||||
if (res) {
|
if (res) {
|
||||||
spin_lock(&res->spinlock);
|
spin_lock(&res->spinlock);
|
||||||
if (res->state & DLM_LOCK_RES_RECOVERING) {
|
if (res->state & DLM_LOCK_RES_RECOVERING) {
|
||||||
|
@ -3069,14 +3067,15 @@ int dlm_migrate_request_handler(struct o2net_msg *msg, u32 len, void *data,
|
||||||
spin_unlock(&res->spinlock);
|
spin_unlock(&res->spinlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
spin_lock(&dlm->master_lock);
|
||||||
/* ignore status. only nonzero status would BUG. */
|
/* ignore status. only nonzero status would BUG. */
|
||||||
ret = dlm_add_migration_mle(dlm, res, mle, &oldmle,
|
ret = dlm_add_migration_mle(dlm, res, mle, &oldmle,
|
||||||
name, namelen,
|
name, namelen,
|
||||||
migrate->new_master,
|
migrate->new_master,
|
||||||
migrate->master);
|
migrate->master);
|
||||||
|
|
||||||
unlock:
|
|
||||||
spin_unlock(&dlm->master_lock);
|
spin_unlock(&dlm->master_lock);
|
||||||
|
unlock:
|
||||||
spin_unlock(&dlm->spinlock);
|
spin_unlock(&dlm->spinlock);
|
||||||
|
|
||||||
if (oldmle) {
|
if (oldmle) {
|
||||||
|
|
Loading…
Reference in New Issue