Whamcloud - gitweb
LU-13195 osp: invalidate object on write error 63/46863/3
authorAlex Zhuravlev <bzzz@whamcloud.com>
Mon, 27 Apr 2020 07:24:33 +0000 (10:24 +0300)
committerOleg Drokin <green@whamcloud.com>
Thu, 5 May 2022 06:10:07 +0000 (06:10 +0000)
do this unconditionally, to avoid cases when the object is
on another request's invalidation list.

Lustre-change: https://review.whamcloud.com/38387
Lustre-commit: 9e1071b517578ed3752efb1412017c8f93cd333b

Signed-off-by: Alex Zhuravlev <bzzz@whamcloud.com>
Change-Id: I8ee0c484e695e88c0ea6fb13ac377fa689150780
Reviewed-by: Alexander Boyko <alexander.boyko@hpe.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/46863
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 6646046..ae8ebc0 100644 (file)
@@ -1128,6 +1128,23 @@ static ssize_t osp_md_declare_write(const struct lu_env *env,
        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
  *
@@ -1168,6 +1185,12 @@ static ssize_t osp_md_write(const struct lu_env *env, struct dt_object *dt,
        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;
 
index e8ebf95..e7f9b62 100644 (file)
@@ -712,7 +712,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,
-                                           rc);
+                                           rc < 0 ? rc : 0);
 
        return rc > 0 ? 0 : rc;
 }