Whamcloud - gitweb
LU-5858 obdclass: eliminate NULL error return 54/12554/4
authorBob Glossman <bob.glossman@intel.com>
Tue, 4 Nov 2014 19:14:35 +0000 (11:14 -0800)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 9 Dec 2014 08:12:25 +0000 (08:12 +0000)
Always return an ERR_PTR() on errors, never return a NULL,
in lu_object_find_slice().  Also clean up callers who
no longer need special case handling of NULL returns.

Signed-off-by: Bob Glossman <bob.glossman@intel.com>
Change-Id: I57ddb38abaec7caf57bb63a75dbd76e181ba72b2
Reviewed-on: http://review.whamcloud.com/12554
Tested-by: Jenkins
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Reviewed-by: Fan Yong <fan.yong@intel.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/lfsck/lfsck_internal.h
lustre/mdd/mdd_device.c
lustre/obdclass/lu_object.c

index 0e2312d..2e71189 100644 (file)
@@ -1165,27 +1165,16 @@ lfsck_object_find_by_dev_nowait(const struct lu_env *env, struct dt_device *dev,
                                const struct lu_fid *fid)
 {
        struct lu_object_conf   *conf = &lfsck_env_info(env)->lti_conf;
-       struct dt_object        *obj;
 
        conf->loc_flags = LOC_F_NOWAIT;
-       obj = lu2dt(lu_object_find_slice(env, dt2lu_dev(dev), fid, conf));
-       if (unlikely(obj == NULL))
-               return ERR_PTR(-ENOENT);
-
-       return obj;
+       return lu2dt(lu_object_find_slice(env, dt2lu_dev(dev), fid, conf));
 }
 
 static inline struct dt_object *
 lfsck_object_find_by_dev(const struct lu_env *env, struct dt_device *dev,
                         const struct lu_fid *fid)
 {
-       struct dt_object *obj;
-
-       obj = lu2dt(lu_object_find_slice(env, dt2lu_dev(dev), fid, NULL));
-       if (unlikely(obj == NULL))
-               return ERR_PTR(-ENOENT);
-
-       return obj;
+       return lu2dt(lu_object_find_slice(env, dt2lu_dev(dev), fid, NULL));
 }
 
 static inline struct dt_object *lfsck_object_find(const struct lu_env *env,
index 0971cb7..3cc950b 100644 (file)
@@ -578,8 +578,6 @@ static int obf_lookup(const struct lu_env *env, struct md_object *p,
 
         /* Check if object with this fid exists */
         child = mdd_object_find(env, mdd, f);
-        if (child == NULL)
-                GOTO(out, rc = 0);
         if (IS_ERR(child))
                 GOTO(out, rc = PTR_ERR(child));
 
index 95d7192..75e422a 100644 (file)
@@ -849,17 +849,20 @@ struct lu_object *lu_object_find_slice(const struct lu_env *env,
                                        const struct lu_fid *f,
                                        const struct lu_object_conf *conf)
 {
-        struct lu_object *top;
-        struct lu_object *obj;
-
-        top = lu_object_find(env, dev, f, conf);
-        if (!IS_ERR(top)) {
-                obj = lu_object_locate(top->lo_header, dev->ld_type);
-                if (obj == NULL)
-                        lu_object_put(env, top);
-        } else
-                obj = top;
-        return obj;
+       struct lu_object *top;
+       struct lu_object *obj;
+
+       top = lu_object_find(env, dev, f, conf);
+       if (IS_ERR(top))
+               return top;
+
+       obj = lu_object_locate(top->lo_header, dev->ld_type);
+       if (unlikely(obj == NULL)) {
+               lu_object_put(env, top);
+               obj = ERR_PTR(-ENOENT);
+       }
+
+       return obj;
 }
 EXPORT_SYMBOL(lu_object_find_slice);