Whamcloud - gitweb
LU-12616 obclass: fix MDS start/stop race
[fs/lustre-release.git] / lustre / ofd / ofd_lvb.c
index a48b4d5..8c6dfbe 100644 (file)
@@ -82,18 +82,16 @@ static int ofd_lvbo_free(struct ldlm_resource *res)
  * \retval             0 on successful setup
  * \retval             negative value on error
  */
-static int ofd_lvbo_init(const struct lu_env *env, struct ldlm_resource *res)
+static int ofd_lvbo_init(struct ldlm_resource *res)
 {
        struct ost_lvb          *lvb;
        struct ofd_device       *ofd;
        struct ofd_object       *fo;
        struct ofd_thread_info  *info;
-       int                      rc = 0;
-
+       struct lu_env *env;
+       int rc = 0;
        ENTRY;
 
-       LASSERT(env);
-       info = ofd_info(env);
        LASSERT(res);
        LASSERT(mutex_is_locked(&res->lr_lvb_mutex));
 
@@ -106,10 +104,14 @@ static int ofd_lvbo_init(const struct lu_env *env, struct ldlm_resource *res)
        if (OBD_FAIL_CHECK(OBD_FAIL_LDLM_OST_LVB))
                RETURN(-ENOMEM);
 
+       env = lu_env_find();
+       LASSERT(env);
+
        OBD_ALLOC_PTR(lvb);
        if (lvb == NULL)
                GOTO(out, rc = -ENOMEM);
 
+       info = ofd_info(env);
        res->lr_lvb_data = lvb;
        res->lr_lvb_len = sizeof(*lvb);
 
@@ -120,8 +122,24 @@ static int ofd_lvbo_init(const struct lu_env *env, struct ldlm_resource *res)
                GOTO(out_lvb, rc = PTR_ERR(fo));
 
        rc = ofd_attr_get(env, fo, &info->fti_attr);
-       if (rc)
+       if (rc) {
+               struct ofd_seq          *oseq;
+               __u64                    seq;
+
+               /* Object could be recreated during the first
+                * CLEANUP_ORPHAN request. */
+               if (rc == -ENOENT) {
+                       seq = fid_seq(&info->fti_fid);
+                       oseq = ofd_seq_load(env, ofd, fid_seq_is_idif(seq) ?
+                                           FID_SEQ_OST_MDT0 : seq);
+                       if (!IS_ERR_OR_NULL(oseq)) {
+                               if (!oseq->os_last_id_synced)
+                                       rc = -EAGAIN;
+                               ofd_seq_put(env, oseq);
+                       }
+               }
                GOTO(out_obj, rc);
+       }
 
        lvb->lvb_size = info->fti_attr.la_size;
        lvb->lvb_blocks = info->fti_attr.la_blocks;
@@ -176,18 +194,19 @@ out:
  * \retval             0 on successful setup
  * \retval             negative value on error
  */
-static int ofd_lvbo_update(const struct lu_env *env, struct ldlm_resource *res,
-                          struct ldlm_lock *lock, struct ptlrpc_request *req,
-                          int increase_only)
+static int ofd_lvbo_update(struct ldlm_resource *res, struct ldlm_lock *lock,
+                          struct ptlrpc_request *req, int increase_only)
 {
-       struct ofd_thread_info  *info;
-       struct ofd_device       *ofd;
-       struct ofd_object       *fo;
-       struct ost_lvb          *lvb;
-       int                      rc = 0;
+       struct ofd_thread_info *info;
+       struct ofd_device *ofd;
+       struct ofd_object *fo;
+       struct ost_lvb  *lvb;
+       const struct lu_env *env;
+       int rc = 0;
 
        ENTRY;
 
+       env = lu_env_find();
        LASSERT(env);
        info = ofd_info(env);
        LASSERT(res != NULL);
@@ -315,6 +334,7 @@ disk_update:
        }
        unlock_res(res);
 
+       info->fti_attr.la_valid = 0;
 out_obj:
        ofd_object_put(env, fo);
 out:
@@ -352,8 +372,7 @@ static int ofd_lvbo_size(struct ldlm_lock *lock)
  *
  * \retval             size of LVB data written into \a buf buffer
  */
-static int ofd_lvbo_fill(const struct lu_env *env, struct ldlm_lock *lock,
-                        void *buf, int *buflen)
+static int ofd_lvbo_fill(struct ldlm_lock *lock, void *buf, int *buflen)
 {
        struct ldlm_resource *res = lock->l_resource;
        int lvb_len;