Whamcloud - gitweb
LU-6142 lustre: convert some container_of to *_safe 84/38384/2
authorMr NeilBrown <neilb@suse.de>
Mon, 27 Apr 2020 05:42:38 +0000 (15:42 +1000)
committerOleg Drokin <green@whamcloud.com>
Tue, 2 Jun 2020 04:28:16 +0000 (04:28 +0000)
Each of these uses of container_of0() cannot be determined from local
inspection to always received a valid pointer, so container_of()
cannot be used.
So convert them to the upstream standard container_of_safe().

Signed-off-by: Mr NeilBrown <neilb@suse.de>
Change-Id: I7d5551ae4d88bc931f7edbd3447b5bb2db8ce40c
Reviewed-on: https://review.whamcloud.com/38384
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Alex Zhuravlev <bzzz@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
14 files changed:
lustre/lfsck/lfsck_internal.h
lustre/llite/vvp_internal.h
lustre/lmv/lmv_internal.h
lustre/lod/lod_internal.h
lustre/mdd/mdd_internal.h
lustre/mdt/mdt_internal.h
lustre/mdt/mdt_mds.c
lustre/mgs/mgs_internal.h
lustre/obdecho/echo.c
lustre/obdecho/echo_client.c
lustre/ofd/ofd_internal.h
lustre/osp/lwp_dev.c
lustre/osp/osp_internal.h
lustre/quota/qmt_internal.h

index d491b2a..9292891 100644 (file)
@@ -1109,7 +1109,8 @@ extern struct lu_context_key lfsck_thread_key;
 
 static inline struct dt_device *lfsck_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 inline struct lfsck_thread_info *
index ce123d3..bb0d66e 100644 (file)
@@ -260,22 +260,22 @@ static inline struct lu_device *vvp2lu_dev(struct vvp_device *vdv)
 
 static inline struct vvp_device *lu2vvp_dev(const struct lu_device *d)
 {
-       return container_of0(d, struct vvp_device, vdv_cl.cd_lu_dev);
+       return container_of_safe(d, struct vvp_device, vdv_cl.cd_lu_dev);
 }
 
 static inline struct vvp_device *cl2vvp_dev(const struct cl_device *d)
 {
-       return container_of0(d, struct vvp_device, vdv_cl);
+       return container_of_safe(d, struct vvp_device, vdv_cl);
 }
 
 static inline struct vvp_object *cl2vvp(const struct cl_object *obj)
 {
-       return container_of0(obj, struct vvp_object, vob_cl);
+       return container_of_safe(obj, struct vvp_object, vob_cl);
 }
 
 static inline struct vvp_object *lu2vvp(const struct lu_object *obj)
 {
-       return container_of0(obj, struct vvp_object, vob_cl.co_lu);
+       return container_of_safe(obj, struct vvp_object, vob_cl.co_lu);
 }
 
 static inline struct inode *vvp_object_inode(const struct cl_object *obj)
index 340bd5a..c1b8a2a 100644 (file)
@@ -66,7 +66,7 @@ int lmv_statfs_check_update(struct obd_device *obd, struct lmv_tgt_desc *tgt);
 
 static inline struct obd_device *lmv2obd_dev(struct lmv_obd *lmv)
 {
-       return container_of0(lmv, struct obd_device, u.lmv);
+       return container_of_safe(lmv, struct obd_device, u.lmv);
 }
 
 static inline struct lu_tgt_desc *
index a371216..00fad0a 100644 (file)
@@ -404,7 +404,7 @@ static inline int lu_device_is_lod(struct lu_device *d)
 static inline struct lod_device* lu2lod_dev(struct lu_device *d)
 {
        LASSERT(lu_device_is_lod(d));
-       return container_of0(d, struct lod_device, lod_dt_dev.dd_lu_dev);
+       return container_of_safe(d, struct lod_device, lod_dt_dev.dd_lu_dev);
 }
 
 static inline struct lu_device *lod2lu_dev(struct lod_device *d)
@@ -426,7 +426,7 @@ static inline struct lod_device *dt2lod_dev(struct dt_device *d)
 static inline struct lod_object *lu2lod_obj(struct lu_object *o)
 {
        LASSERT(ergo(o != NULL, lu_device_is_lod(o->lo_dev)));
-       return container_of0(o, struct lod_object, ldo_obj.do_lu);
+       return container_of_safe(o, struct lod_object, ldo_obj.do_lu);
 }
 
 static inline struct lu_object *lod2lu_obj(struct lod_object *obj)
