piaojun
2017-Sep-23 03:39 UTC
[Ocfs2-devel] [patch 1/2] ocfs2/dlm: protect 'tracking_list' by 'track_lock'
'dlm->tracking_list' need to be protected by 'dlm->track_lock'. Signed-off-by: Jun Piao <piaojun at huawei.com> Reviewed-by: Alex Chen <alex.chen at huawei.com> --- fs/ocfs2/dlm/dlmdomain.c | 7 ++++++- fs/ocfs2/dlm/dlmmaster.c | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/fs/ocfs2/dlm/dlmdomain.c b/fs/ocfs2/dlm/dlmdomain.c index a2b19fb..b118525 100644 --- a/fs/ocfs2/dlm/dlmdomain.c +++ b/fs/ocfs2/dlm/dlmdomain.c @@ -726,12 +726,17 @@ void dlm_unregister_domain(struct dlm_ctxt *dlm) } /* This list should be empty. If not, print remaining lockres */ + spin_lock(&dlm->track_lock); if (!list_empty(&dlm->tracking_list)) { mlog(ML_ERROR, "Following lockres' are still on the " "tracking list:\n"); - list_for_each_entry(res, &dlm->tracking_list, tracking) + list_for_each_entry(res, &dlm->tracking_list, tracking) { + spin_unlock(&dlm->track_lock); dlm_print_one_lock_resource(res); + spin_lock(&dlm->track_lock); + } } + spin_unlock(&dlm->track_lock); dlm_mark_domain_leaving(dlm); dlm_leave_domain(dlm); diff --git a/fs/ocfs2/dlm/dlmmaster.c b/fs/ocfs2/dlm/dlmmaster.c index 3e04279..44e7d18 100644 --- a/fs/ocfs2/dlm/dlmmaster.c +++ b/fs/ocfs2/dlm/dlmmaster.c @@ -589,9 +589,9 @@ static void dlm_init_lockres(struct dlm_ctxt *dlm, res->last_used = 0; - spin_lock(&dlm->spinlock); + spin_lock(&dlm->track_lock); list_add_tail(&res->tracking, &dlm->tracking_list); - spin_unlock(&dlm->spinlock); + spin_unlock(&dlm->track_lock); memset(res->lvb, 0, DLM_LVB_LEN); memset(res->refmap, 0, sizeof(res->refmap)); --
Joseph Qi
2017-Sep-25 10:35 UTC
[Ocfs2-devel] [patch 1/2] ocfs2/dlm: protect 'tracking_list' by 'track_lock'
On 17/9/23 11:39, piaojun wrote:> 'dlm->tracking_list' need to be protected by 'dlm->track_lock'. > > Signed-off-by: Jun Piao <piaojun at huawei.com> > Reviewed-by: Alex Chen <alex.chen at huawei.com> > --- > fs/ocfs2/dlm/dlmdomain.c | 7 ++++++- > fs/ocfs2/dlm/dlmmaster.c | 4 ++-- > 2 files changed, 8 insertions(+), 3 deletions(-) > > diff --git a/fs/ocfs2/dlm/dlmdomain.c b/fs/ocfs2/dlm/dlmdomain.c > index a2b19fb..b118525 100644 > --- a/fs/ocfs2/dlm/dlmdomain.c > +++ b/fs/ocfs2/dlm/dlmdomain.c > @@ -726,12 +726,17 @@ void dlm_unregister_domain(struct dlm_ctxt *dlm) > } > > /* This list should be empty. If not, print remaining lockres */ > + spin_lock(&dlm->track_lock); > if (!list_empty(&dlm->tracking_list)) { > mlog(ML_ERROR, "Following lockres' are still on the " > "tracking list:\n"); > - list_for_each_entry(res, &dlm->tracking_list, tracking) > + list_for_each_entry(res, &dlm->tracking_list, tracking) { > + spin_unlock(&dlm->track_lock);Um... If we unlock here, the iterator still has chance to be corrupted. Thanks, Joseph> dlm_print_one_lock_resource(res); > + spin_lock(&dlm->track_lock); > + } > } > + spin_unlock(&dlm->track_lock); > > dlm_mark_domain_leaving(dlm); > dlm_leave_domain(dlm); > diff --git a/fs/ocfs2/dlm/dlmmaster.c b/fs/ocfs2/dlm/dlmmaster.c > index 3e04279..44e7d18 100644 > --- a/fs/ocfs2/dlm/dlmmaster.c > +++ b/fs/ocfs2/dlm/dlmmaster.c > @@ -589,9 +589,9 @@ static void dlm_init_lockres(struct dlm_ctxt *dlm, > > res->last_used = 0; > > - spin_lock(&dlm->spinlock); > + spin_lock(&dlm->track_lock); > list_add_tail(&res->tracking, &dlm->tracking_list); > - spin_unlock(&dlm->spinlock); > + spin_unlock(&dlm->track_lock); > > memset(res->lvb, 0, DLM_LVB_LEN); > memset(res->refmap, 0, sizeof(res->refmap)); >