From d42fdb3fa8965ce2c5223bec7caec9b202e5fe22 Mon Sep 17 00:00:00 2001 From: Yu Jian Date: Fri, 13 Jul 2012 17:45:53 +0800 Subject: [PATCH] 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 --- lustre/obdfilter/filter.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) 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) { -- 1.8.3.1