index 0fc99bd..a5bc753 100644 (file)
@@ -440,8 +440,8 @@ static inline int lu_device_is_mdd(struct lu_device *d)
 
 static inline struct mdd_device *lu2mdd_dev(struct lu_device *d)
 {
-        LASSERT(lu_device_is_mdd(d));
-        return container_of0(d, struct mdd_device, mdd_md_dev.md_lu_dev);
+       LASSERT(lu_device_is_mdd(d));
+       return container_of_safe(d, struct mdd_device, mdd_md_dev.md_lu_dev);
 }
 
 static inline struct lu_device *mdd2lu_dev(struct mdd_device *mdd)
@@ -451,18 +451,19 @@ static inline struct lu_device *mdd2lu_dev(struct mdd_device *mdd)
 
 static inline struct mdd_object *lu2mdd_obj(struct lu_object *o)
 {
-        LASSERT(ergo(o != NULL, lu_device_is_mdd(o->lo_dev)));
-        return container_of0(o, struct mdd_object, mod_obj.mo_lu);
+       LASSERT(ergo(o != NULL, lu_device_is_mdd(o->lo_dev)));
+       return container_of_safe(o, struct mdd_object,
+                                mod_obj.mo_lu);
 }
 
 static inline struct mdd_device *mdo2mdd(struct md_object *mdo)
 {
-        return lu2mdd_dev(mdo->mo_lu.lo_dev);
+       return lu2mdd_dev(mdo->mo_lu.lo_dev);
 }
 
 static inline struct mdd_object *md2mdd_obj(struct md_object *mdo)
 {
-       return container_of0(mdo, struct mdd_object, mod_obj);
+       return container_of_safe(mdo, struct mdd_object, mod_obj);
 }
 
 static inline const
