From 9c61a7c0dd558e08a39c13a620d1e3e968d8484a Mon Sep 17 00:00:00 2001 From: Jinshan Xiong Date: Tue, 16 Oct 2012 12:35:40 -0700 Subject: [PATCH] LU-2179 osc: truncate partial page correctly Debug patch for osc_extent_wait() and don't wait for completion of RPC it's not even sent in truncate. Signed-off-by: Jinshan Xiong Change-Id: I3bf3a5f9b3d1b552eee7e5eae33c8777847b942d Reviewed-on: http://review.whamcloud.com/4295 Reviewed-by: Niu Yawei Tested-by: Hudson Tested-by: Maloo Reviewed-by: Oleg Drokin --- lustre/osc/osc_cache.c | 20 ++++++++++++++++++-- lustre/osc/osc_cl_internal.h | 1 + lustre/osc/osc_io.c | 10 ++++++---- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/lustre/osc/osc_cache.c b/lustre/osc/osc_cache.c index 6dc06a55..38b164d 100644 --- a/lustre/osc/osc_cache.c +++ b/lustre/osc/osc_cache.c @@ -845,6 +845,17 @@ int osc_extent_finish(const struct lu_env *env, struct osc_extent *ext, RETURN(0); } +static int extent_wait_cb(struct osc_extent *ext, int state) +{ + int ret; + + osc_object_lock(ext->oe_obj); + ret = ext->oe_state == state; + osc_object_unlock(ext->oe_obj); + + return ret; +} + /** * Wait for the extent's state to become @state. */ @@ -852,7 +863,8 @@ static int osc_extent_wait(const struct lu_env *env, struct osc_extent *ext, int state) { struct osc_object *obj = ext->oe_obj; - struct l_wait_info lwi = LWI_INTR(LWI_ON_SIGNAL_NOOP, NULL); + struct l_wait_info lwi = LWI_TIMEOUT_INTR(cfs_time_seconds(600), NULL, + LWI_ON_SIGNAL_NOOP, NULL); int rc = 0; ENTRY; @@ -874,7 +886,11 @@ static int osc_extent_wait(const struct lu_env *env, struct osc_extent *ext, osc_extent_release(env, ext); /* wait for the extent until its state becomes @state */ - rc = l_wait_event(ext->oe_waitq, ext->oe_state == state, &lwi); + rc = l_wait_event(ext->oe_waitq, extent_wait_cb(ext, state), &lwi); + if (rc == -ETIMEDOUT) { + OSC_EXTENT_DUMP(D_ERROR, ext, "wait ext %d timedout\n", state); + LBUG(); + } if (rc == 0 && ext->oe_rc < 0) rc = ext->oe_rc; RETURN(rc); diff --git a/lustre/osc/osc_cl_internal.h b/lustre/osc/osc_cl_internal.h index 7cf86b3..c8ec533 100644 --- a/lustre/osc/osc_cl_internal.h +++ b/lustre/osc/osc_cl_internal.h @@ -82,6 +82,7 @@ struct osc_io { struct obd_info oi_info; struct obdo oi_oa; struct osc_async_cbargs { + bool opc_rpc_sent; int opc_rc; cfs_completion_t opc_sync; } oi_cbarg; diff --git a/lustre/osc/osc_io.c b/lustre/osc/osc_io.c index c38dd76..58f8b71 100644 --- a/lustre/osc/osc_io.c +++ b/lustre/osc/osc_io.c @@ -482,6 +482,7 @@ static int osc_io_setattr_start(const struct lu_env *env, &oinfo, NULL, osc_async_upcall, cbargs, PTLRPCD_SET); + cbargs->opc_rpc_sent = result == 0; } return result; } @@ -493,11 +494,12 @@ static void osc_io_setattr_end(const struct lu_env *env, struct osc_io *oio = cl2osc_io(env, slice); struct cl_object *obj = slice->cis_obj; struct osc_async_cbargs *cbargs = &oio->oi_cbarg; - int result; - - cfs_wait_for_completion(&cbargs->opc_sync); + int result = 0; - result = io->ci_result = cbargs->opc_rc; + if (cbargs->opc_rpc_sent) { + cfs_wait_for_completion(&cbargs->opc_sync); + result = io->ci_result = cbargs->opc_rc; + } if (result == 0) { if (oio->oi_lockless) { /* lockless truncate */ -- 1.8.3.1