From: Yu Jian Date: Fri, 13 Jul 2012 09:45:53 +0000 (+0800) Subject: LU-1129 obdfilter: handle race condition of recreating objects X-Git-Tag: 2.2.91~8 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=d42fdb3fa8965ce2c5223bec7caec9b202e5fe22 LU-1129 obdfilter: handle race condition of recreating objects During OST recovery, a race can happen while handling replayed OST_WRITE request during the MDS->OST orphan recovery period to recreate missing objects, which can trigger ASSERTION(diff >= 0) failure. This patch handles the above issue by adding obd->obd_recovering into the assertion to check whether the OST is in recovery or not. If it's in recovery and diff < 0, then no assertion failure occurs, the object has been recreated. If the OST is not in recovery and diff < 0, then the assertion failure occurs. Signed-off-by: Yu Jian Change-Id: If486bc8221cf4b9d53b6de53e8ec14a4f3174b45 Reviewed-on: http://review.whamcloud.com/3391 Tested-by: Hudson Tested-by: Maloo Reviewed-by: Mike Pershin Reviewed-by: Jinshan Xiong Reviewed-by: Oleg Drokin --- diff --git a/lustre/obdfilter/filter.c b/lustre/obdfilter/filter.c index 422db94..eb74491 100644 --- a/lustre/obdfilter/filter.c +++ b/lustre/obdfilter/filter.c @@ -3785,8 +3785,15 @@ static int filter_handle_precreate(struct obd_export *exp, struct obdo *oa, CDEBUG(D_RPCTRACE, "filter_last_id() = "LPU64" -> diff = %d\n", filter_last_id(filter, group), diff); - LASSERTF(diff >= 0,"%s: "LPU64" - "LPU64" = %d\n",obd->obd_name, - oa->o_id, filter_last_id(filter, group), diff); + /* + * Check obd->obd_recovering to handle the race condition + * while recreating missing precreated objects through + * filter_preprw_write() and mds_lov_clear_orphans() + * at the same time. + */ + LASSERTF(ergo(!obd->obd_recovering, diff >= 0), + "%s: "LPU64" - "LPU64" = %d\n", obd->obd_name, + oa->o_id, filter_last_id(filter, group), diff); } if (diff > 0) {