Whamcloud - gitweb
LU-2445 lfs: fixed support for lfs migrate -b
[fs/lustre-release.git] / lustre / ofd / ofd_objects.c
index b6fcd4a..3aa18f5 100644 (file)
@@ -60,8 +60,8 @@
  * \retval             0 if version matches
  * \retval             -EOVERFLOW on version mismatch
  */
-int ofd_version_get_check(struct ofd_thread_info *info,
-                         struct ofd_object *fo)
+static int ofd_version_get_check(struct ofd_thread_info *info,
+                                struct ofd_object *fo)
 {
        dt_obj_version_t curr_version;
 
@@ -205,7 +205,7 @@ void ofd_object_put(const struct lu_env *env, struct ofd_object *fo)
  * \retval             negative value on error
  */
 int ofd_precreate_objects(const struct lu_env *env, struct ofd_device *ofd,
-                         obd_id id, struct ofd_seq *oseq, int nr, int sync)
+                         u64 id, struct ofd_seq *oseq, int nr, int sync)
 {
        struct ofd_thread_info  *info = ofd_info(env);
        struct ofd_object       *fo = NULL;
@@ -213,7 +213,7 @@ int ofd_precreate_objects(const struct lu_env *env, struct ofd_device *ofd,
        struct thandle          *th;
        struct ofd_object       **batch;
        struct lu_fid           *fid = &info->fti_fid;
-       obd_id                   tmp;
+       u64                      tmp;
        int                      rc;
        int                      i;
        int                      objects = 0;
@@ -305,7 +305,10 @@ int ofd_precreate_objects(const struct lu_env *env, struct ofd_device *ofd,
 
                rc = dt_declare_create(env, next, &info->fti_attr, NULL,
                                       &info->fti_dof, th);
-               if (rc) {
+               if (rc < 0) {
+                       if (i == 0)
+                               GOTO(trans_stop, rc);
+
                        nr = i;
                        break;
                }
@@ -318,8 +321,6 @@ int ofd_precreate_objects(const struct lu_env *env, struct ofd_device *ofd,
        CDEBUG(D_OTHER, "%s: create new object "DFID" nr %d\n",
               ofd_name(ofd), PFID(fid), nr);
 
-       LASSERT(nr > 0);
-
         /* When the LFSCK scanning the whole device to verify the LAST_ID file
          * consistency, it will load the last_id into RAM firstly, and compare
          * the last_id with each OST-object's ID. If the later one is larger,
@@ -349,10 +350,12 @@ int ofd_precreate_objects(const struct lu_env *env, struct ofd_device *ofd,
 
                /* Only the new created objects need to be recorded. */
                if (ofd->ofd_osd->dd_record_fid_accessed) {
-                       lfsck_pack_rfa(&ofd_info(env)->fti_lr,
-                                      lu_object_fid(&fo->ofo_obj.do_lu));
-                       lfsck_in_notify(env, ofd->ofd_osd,
-                                       &ofd_info(env)->fti_lr);
+                       struct lfsck_request *lr = &ofd_info(env)->fti_lr;
+
+                       lfsck_pack_rfa(lr, lu_object_fid(&fo->ofo_obj.do_lu),
+                                      LE_FID_ACCESSED,
+                                      LFSCK_TYPE_LAYOUT);
+                       lfsck_in_notify(env, ofd->ofd_osd, lr, NULL);
                }
 
                if (likely(!ofd_object_exists(fo) &&
@@ -362,8 +365,13 @@ int ofd_precreate_objects(const struct lu_env *env, struct ofd_device *ofd,
 
                        rc = dt_create(env, next, &info->fti_attr, NULL,
                                       &info->fti_dof, th);
-                       if (rc)
+                       if (rc < 0) {
+                               if (i == 0)
+                                       GOTO(trans_stop, rc);
+
+                               rc = 0;
                                break;
+                       }
                        LASSERT(ofd_object_exists(fo));
                }
                ofd_seq_last_oid_set(oseq, id + i);
@@ -608,12 +616,12 @@ int ofd_object_punch(const struct lu_env *env, struct ofd_object *fo,
        /* we support truncate, not punch yet */
        LASSERT(end == OBD_OBJECT_EOF);
 
+       ofd_write_lock(env, fo);
        fmd = ofd_fmd_get(info->fti_exp, &fo->ofo_header.loh_fid);
        if (fmd && fmd->fmd_mactime_xid < info->fti_xid)
                fmd->fmd_mactime_xid = info->fti_xid;
        ofd_fmd_put(info->fti_exp, fmd);
 
-       ofd_write_lock(env, fo);
        if (!ofd_object_exists(fo))
                GOTO(unlock, rc = -ENOENT);
 
@@ -731,8 +739,14 @@ int ofd_object_destroy(const struct lu_env *env, struct ofd_object *fo,
        if (IS_ERR(th))
                GOTO(unlock, rc = PTR_ERR(th));
 
-       dt_declare_ref_del(env, ofd_object_child(fo), th);
-       dt_declare_destroy(env, ofd_object_child(fo), th);
+       rc = dt_declare_ref_del(env, ofd_object_child(fo), th);
+       if (rc < 0)
+               GOTO(stop, rc);
+
+       rc = dt_declare_destroy(env, ofd_object_child(fo), th);
+       if (rc < 0)
+               GOTO(stop, rc);
+
        if (orphan)
                rc = dt_trans_start_local(env, ofd->ofd_osd, th);
        else