Whamcloud - gitweb
LU-2179 osc: truncate partial page correctly
authorJinshan Xiong <jinshan.xiong@whamcloud.com>
Tue, 16 Oct 2012 19:35:40 +0000 (12:35 -0700)
committerOleg Drokin <green@whamcloud.com>
Fri, 19 Oct 2012 14:24:56 +0000 (10:24 -0400)
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 <jinshan.xiong@intel.com>
Change-Id: I3bf3a5f9b3d1b552eee7e5eae33c8777847b942d
Reviewed-on: http://review.whamcloud.com/4295
Reviewed-by: Niu Yawei <niu@whamcloud.com>
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/osc/osc_cache.c
lustre/osc/osc_cl_internal.h
lustre/osc/osc_io.c

index 6dc06a5..38b164d 100644 (file)
@@ -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);
index 7cf86b3..c8ec533 100644 (file)
@@ -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;
index c38dd76..58f8b71 100644 (file)
@@ -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 */