diff options
author | David Teigland <teigland@redhat.com> | 2007-01-15 11:34:52 -0500 |
---|---|---|
committer | Steven Whitehouse <swhiteho@redhat.com> | 2007-02-05 13:36:55 -0500 |
commit | a1bc86e6bddd34362ca08a3a4d898eb4b5c15215 (patch) | |
tree | 92b30f8f9400c5a1b71a2e3a17397b9d0b2cc2f2 /fs/dlm/lock.c | |
parent | 1d6e8131cf0064ef5ab5f3411a82b800afbfadee (diff) |
[DLM] fix user unlocking
When a user process exits, we clear all the locks it holds. There is a
problem, though, with locks that the process had begun unlocking before it
exited. We couldn't find the lkb's that were in the process of being
unlocked remotely, to flag that they are DEAD. To solve this, we move
lkb's being unlocked onto a new list in the per-process structure that
tracks what locks the process is holding. We can then go through this
list to flag the necessary lkb's when clearing locks for a process when it
exits.
Signed-off-by: David Teigland <teigland@redhat.com>
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Diffstat (limited to 'fs/dlm/lock.c')
-rw-r--r-- | fs/dlm/lock.c | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/fs/dlm/lock.c b/fs/dlm/lock.c index 5bac9827ded3..6ad2b8eb96a5 100644 --- a/fs/dlm/lock.c +++ b/fs/dlm/lock.c | |||
@@ -3772,12 +3772,10 @@ int dlm_user_unlock(struct dlm_ls *ls, struct dlm_user_args *ua_tmp, | |||
3772 | goto out_put; | 3772 | goto out_put; |
3773 | 3773 | ||
3774 | spin_lock(&ua->proc->locks_spin); | 3774 | spin_lock(&ua->proc->locks_spin); |
3775 | list_del_init(&lkb->lkb_ownqueue); | 3775 | /* dlm_user_add_ast() may have already taken lkb off the proc list */ |
3776 | if (!list_empty(&lkb->lkb_ownqueue)) | ||
3777 | list_move(&lkb->lkb_ownqueue, &ua->proc->unlocking); | ||
3776 | spin_unlock(&ua->proc->locks_spin); | 3778 | spin_unlock(&ua->proc->locks_spin); |
3777 | |||
3778 | /* this removes the reference for the proc->locks list added by | ||
3779 | dlm_user_request */ | ||
3780 | unhold_lkb(lkb); | ||
3781 | out_put: | 3779 | out_put: |
3782 | dlm_put_lkb(lkb); | 3780 | dlm_put_lkb(lkb); |
3783 | out: | 3781 | out: |
@@ -3817,9 +3815,8 @@ int dlm_user_cancel(struct dlm_ls *ls, struct dlm_user_args *ua_tmp, | |||
3817 | /* this lkb was removed from the WAITING queue */ | 3815 | /* this lkb was removed from the WAITING queue */ |
3818 | if (lkb->lkb_grmode == DLM_LOCK_IV) { | 3816 | if (lkb->lkb_grmode == DLM_LOCK_IV) { |
3819 | spin_lock(&ua->proc->locks_spin); | 3817 | spin_lock(&ua->proc->locks_spin); |
3820 | list_del_init(&lkb->lkb_ownqueue); | 3818 | list_move(&lkb->lkb_ownqueue, &ua->proc->unlocking); |
3821 | spin_unlock(&ua->proc->locks_spin); | 3819 | spin_unlock(&ua->proc->locks_spin); |
3822 | unhold_lkb(lkb); | ||
3823 | } | 3820 | } |
3824 | out_put: | 3821 | out_put: |
3825 | dlm_put_lkb(lkb); | 3822 | dlm_put_lkb(lkb); |
@@ -3880,11 +3877,6 @@ void dlm_clear_proc_locks(struct dlm_ls *ls, struct dlm_user_proc *proc) | |||
3880 | mutex_lock(&ls->ls_clear_proc_locks); | 3877 | mutex_lock(&ls->ls_clear_proc_locks); |
3881 | 3878 | ||
3882 | list_for_each_entry_safe(lkb, safe, &proc->locks, lkb_ownqueue) { | 3879 | list_for_each_entry_safe(lkb, safe, &proc->locks, lkb_ownqueue) { |
3883 | if (lkb->lkb_ast_type) { | ||
3884 | list_del(&lkb->lkb_astqueue); | ||
3885 | unhold_lkb(lkb); | ||
3886 | } | ||
3887 | |||
3888 | list_del_init(&lkb->lkb_ownqueue); | 3880 | list_del_init(&lkb->lkb_ownqueue); |
3889 | 3881 | ||
3890 | if (lkb->lkb_exflags & DLM_LKF_PERSISTENT) { | 3882 | if (lkb->lkb_exflags & DLM_LKF_PERSISTENT) { |
@@ -3901,6 +3893,20 @@ void dlm_clear_proc_locks(struct dlm_ls *ls, struct dlm_user_proc *proc) | |||
3901 | 3893 | ||
3902 | dlm_put_lkb(lkb); | 3894 | dlm_put_lkb(lkb); |
3903 | } | 3895 | } |
3896 | |||
3897 | /* in-progress unlocks */ | ||
3898 | list_for_each_entry_safe(lkb, safe, &proc->unlocking, lkb_ownqueue) { | ||
3899 | list_del_init(&lkb->lkb_ownqueue); | ||
3900 | lkb->lkb_flags |= DLM_IFL_DEAD; | ||
3901 | dlm_put_lkb(lkb); | ||
3902 | } | ||
3903 | |||
3904 | list_for_each_entry_safe(lkb, safe, &proc->asts, lkb_astqueue) { | ||
3905 | list_del(&lkb->lkb_astqueue); | ||
3906 | dlm_put_lkb(lkb); | ||
3907 | } | ||
3908 | |||
3904 | mutex_unlock(&ls->ls_clear_proc_locks); | 3909 | mutex_unlock(&ls->ls_clear_proc_locks); |
3905 | unlock_recovery(ls); | 3910 | unlock_recovery(ls); |
3906 | } | 3911 | } |
3912 | |||