From 9e1071b517578ed3752efb1412017c8f93cd333b Mon Sep 17 00:00:00 2001 From: Alex Zhuravlev Date: Mon, 27 Apr 2020 10:24:33 +0300 Subject: [PATCH] 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 --- lustre/osp/osp_md_object.c | 23 +++++++++++++++++++++++ lustre/target/out_lib.c | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) 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; } -- 1.8.3.1