Whamcloud - gitweb
LU-13195 osp: invalidate object on write error 87/38387/4
authorAlex Zhuravlev <bzzz@whamcloud.com>
Mon, 27 Apr 2020 07:24:33 +0000 (10:24 +0300)
committerOleg Drokin <green@whamcloud.com>
Wed, 10 Jun 2020 20:51:23 +0000 (20:51 +0000)
do this unconditionally, to avoid cases when the object is
on another request's invalidation list.

Signed-off-by: Alex Zhuravlev <bzzz@whamcloud.com>
Change-Id: I8ee0c484e695e88c0ea6fb13ac377fa689150780
Reviewed-on: https://review.whamcloud.com/38387
Reviewed-by: Alexander Boyko <alexander.boyko@hpe.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/osp/osp_md_object.c
lustre/target/out_lib.c

index 61d0e82..b607b78 100644 (file)
@@ -1127,6 +1127,23 @@ static ssize_t osp_md_declare_write(const struct lu_env *env,
        return 0;
 }
 
        return 0;
 }
 
+static int osp_write_interpreter(const struct lu_env *env,
+                                 struct object_update_reply *reply,
+                                 struct ptlrpc_request *req,
+                                 struct osp_object *obj,
+                                 void *data, int index, int rc)
+{
+       if (rc) {
+               CDEBUG(D_HA, "error "DFID": rc = %d\n",
+                      PFID(lu_object_fid(&obj->opo_obj.do_lu)), rc);
+               spin_lock(&obj->opo_lock);
+               obj->opo_attr.la_valid = 0;
+               obj->opo_stale = 1;
+               spin_unlock(&obj->opo_lock);
+       }
+       return 0;
+}
+
 /**
  * Implementation of dt_body_operations::dbo_write
  *
 /**
  * Implementation of dt_body_operations::dbo_write
  *
@@ -1167,6 +1184,12 @@ static ssize_t osp_md_write(const struct lu_env *env, struct dt_object *dt,
        if (rc < 0)
                RETURN(rc);
 
        if (rc < 0)
                RETURN(rc);
 
+       /* to be able to invalidate object's state in case of an error */
+       rc = osp_insert_update_callback(env, update, obj, NULL,
+                       osp_write_interpreter);
+       if (rc < 0)
+               RETURN(rc);
+
        /* XXX: how about the write error happened later? */
        *pos += buf->lb_len;
 
        /* XXX: how about the write error happened later? */
        *pos += buf->lb_len;
 
index d42187f..63a1eb9 100644 (file)
@@ -707,7 +707,7 @@ static int out_tx_write_exec(const struct lu_env *env, struct thandle *th,
 
        if (arg->reply != NULL)
                object_update_result_insert(arg->reply, NULL, 0, arg->index,
 
        if (arg->reply != NULL)
                object_update_result_insert(arg->reply, NULL, 0, arg->index,
-                                           rc);
+                                           rc < 0 ? rc : 0);
 
        return rc > 0 ? 0 : rc;
 }
 
        return rc > 0 ? 0 : rc;
 }