From 81f7a3ceea4039f8f81d3aa009079aa27b3fb1b2 Mon Sep 17 00:00:00 2001 From: Bob Glossman Date: Tue, 4 Nov 2014 11:14:35 -0800 Subject: [PATCH] LU-5858 obdclass: eliminate NULL error return 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 Change-Id: I57ddb38abaec7caf57bb63a75dbd76e181ba72b2 Reviewed-on: http://review.whamcloud.com/12554 Tested-by: Jenkins Reviewed-by: Dmitry Eremin Reviewed-by: Fan Yong Reviewed-by: John L. Hammond Tested-by: Maloo Reviewed-by: Oleg Drokin --- lustre/lfsck/lfsck_internal.h | 15 ++------------- lustre/mdd/mdd_device.c | 2 -- lustre/obdclass/lu_object.c | 25 ++++++++++++++----------- 3 files changed, 16 insertions(+), 26 deletions(-) diff --git a/lustre/lfsck/lfsck_internal.h b/lustre/lfsck/lfsck_internal.h index 0e2312d..2e71189 100644 --- a/lustre/lfsck/lfsck_internal.h +++ b/lustre/lfsck/lfsck_internal.h @@ -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, diff --git a/lustre/mdd/mdd_device.c b/lustre/mdd/mdd_device.c index 0971cb7..3cc950b 100644 --- a/lustre/mdd/mdd_device.c +++ b/lustre/mdd/mdd_device.c @@ -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)); diff --git a/lustre/obdclass/lu_object.c b/lustre/obdclass/lu_object.c index 95d7192..75e422a 100644 --- a/lustre/obdclass/lu_object.c +++ b/lustre/obdclass/lu_object.c @@ -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); -- 1.8.3.1