From: Alex Zhuravlev Date: Mon, 27 Apr 2020 07:24:33 +0000 (+0300) Subject: LU-13195 osp: invalidate object on write error X-Git-Tag: 2.13.55~154 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=refs%2Fchanges%2F87%2F38387%2F4;p=fs%2Flustre-release.git LU-13195 osp: invalidate object on write error do this unconditionally, to avoid cases when the object is on another request's invalidation list. Signed-off-by: Alex Zhuravlev Change-Id: I8ee0c484e695e88c0ea6fb13ac377fa689150780 Reviewed-on: https://review.whamcloud.com/38387 Reviewed-by: Alexander Boyko Reviewed-by: Andreas Dilger Tested-by: jenkins Tested-by: Maloo Reviewed-by: Oleg Drokin --- diff --git a/lustre/osp/osp_md_object.c b/lustre/osp/osp_md_object.c index 61d0e82..b607b78 100644 --- a/lustre/osp/osp_md_object.c +++ b/lustre/osp/osp_md_object.c @@ -1127,6 +1127,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 * @@ -1167,6 +1184,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; diff --git a/lustre/target/out_lib.c b/lustre/target/out_lib.c index d42187f..63a1eb9 100644 --- a/lustre/target/out_lib.c +++ b/lustre/target/out_lib.c @@ -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, - rc); + rc < 0 ? rc : 0); return rc > 0 ? 0 : rc; }