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>
list_for_each_entry(n, &lo->lo_header->loh_layers, lo_linkage) {
if (n->lo_dev == &dev->dd_lu_dev)
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);
}
lu_object_put(env, lo);
- 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)
under = &ls->ls_osd->dd_lu_dev;
below = under->ld_ops->ldo_object_alloc(env, o->lo_header, under);
if (below == NULL)
static inline struct ls_device *dt2ls_dev(struct dt_device *d)
{
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);
static inline struct ls_object *lu2ls_obj(struct lu_object *o)
{
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,
}
static inline struct dt_object *ls_locate(const struct lu_env *env,
* lives as long as possible and ->loo_object_free() methods
* can look at its contents.
*/
* 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);
list_del_init(&o->lo_linkage);
LASSERT(o->lo_ops->loo_object_free != NULL);
o->lo_ops->loo_object_free(env, o);
return ERR_PTR(-ENOENT);
}
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;
if (!list_empty(&h->loh_lru)) {
struct lu_site_bkt_data *bkt;
static inline struct dt_device *scrub_obj2dev(struct dt_object *obj)
{
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)
}
static void scrub_file_to_cpu(struct scrub_file *des, struct scrub_file *src)