From 799ed89ac8633b17f631cc13a3fb6fd90d8e958c Mon Sep 17 00:00:00 2001 From: "hongchao.zhang" Date: Sun, 8 May 2011 14:34:45 +0800 Subject: [PATCH] LU-328 unlock fo_llog_list_lock before allocating memory in filter_find_create_olg in filter.c, the spinlock filter->fo_llog_list_lock is held during allocating a new obd_llog_group, which cause system hang Change-Id: I1b95387fbaf6f9a7080073b8ee7918e46263f1f0 Signed-off-by: Hongchao Zhang Reviewed-on: http://review.whamcloud.com/556 Tested-by: Hudson Reviewed-by: Andreas Dilger Reviewed-by: Fan Yong --- lustre/obdfilter/filter.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/lustre/obdfilter/filter.c b/lustre/obdfilter/filter.c index 9b3b46c..c2b6d01 100644 --- a/lustre/obdfilter/filter.c +++ b/lustre/obdfilter/filter.c @@ -2465,7 +2465,7 @@ struct obd_llog_group *filter_find_olg(struct obd_device *obd, int group) */ struct obd_llog_group *filter_find_create_olg(struct obd_device *obd, int group) { - struct obd_llog_group *olg = NULL; + struct obd_llog_group *olg = NULL, *olg_new = NULL; struct filter_obd *filter; int rc; @@ -2474,6 +2474,10 @@ struct obd_llog_group *filter_find_create_olg(struct obd_device *obd, int group) if (group == FID_SEQ_LLOG) RETURN(&obd->obd_olg); + OBD_ALLOC_PTR(olg_new); + if (olg_new == NULL) + RETURN(ERR_PTR(-ENOMEM)); + cfs_spin_lock(&filter->fo_llog_list_lock); olg = filter_find_olg_internal(filter, group); if (olg) { @@ -2482,10 +2486,11 @@ struct obd_llog_group *filter_find_create_olg(struct obd_device *obd, int group) } else { GOTO(out_unlock, olg); } + } else { + /* set as the newly allocated one */ + olg = olg_new; + olg_new = NULL; } - OBD_ALLOC_PTR(olg); - if (olg == NULL) - GOTO(out_unlock, olg = ERR_PTR(-ENOMEM)); llog_group_init(olg, group); cfs_list_add(&olg->olg_list, &filter->fo_llog_list); @@ -2510,7 +2515,9 @@ out: out_unlock: cfs_spin_unlock(&filter->fo_llog_list_lock); - GOTO(out, olg); + if (olg_new) + OBD_FREE_PTR(olg_new); + goto out; } static int filter_llog_connect(struct obd_export *exp, -- 1.8.3.1