Whamcloud - gitweb
LU-5416 ofd: improve error handling in ofd_precreate_objects()
[fs/lustre-release.git] / lustre / ofd / ofd_objects.c
index b6fcd4a..245b5d8 100644 (file)
@@ -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,
@@ -362,8 +363,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);