Whamcloud - gitweb
LU-5416 ofd: improve error handling in ofd_precreate_objects() 70/11370/2
authorJohn L. Hammond <john.hammond@intel.com>
Thu, 7 Aug 2014 19:37:17 +0000 (14:37 -0500)
committerOleg Drokin <oleg.drokin@intel.com>
Wed, 24 Sep 2014 01:13:40 +0000 (01:13 +0000)
In ofd_precreate_objects() fix two invalid assertions triggered by
errors in the first iterations of the declare loop and the create
loop.

Signed-off-by: John L. Hammond <john.hammond@intel.com>
Change-Id: I8bee1528dc58d5b8b35ac89056c667370cc347c5
Reviewed-on: http://review.whamcloud.com/11370
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Alex Zhuravlev <alexey.zhuravlev@intel.com>
Reviewed-by: Mike Pershin <mike.pershin@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
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);
 
                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;
                }
                        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);
 
        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,
         /* 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);
 
                        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;
                                break;
+                       }
                        LASSERT(ofd_object_exists(fo));
                }
                ofd_seq_last_oid_set(oseq, id + i);
                        LASSERT(ofd_object_exists(fo));
                }
                ofd_seq_last_oid_set(oseq, id + i);