Whamcloud - gitweb
LU-6142 obdclass: convert calls to container_of0() 81/38381/2
authorMr NeilBrown <neilb@suse.de>
Mon, 27 Apr 2020 05:28:23 +0000 (15:28 +1000)
committerOleg Drokin <green@whamcloud.com>
Wed, 10 Jun 2020 20:51:19 +0000 (20:51 +0000)
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 <neilb@suse.de>
Change-Id: Ice1063f3ccb74eaec575bff85c960f3288be5ef5
Reviewed-on: https://review.whamcloud.com/38381
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Mike Pershin <mpershin@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/obdclass/dt_object.c
lustre/obdclass/local_storage.c
lustre/obdclass/local_storage.h
lustre/obdclass/lu_object.c
lustre/obdclass/scrub.c

index eddcaa7..d334398 100644 (file)
@@ -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);
index c5d8935..cc3b0de 100644 (file)
@@ -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)
index 7ff6faa..63af194 100644 (file)
@@ -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,
index 62d4521..440767d 100644 (file)
@@ -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;
 
index 0d8ad4b..fabb7bf 100644 (file)
@@ -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)