index 99320fc..b9d32d6 100644 (file)
@@ -916,12 +916,12 @@ int mdt_pack_secctx_in_reply(struct mdt_thread_info *info,
 
 static inline struct mdt_device *mdt_dev(struct lu_device *d)
 {
-       return container_of0(d, struct mdt_device, mdt_lu_dev);
+       return container_of_safe(d, struct mdt_device, mdt_lu_dev);
 }
 
 static inline struct mdt_object *mdt_obj(struct lu_object *o)
 {
-       return container_of0(o, struct mdt_object, mot_obj);
+       return container_of_safe(o, struct mdt_object, mot_obj);
 }
 
 static inline struct dt_object *mdt_obj2dt(struct mdt_object *mo)
index 860cdf9..1c06518 100644 (file)
@@ -567,7 +567,7 @@ err_mds_svc:
 
 static inline struct mds_device *mds_dev(struct lu_device *d)
 {
-       return container_of0(d, struct mds_device, mds_md_dev.md_lu_dev);
+       return container_of_safe(d, struct mds_device, mds_md_dev.md_lu_dev);
 }
 
 static struct lu_device *mds_device_fini(const struct lu_env *env,
index b062f91..793f178 100644 (file)
@@ -330,7 +330,7 @@ static inline int lu_device_is_mgs(struct lu_device *d)
 static inline struct mgs_device* lu2mgs_dev(struct lu_device *d)
 {
        LASSERT(lu_device_is_mgs(d));
-       return container_of0(d, struct mgs_device, mgs_dt_dev.dd_lu_dev);
+       return container_of_safe(d, struct mgs_device, mgs_dt_dev.dd_lu_dev);
 }
 
 static inline struct mgs_device *exp2mgs_dev(struct obd_export *exp)
@@ -352,7 +352,7 @@ static inline struct mgs_device *dt2mgs_dev(struct dt_device *d)
 static inline struct mgs_object *lu2mgs_obj(struct lu_object *o)
 {
        LASSERT(ergo(o != NULL, lu_device_is_mgs(o->lo_dev)));
-       return container_of0(o, struct mgs_object, mgo_obj.do_lu);
+       return container_of_safe(o, struct mgs_object, mgo_obj.do_lu);
 }
 
 static inline struct lu_object *mgs2lu_obj(struct mgs_object *obj)
index f0978ad..e31d048 100644 (file)
@@ -68,7 +68,7 @@ struct echo_srv_device {
 
 static inline struct echo_srv_device *echo_srv_dev(struct lu_device *d)
 {
-       return container_of0(d, struct echo_srv_device, esd_dev);
+       return container_of_safe(d, struct echo_srv_device, esd_dev);
 }
 
 static inline struct obd_device *echo_srv_obd(struct echo_srv_device *esd)
index e25cae0..19e522a 100644 (file)
@@ -135,7 +135,7 @@ static int echo_client_cleanup(struct obd_device *obd);
  */
 static inline struct echo_device *cl2echo_dev(const struct cl_device *dev)
 {
-       return container_of0(dev, struct echo_device, ed_cl);
+       return container_of_safe(dev, struct echo_device, ed_cl);
 }
 
 static inline struct cl_device *echo_dev2cl(struct echo_device *d)
@@ -193,7 +193,8 @@ struct echo_object_conf *cl2echo_conf(const struct cl_object_conf *c)
 #ifdef HAVE_SERVER_SUPPORT
 static inline struct echo_md_device *lu2emd_dev(struct lu_device *d)
 {
-       return container_of0(d, struct echo_md_device, emd_md_dev.md_lu_dev);
+       return container_of_safe(d, struct echo_md_device,
+                                emd_md_dev.md_lu_dev);
 }
 
 static inline struct lu_device *emd2lu_dev(struct echo_md_device *d)
index bbe8cc2..9d06085 100644 (file)
@@ -166,7 +166,7 @@ struct ofd_device {
 
 static inline struct ofd_device *ofd_dev(struct lu_device *d)
 {
-       return container_of0(d, struct ofd_device, ofd_dt_dev.dd_lu_dev);
+       return container_of_safe(d, struct ofd_device, ofd_dt_dev.dd_lu_dev);
 }
 
 static inline struct obd_device *ofd_obd(struct ofd_device *ofd)
@@ -195,7 +195,7 @@ struct ofd_object {
 
 static inline struct ofd_object *ofd_obj(struct lu_object *o)
 {
-       return container_of0(o, struct ofd_object, ofo_obj.do_lu);
+       return container_of_safe(o, struct ofd_object, ofo_obj.do_lu);
 }
 
 static inline int ofd_object_exists(struct ofd_object *obj)
index 6fdf950..d8c83aa 100644 (file)
@@ -56,7 +56,7 @@ struct lwp_device {
 
 static inline struct lwp_device *lu2lwp_dev(struct lu_device *d)
 {
-       return container_of0(d, struct lwp_device, lpd_dev);
+       return container_of_safe(d, struct lwp_device, lpd_dev);
 }
 
 static inline struct lu_device *lwp2lu_dev(struct lwp_device *d)
index 5aadd7b..7246cd2 100644 (file)
@@ -460,7 +460,7 @@ static inline int lu_device_is_osp(struct lu_device *d)
 static inline struct osp_device *lu2osp_dev(struct lu_device *d)
 {
        LASSERT(lu_device_is_osp(d));
-       return container_of0(d, struct osp_device, opd_dt_dev.dd_lu_dev);
+       return container_of_safe(d, struct osp_device, opd_dt_dev.dd_lu_dev);
 }
 
 static inline struct lu_device *osp2lu_dev(struct osp_device *d)
@@ -471,13 +471,13 @@ static inline struct lu_device *osp2lu_dev(struct osp_device *d)
 static inline struct osp_device *dt2osp_dev(struct dt_device *d)
 {
        LASSERT(lu_device_is_osp(&d->dd_lu_dev));
-       return container_of0(d, struct osp_device, opd_dt_dev);
+       return container_of_safe(d, struct osp_device, opd_dt_dev);
 }
 
 static inline struct osp_object *lu2osp_obj(struct lu_object *o)
 {
        LASSERT(ergo(o != NULL, lu_device_is_osp(o->lo_dev)));
-       return container_of0(o, struct osp_object, opo_obj.do_lu);
+       return container_of_safe(o, struct osp_object, opo_obj.do_lu);
 }
 
 static inline struct lu_object *osp2lu_obj(struct osp_object *obj)
@@ -488,7 +488,7 @@ static inline struct lu_object *osp2lu_obj(struct osp_object *obj)
 static inline struct osp_object *osp_obj(const struct lu_object *o)
 {
        LASSERT(lu_device_is_osp(o->lo_dev));
-       return container_of0(o, struct osp_object, opo_obj.do_lu);
+       return container_of_safe(o, struct osp_object, opo_obj.do_lu);
 }
 
 static inline struct osp_object *dt2osp_obj(const struct dt_object *d)
index 423cda6..ba72a1e 100644 (file)
@@ -301,7 +301,7 @@ struct qmt_thread_info *qmt_info(const struct lu_env *env)
 /* helper routine to convert a lu_device into a qmt_device */
 static inline struct qmt_device *lu2qmt_dev(struct lu_device *ld)
 {
-       return container_of0(lu2dt_dev(ld), struct qmt_device, qmt_dt_dev);
+       return container_of_safe(lu2dt_dev(ld), struct qmt_device, qmt_dt_dev);
 }
 
 /* helper routine to convert a qmt_device into lu_device */