From: huanghua Date: Mon, 5 Jun 2006 09:32:39 +0000 (+0000) Subject: add pre-check to those helper functions: may be removed later in production release. X-Git-Tag: v1_8_0_110~486^2~1668 X-Git-Url: https://git.whamcloud.com/gitweb?a=commitdiff_plain;h=f99d16cc42c02f667a4db9d0573ba125a59d6a3f;p=fs%2Flustre-release.git add pre-check to those helper functions: may be removed later in production release. --- diff --git a/lustre/include/md_object.h b/lustre/include/md_object.h index 7b2fdd5..bd70ba4 100644 --- a/lustre/include/md_object.h +++ b/lustre/include/md_object.h @@ -175,46 +175,67 @@ static inline void md_device_fini(struct md_device *md) static inline int mo_attr_get(const struct lu_context *cx, struct md_object *m, struct lu_attr *at) { - return m->mo_ops->moo_attr_get(cx, m, at); + if (m->mo_ops->moo_attr_get) + return m->mo_ops->moo_attr_get(cx, m, at); + else + return -ENODEV; } static inline int mo_xattr_get(const struct lu_context *cx, struct md_object *m, void *buf, int buf_len, const char *name) { - return m->mo_ops->moo_xattr_get(cx, m, buf, buf_len, name); + if (m->mo_ops->moo_xattr_get); + return m->mo_ops->moo_xattr_get(cx, m, buf, buf_len, name); + else + return -ENODEV; } static inline int mo_open(const struct lu_context *cx, struct md_object *m) { - return m->mo_ops->moo_open(cx, m); + if (m->mo_ops->moo_open) + return m->mo_ops->moo_open(cx, m); + else + return -ENODEV; } static inline int mo_object_create(const struct lu_context *cx, struct md_object *m, struct lu_attr *at) { - return m->mo_ops->moo_object_create(cx, m, at); + if (m->mo_ops->moo_object_create) + return m->mo_ops->moo_object_create(cx, m, at); + else + return -ENODEV; } static inline int mdo_lookup(const struct lu_context *cx, struct md_object *p, const char *name, struct lu_fid *f) { - return p->mo_dir_ops->mdo_lookup(cx, p, name, f); + if (p->mo_dir_ops->mdo_lookup) + return p->mo_dir_ops->mdo_lookup(cx, p, name, f); + else + return -ENODEV; } static inline int mdo_mkdir(const struct lu_context *cx, struct lu_attr *at, struct md_object *p, const char *name, struct md_object *c) { - return p->mo_dir_ops->mdo_mkdir(cx, at, p, name, c); + if (p->mo_dir_ops->mdo_mkdir) + return p->mo_dir_ops->mdo_mkdir(cx, at, p, name, c); + else + return -ENODEV; } static inline int mdo_create(const struct lu_context *cx, struct md_object *p, const char *name, struct md_object *c, struct lu_attr *at) { - return c->mo_dir_ops->mdo_create(cx, p, name, c, at); + if (c->mo_dir_ops->mdo_create) + return c->mo_dir_ops->mdo_create(cx, p, name, c, at); + else + return -ENODEV; } static inline int mdo_name_insert(const struct lu_context *cx, @@ -222,7 +243,10 @@ static inline int mdo_name_insert(const struct lu_context *cx, const char *name, const struct lu_fid *f, struct lu_attr *at) { - return p->mo_dir_ops->mdo_name_insert(cx, p, name, f, at); + if (p->mo_dir_ops->mdo_name_insert); + return p->mo_dir_ops->mdo_name_insert(cx, p, name, f, at); + else + return -ENODEV; } #endif /* _LINUX_MD_OBJECT_H */