From: Mr NeilBrown Date: Mon, 27 Apr 2020 05:28:23 +0000 (+1000) Subject: LU-6142 obdclass: convert calls to container_of0() X-Git-Tag: 2.13.55~155 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=ebc793d7d4407177a7876e03776fc3727c174ff1 LU-6142 obdclass: convert calls to container_of0() Most calls to container_of8() in lustre/obdclass can be safely changed to container_of(), etiher because the pointer passed in is obviously not NULL (or error) from the context, or because the pointer returned is dereferenced without and checks. The only excepts are simple wrapped like dt2ls_dev(), lu2ls_obj(), scrub_obj2dev() where these is no context, so it is safest to convert to container_of_safe() instead. Signed-off-by: Mr NeilBrown Change-Id: Ice1063f3ccb74eaec575bff85c960f3288be5ef5 Reviewed-on: https://review.whamcloud.com/38381 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Mike Pershin Reviewed-by: James Simmons Reviewed-by: Oleg Drokin --- diff --git a/lustre/obdclass/dt_object.c b/lustre/obdclass/dt_object.c index eddcaa7..d334398 100644 --- a/lustre/obdclass/dt_object.c +++ b/lustre/obdclass/dt_object.c @@ -240,7 +240,7 @@ struct dt_object *dt_locate_at(const struct lu_env *env, list_for_each_entry(n, &lo->lo_header->loh_layers, lo_linkage) { if (n->lo_dev == &dev->dd_lu_dev) - return container_of0(n, struct dt_object, do_lu); + return container_of(n, struct dt_object, do_lu); } lu_object_put(env, lo); diff --git a/lustre/obdclass/local_storage.c b/lustre/obdclass/local_storage.c index c5d8935..cc3b0de 100644 --- a/lustre/obdclass/local_storage.c +++ b/lustre/obdclass/local_storage.c @@ -47,7 +47,7 @@ static int ls_object_init(const struct lu_env *env, struct lu_object *o, ENTRY; - ls = container_of0(o->lo_dev, struct ls_device, ls_top_dev.dd_lu_dev); + ls = container_of(o->lo_dev, struct ls_device, ls_top_dev.dd_lu_dev); under = &ls->ls_osd->dd_lu_dev; below = under->ld_ops->ldo_object_alloc(env, o->lo_header, under); if (below == NULL) diff --git a/lustre/obdclass/local_storage.h b/lustre/obdclass/local_storage.h index 7ff6faa..63af194 100644 --- a/lustre/obdclass/local_storage.h +++ b/lustre/obdclass/local_storage.h @@ -52,7 +52,7 @@ struct ls_device { static inline struct ls_device *dt2ls_dev(struct dt_device *d) { - return container_of0(d, struct ls_device, ls_top_dev); + return container_of_safe(d, struct ls_device, ls_top_dev); } struct ls_object { @@ -62,7 +62,7 @@ struct ls_object { static inline struct ls_object *lu2ls_obj(struct lu_object *o) { - return container_of0(o, struct ls_object, ls_obj.do_lu); + return container_of_safe(o, struct ls_object, ls_obj.do_lu); } static inline struct dt_object *ls_locate(const struct lu_env *env, diff --git a/lustre/obdclass/lu_object.c b/lustre/obdclass/lu_object.c index 62d4521..440767d 100644 --- a/lustre/obdclass/lu_object.c +++ b/lustre/obdclass/lu_object.c @@ -401,7 +401,7 @@ static void lu_object_free(const struct lu_env *env, struct lu_object *o) * lives as long as possible and ->loo_object_free() methods * can look at its contents. */ - o = container_of0(splice.prev, struct lu_object, lo_linkage); + o = container_of(splice.prev, struct lu_object, lo_linkage); list_del_init(&o->lo_linkage); LASSERT(o->lo_ops->loo_object_free != NULL); o->lo_ops->loo_object_free(env, o); @@ -673,7 +673,7 @@ static struct lu_object *htable_lookup(struct lu_site *s, return ERR_PTR(-ENOENT); } - h = container_of0(hnode, struct lu_object_header, loh_hash); + h = container_of(hnode, struct lu_object_header, loh_hash); if (!list_empty(&h->loh_lru)) { struct lu_site_bkt_data *bkt; diff --git a/lustre/obdclass/scrub.c b/lustre/obdclass/scrub.c index 0d8ad4b..fabb7bf 100644 --- a/lustre/obdclass/scrub.c +++ b/lustre/obdclass/scrub.c @@ -41,7 +41,8 @@ static inline struct dt_device *scrub_obj2dev(struct dt_object *obj) { - return container_of0(obj->do_lu.lo_dev, struct dt_device, dd_lu_dev); + return container_of_safe(obj->do_lu.lo_dev, struct dt_device, + dd_lu_dev); } static void scrub_file_to_cpu(struct scrub_file *des, struct scrub_file *src)