From: Bruno Faccini Date: Wed, 17 Jan 2018 15:22:58 +0000 (+0100) Subject: LU-10527 obdclass: don't recycle loghandle upon ENOSPC X-Git-Tag: 2.10.7-RC1~79 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=51e962be60cf599ecf154ea3a6b1c0f9882daac2;p=fs%2Flustre-release.git LU-10527 obdclass: don't recycle loghandle upon ENOSPC In llog_cat_add_rec(), upon -ENOSPC error being returned from llog_cat_new_log(), don't reset "cathandle->u.chd.chd_current_log" to NULL. Not doing so will avoid to have llog_cat_declare_add_rec() repeatedly and unnecessarily create new+partially initialized LLOGs/llog_handle and assigned to "cathandle->u.chd.chd_current_log", this without llog_init_handle() never being called to initialize "loghandle->lgh_hdr". Also, unnecessary LASSERT(llh) has been removed in llog_cat_current_log() as it prevented to gracefully handle this case by simply returning the loghandle. Thanks to S.Cheremencev (Cray) to report this. Both ways to fix have been kept in patch as the 1st part allows for better performance in terms of number of FS operations being done with permanent changelog's ENOSPC condition, even if this covers a somewhat unlikely situation. Lustre-commit: 5761b9576d39c44c02455b86eb86ce1276930e60 Lustre-change: https://review.whamcloud.com/30897 Signed-off-by: Bruno Faccini Change-Id: I526f788dc283fa7136ba518179d9337e1d5e3714 Reviewed-by: Sergey Cheremencev Reviewed-by: Alexandr Boyko Reviewed-by: Oleg Drokin Reviewed-on: https://review.whamcloud.com/33850 Tested-by: Jenkins Reviewed-by: Andreas Dilger Tested-by: Maloo --- diff --git a/lustre/obdclass/llog_cat.c b/lustre/obdclass/llog_cat.c index 058d87e..248eab5 100644 --- a/lustre/obdclass/llog_cat.c +++ b/lustre/obdclass/llog_cat.c @@ -386,8 +386,7 @@ static struct llog_handle *llog_cat_current_log(struct llog_handle *cathandle, down_write_nested(&loghandle->lgh_lock, LLOGH_LOG); llh = loghandle->lgh_hdr; - LASSERT(llh); - if (!llog_is_full(loghandle)) + if (llh == NULL || !llog_is_full(loghandle)) GOTO(out_unlock, loghandle); else up_write(&loghandle->lgh_lock); @@ -487,7 +486,12 @@ retry: up_write(&loghandle->lgh_lock); /* nobody should be trying to use this llog */ down_write(&cathandle->lgh_lock); - if (cathandle->u.chd.chd_current_log == loghandle) + /* only reset current log if still room in catalog, to + * avoid unnecessarily and racy creation of new and + * partially initialized llog_handle + */ + if ((cathandle->u.chd.chd_current_log == loghandle) && + rc != -ENOSPC) cathandle->u.chd.chd_current_log = NULL; up_write(&cathandle->lgh_lock); RETURN(rc);