aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/lustre/lustre/osc
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.com>2018-03-29 15:26:48 +1100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-04-23 15:16:58 +0200
commit05e6557b8ed833546ee2b66ce6b58fecf09f439e (patch)
treea2cd87c97111677ec5a30d5f82260482c1d64f9f /drivers/staging/lustre/lustre/osc
parentstaging: lustre: rearrange placement of CPU partition management code. (diff)
downloadlinux-dev-05e6557b8ed833546ee2b66ce6b58fecf09f439e.tar.xz
linux-dev-05e6557b8ed833546ee2b66ce6b58fecf09f439e.zip
staging: lustre: add container_of_safe()
Luster has a container_of0() function which is similar to container_of() but passes an IS_ERR_OR_NULL() pointer through unchanged. This could be generally useful: bcache at last has a similar function. Naming is hard, but the precedent set by hlist_entry_safe() suggests a _safe suffix might be most consistent. So add container_of_safe() to kernel.h, and replace all occurrences of container_of0() with one of - list_first_entry, list_next_entry, when that is a better fit, - container_of(), when the pointer is used as a validpointer in surrounding code, - container_of_safe() when there is no obviously better alternative. Signed-off-by: NeilBrown <neilb@suse.com> Reviewed-by: James Simmons <jsimmons@infradead.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/lustre/lustre/osc')
-rw-r--r--drivers/staging/lustre/lustre/osc/osc_cl_internal.h10
-rw-r--r--drivers/staging/lustre/lustre/osc/osc_internal.h2
-rw-r--r--drivers/staging/lustre/lustre/osc/osc_io.c2
-rw-r--r--drivers/staging/lustre/lustre/osc/osc_object.c2
4 files changed, 8 insertions, 8 deletions
diff --git a/drivers/staging/lustre/lustre/osc/osc_cl_internal.h b/drivers/staging/lustre/lustre/osc/osc_cl_internal.h
index 1449013722f6..dc25dd12d7d5 100644
--- a/drivers/staging/lustre/lustre/osc/osc_cl_internal.h
+++ b/drivers/staging/lustre/lustre/osc/osc_cl_internal.h
@@ -460,7 +460,7 @@ static inline int osc_is_object(const struct lu_object *obj)
static inline struct osc_device *lu2osc_dev(const struct lu_device *d)
{
LINVRNT(d->ld_type == &osc_device_type);
- return container_of0(d, struct osc_device, od_cl.cd_lu_dev);
+ return container_of(d, struct osc_device, od_cl.cd_lu_dev);
}
static inline struct obd_export *osc_export(const struct osc_object *obj)
@@ -476,7 +476,7 @@ static inline struct client_obd *osc_cli(const struct osc_object *obj)
static inline struct osc_object *cl2osc(const struct cl_object *obj)
{
LINVRNT(osc_is_object(&obj->co_lu));
- return container_of0(obj, struct osc_object, oo_cl);
+ return container_of(obj, struct osc_object, oo_cl);
}
static inline struct cl_object *osc2cl(const struct osc_object *obj)
@@ -509,12 +509,12 @@ static inline enum cl_lock_mode osc_ldlm2cl_lock(enum ldlm_mode mode)
static inline struct osc_page *cl2osc_page(const struct cl_page_slice *slice)
{
LINVRNT(osc_is_object(&slice->cpl_obj->co_lu));
- return container_of0(slice, struct osc_page, ops_cl);
+ return container_of(slice, struct osc_page, ops_cl);
}
static inline struct osc_page *oap2osc(struct osc_async_page *oap)
{
- return container_of0(oap, struct osc_page, ops_oap);
+ return container_of_safe(oap, struct osc_page, ops_oap);
}
static inline pgoff_t osc_index(struct osc_page *opg)
@@ -545,7 +545,7 @@ osc_cl_page_osc(struct cl_page *page, struct osc_object *osc)
static inline struct osc_lock *cl2osc_lock(const struct cl_lock_slice *slice)
{
LINVRNT(osc_is_object(&slice->cls_obj->co_lu));
- return container_of0(slice, struct osc_lock, ols_cl);
+ return container_of(slice, struct osc_lock, ols_cl);
}
static inline struct osc_lock *osc_lock_at(const struct cl_lock *lock)
diff --git a/drivers/staging/lustre/lustre/osc/osc_internal.h b/drivers/staging/lustre/lustre/osc/osc_internal.h
index 1c8ba4ad6e7f..fca020568c19 100644
--- a/drivers/staging/lustre/lustre/osc/osc_internal.h
+++ b/drivers/staging/lustre/lustre/osc/osc_internal.h
@@ -180,7 +180,7 @@ struct osc_device {
static inline struct osc_device *obd2osc_dev(const struct obd_device *d)
{
- return container_of0(d->obd_lu_dev, struct osc_device, od_cl.cd_lu_dev);
+ return container_of_safe(d->obd_lu_dev, struct osc_device, od_cl.cd_lu_dev);
}
extern struct lu_kmem_descr osc_caches[];
diff --git a/drivers/staging/lustre/lustre/osc/osc_io.c b/drivers/staging/lustre/lustre/osc/osc_io.c
index 76743faf3e6d..67734a8ed331 100644
--- a/drivers/staging/lustre/lustre/osc/osc_io.c
+++ b/drivers/staging/lustre/lustre/osc/osc_io.c
@@ -55,7 +55,7 @@
static struct osc_io *cl2osc_io(const struct lu_env *env,
const struct cl_io_slice *slice)
{
- struct osc_io *oio = container_of0(slice, struct osc_io, oi_cl);
+ struct osc_io *oio = container_of_safe(slice, struct osc_io, oi_cl);
LINVRNT(oio == osc_env_io(env));
return oio;
diff --git a/drivers/staging/lustre/lustre/osc/osc_object.c b/drivers/staging/lustre/lustre/osc/osc_object.c
index 4f81dd16f4f5..84240181c7ea 100644
--- a/drivers/staging/lustre/lustre/osc/osc_object.c
+++ b/drivers/staging/lustre/lustre/osc/osc_object.c
@@ -58,7 +58,7 @@ static struct lu_object *osc2lu(struct osc_object *osc)
static struct osc_object *lu2osc(const struct lu_object *obj)
{
LINVRNT(osc_is_object(obj));
- return container_of0(obj, struct osc_object, oo_cl.co_lu);
+ return container_of(obj, struct osc_object, oo_cl.co_lu);
}
/*****************************************************************************