From 771ae2cdd70699b0f52616e0e07b96ee8afb1f17 Mon Sep 17 00:00:00 2001 From: Alexander Boyko Date: Wed, 4 Jul 2018 06:41:52 -0400 Subject: [PATCH] LU-11116 llog: error handling cleanup llog_cat_new_log() needs some error handling cleanup. Save and restore thread lgi_cookie when using, to prevent conflict/corruptions with llog_process_thread(). Signed-off-by: Alexander Boyko Change-Id: I12fdfe1a72e77cfeb5ad464b8582db68a7bcfe16 Cray-bug-id: LUS-4780 Reviewed-on: https://review.whamcloud.com/32780 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Andriy Skulysh Reviewed-by: Andreas Dilger Reviewed-by: Mike Pershin Reviewed-by: Oleg Drokin --- lustre/obdclass/llog.c | 8 ++++++++ lustre/obdclass/llog_cat.c | 4 +++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lustre/obdclass/llog.c b/lustre/obdclass/llog.c index 274ba97..53887ae 100644 --- a/lustre/obdclass/llog.c +++ b/lustre/obdclass/llog.c @@ -198,6 +198,7 @@ int llog_cancel_rec(const struct lu_env *env, struct llog_handle *loghandle, struct dt_device *dt; struct llog_log_hdr *llh; struct thandle *th; + __u32 tmp_lgc_index; int rc; int rc1; bool subtract_count = false; @@ -249,12 +250,19 @@ int llog_cancel_rec(const struct lu_env *env, struct llog_handle *loghandle, loghandle->lgh_hdr->llh_count--; subtract_count = true; + + /* Since llog_process_thread use lgi_cookie, it`s better to save them + * and restore after using + */ + tmp_lgc_index = lgi->lgi_cookie.lgc_index; /* Pass this index to llog_osd_write_rec(), which will use the index * to only update the necesary bitmap. */ lgi->lgi_cookie.lgc_index = index; /* update header */ rc = llog_write_rec(env, loghandle, &llh->llh_hdr, &lgi->lgi_cookie, LLOG_HEADER_IDX, th); + lgi->lgi_cookie.lgc_index = tmp_lgc_index; + if (rc != 0) GOTO(out_unlock, rc); diff --git a/lustre/obdclass/llog_cat.c b/lustre/obdclass/llog_cat.c index ec28fa8..59a0950 100644 --- a/lustre/obdclass/llog_cat.c +++ b/lustre/obdclass/llog_cat.c @@ -213,8 +213,10 @@ out_destroy: loghandle->lgh_hdr->llh_flags &= ~LLOG_F_ZAP_WHEN_EMPTY; /* this is to mimic full log, so another llog_cat_current_log() * can skip it and ask for another onet */ - loghandle->lgh_last_idx = LLOG_HDR_BITMAP_SIZE(llh) + 1; + loghandle->lgh_last_idx = LLOG_HDR_BITMAP_SIZE(loghandle->lgh_hdr) + 1; llog_trans_destroy(env, loghandle, th); + if (handle != NULL) + dt_trans_stop(env, dt, handle); RETURN(rc); } -- 1.8.3.1