Whamcloud - gitweb
LU-13974 llog: check stale osp object
[fs/lustre-release.git] / lustre / osp / osp_md_object.c
index 37ce566..2abaf95 100644 (file)
@@ -1089,6 +1089,7 @@ struct dt_object_operations osp_md_obj_ops = {
        .do_object_lock       = osp_md_object_lock,
        .do_object_unlock     = osp_md_object_unlock,
        .do_invalidate        = osp_invalidate,
+       .do_check_stale       = osp_check_stale,
 };
 
 /**
@@ -1127,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
  *
@@ -1167,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;
 
@@ -1240,7 +1264,7 @@ static ssize_t osp_md_read(const struct lu_env *env, struct dt_object *dt,
 
        /* allocate bulk descriptor */
        desc = ptlrpc_prep_bulk_imp(req, pages, 1,
-                                   PTLRPC_BULK_PUT_SINK | PTLRPC_BULK_BUF_KIOV,
+                                   PTLRPC_BULK_PUT_SINK,
                                    MDS_BULK_PORTAL,
                                    &ptlrpc_bulk_kiov_nopin_ops);
        if (desc == NULL)