#ifndef __KERNEL__
#include <sys/types.h>
-#include <portals/list.h>
+#include <libcfs/list.h>
#else
#include <asm/segment.h>
#include <asm/uaccess.h>
#include <linux/lustre_lib.h>
#include <linux/lustre_idl.h>
#include <linux/lprocfs_status.h>
+#include <linux/lustre_log.h>
/* OBD Device Declarations */
#define MAX_OBD_DEVICES 256
extern struct obd_device obd_dev[MAX_OBD_DEVICES];
+extern spinlock_t obd_dev_lock;
/* OBD Operations Declarations */
extern struct obd_device *class_conn2obd(struct lustre_handle *);
/* genops.c */
struct obd_export *class_conn2export(struct lustre_handle *);
-int class_register_type(struct obd_ops *ops, struct lprocfs_vars *, char *nm);
+int class_register_type(struct obd_ops *ops, struct md_ops *md_ops,
+ struct lprocfs_vars *, char *nm);
int class_unregister_type(char *nm);
-struct obd_device *class_newdev(int *dev);
+struct obd_device *class_newdev(struct obd_type *type);
+void class_release_dev(struct obd_device *obd);
int class_name2dev(char *name);
struct obd_device *class_name2obd(char *name);
int class_uuid2dev(struct obd_uuid *uuid);
struct obd_device *class_uuid2obd(struct obd_uuid *uuid);
-struct obd_device * class_find_client_obd(struct obd_uuid *tgt_uuid,
+struct obd_device * class_find_client_obd(struct obd_uuid *tgt_uuid,
char * typ_name,
struct obd_uuid *grp_uuid);
-struct obd_device * class_devices_in_group(struct obd_uuid *grp_uuid,
+struct obd_device * class_devices_in_group(struct obd_uuid *grp_uuid,
int *next);
int oig_init(struct obd_io_group **oig);
void oig_add_one(struct obd_io_group *oig,
struct oig_callback_context *occ);
-void oig_complete_one(struct obd_io_group *oig,
+void oig_complete_one(struct obd_io_group *oig,
struct oig_callback_context *occ, int rc);
void oig_release(struct obd_io_group *oig);
int oig_wait(struct obd_io_group *oig);
-/* config.c */
+/* obd_config.c */
int class_process_config(struct lustre_cfg *lcfg);
-int class_attach(struct lustre_cfg *lcfg);
-int class_setup(struct obd_device *obd, struct lustre_cfg *lcfg);
-int class_cleanup(struct obd_device *obd, struct lustre_cfg *lcfg);
-int class_detach(struct obd_device *obd, struct lustre_cfg *lcfg);
-/* Passed as data param to class_config_parse_llog */
+/* Passed as data param to class_config_parse_handler() */
+#define CFG_MODIFY_UUID_FL 0x00001
struct config_llog_instance {
- char * cfg_instance;
+ char *cfg_instance;
struct obd_uuid cfg_uuid;
- ptl_nid_t cfg_local_nid;
+ ptl_nid_t cfg_local_nid;
+ int cfg_flags;
};
-int class_config_parse_llog(struct llog_ctxt *ctxt, char *name,
- struct config_llog_instance *cfg);
-int class_config_dump_llog(struct llog_ctxt *ctxt, char *name,
+
+int class_config_process_llog(struct llog_ctxt *ctxt, char *name,
+ struct config_llog_instance *cfg);
+int class_config_dump_llog(struct llog_ctxt *ctxt, char *name,
struct config_llog_instance *cfg);
struct lustre_profile {
struct list_head lp_list;
- char * lp_profile;
- char * lp_osc;
- char * lp_mdc;
+ char *lp_profile;
+ char *lp_lov;
+ char *lp_lmv;
+ char *lp_gkc;
};
struct lustre_profile *class_get_profile(char * prof);
void class_del_profile(char *prof);
+#define class_export_rpc_get(exp) \
+({ \
+ atomic_inc(&(exp)->exp_rpc_count); \
+ CDEBUG(D_INFO, "RPC GETting export %p : new rpc_count %d\n", \
+ (exp), atomic_read(&(exp)->exp_rpc_count)); \
+ class_export_get(exp); \
+})
+
+#define class_export_rpc_put(exp) \
+({ \
+ atomic_dec(&(exp)->exp_rpc_count); \
+ CDEBUG(D_INFO, "RPC PUTting export %p : new rpc_count %d\n", \
+ (exp), atomic_read(&(exp)->exp_rpc_count)); \
+ class_export_put(exp); \
+})
+
#define class_export_get(exp) \
({ \
struct obd_export *exp_ = exp; \
LASSERT(atomic_read(&(exp)->exp_refcount) < 0x5a5a5a); \
__class_export_put(exp); \
} while (0)
+
void __class_export_put(struct obd_export *);
struct obd_export *class_new_export(struct obd_device *obddev);
void class_unlink_export(struct obd_export *exp);
void class_put_type(struct obd_type *type);
int class_connect(struct lustre_handle *conn, struct obd_device *obd,
struct obd_uuid *cluuid);
-int class_disconnect(struct obd_export *exp, int failover);
-void class_disconnect_exports(struct obd_device *obddev, int failover);
+int class_disconnect(struct obd_export *exp, unsigned long flags);
+void class_disconnect_exports(struct obd_device *, unsigned long);
+int class_disconnect_stale_exports(struct obd_device *,
+ int (*test_export)(struct obd_export *),
+ unsigned long);
+
/* generic operations shared by various OBD types */
int class_multi_setup(struct obd_device *obddev, uint32_t len, void *data);
int class_multi_cleanup(struct obd_device *obddev);
/* obdo.c */
#ifdef __KERNEL__
void obdo_from_iattr(struct obdo *oa, struct iattr *attr, unsigned ia_valid);
-void iattr_from_obdo(struct iattr *attr, struct obdo *oa, obd_flag valid);
-void obdo_from_inode(struct obdo *dst, struct inode *src, obd_flag valid);
-void obdo_refresh_inode(struct inode *dst, struct obdo *src, obd_flag valid);
-void obdo_to_inode(struct inode *dst, struct obdo *src, obd_flag valid);
+void iattr_from_obdo(struct iattr *attr, struct obdo *oa, obd_valid valid);
+void obdo_from_inode(struct obdo *dst, struct inode *src, obd_valid valid);
+void obdo_refresh_inode(struct inode *dst, struct obdo *src, obd_valid valid);
+void obdo_to_inode(struct inode *dst, struct obdo *src, obd_valid valid);
#endif
-void obdo_cpy_md(struct obdo *dst, struct obdo *src, obd_flag valid);
-int obdo_cmp_md(struct obdo *dst, struct obdo *src, obd_flag compare);
+void obdo_cpy_md(struct obdo *dst, struct obdo *src, obd_valid valid);
+int obdo_cmp_md(struct obdo *dst, struct obdo *src, obd_valid compare);
void obdo_to_ioobj(struct obdo *oa, struct obd_ioobj *ioobj);
-static inline int obd_check_conn(struct lustre_handle *conn)
-{
- struct obd_device *obd;
- if (!conn) {
- CERROR("NULL conn\n");
- RETURN(-ENOTCONN);
- }
-
- obd = class_conn2obd(conn);
- if (!obd) {
- CERROR("NULL obd\n");
- RETURN(-ENODEV);
- }
-
- if (!obd->obd_attached) {
- CERROR("obd %d not attached\n", obd->obd_minor);
- RETURN(-ENODEV);
- }
-
- if (!obd->obd_set_up) {
- CERROR("obd %d not setup\n", obd->obd_minor);
- RETURN(-ENODEV);
- }
-
- if (!obd->obd_type) {
- CERROR("obd %d not typed\n", obd->obd_minor);
- RETURN(-ENODEV);
- }
-
- if (!obd->obd_type->typ_ops) {
- CERROR("obd_check_conn: obd %d no operations\n",
- obd->obd_minor);
- RETURN(-EOPNOTSUPP);
- }
- return 0;
-}
-
-
#define OBT(dev) (dev)->obd_type
#define OBP(dev, op) (dev)->obd_type->typ_ops->o_ ## op
+#define MDP(dev, op) (dev)->obd_type->typ_md_ops->m_ ## op
#define CTXTP(ctxt, op) (ctxt)->loc_logops->lop_##op
-/* Ensure obd_setup: used for disconnect which might be called while
- an obd is stopping. */
-#define OBD_CHECK_SETUP(conn, exp) \
-do { \
- if (!(conn)) { \
- CERROR("NULL connection\n"); \
- RETURN(-EINVAL); \
- } \
- \
- exp = class_conn2export(conn); \
- if (!(exp)) { \
- CERROR("No export for conn "LPX64"\n", (conn)->cookie); \
- RETURN(-EINVAL); \
- } \
- \
- if (!(exp)->exp_obd->obd_set_up) { \
- CERROR("Device %d not setup\n", \
- (exp)->exp_obd->obd_minor); \
- class_export_put(exp); \
- RETURN(-EINVAL); \
- } \
-} while (0)
-
-/* Ensure obd_setup and !obd_stopping. */
-#define OBD_CHECK_ACTIVE(conn, exp) \
-do { \
- if (!(conn)) { \
- CERROR("NULL connection\n"); \
- RETURN(-EINVAL); \
- } \
- \
- exp = class_conn2export(conn); \
- if (!(exp)) { \
- CERROR("No export for conn "LPX64"\n", (conn)->cookie); \
- RETURN(-EINVAL); \
- } \
- \
- if (!(exp)->exp_obd->obd_set_up || (exp)->exp_obd->obd_stopping) { \
- CERROR("Device %d not setup\n", \
- (exp)->exp_obd->obd_minor); \
- class_export_put(exp); \
- RETURN(-EINVAL); \
- } \
-} while (0)
-
/* Ensure obd_setup: used for cleanup which must be called
while obd is stopping */
-#define OBD_CHECK_DEV_STOPPING(obd) \
+#define OBD_CHECK_DEV(obd) \
do { \
if (!(obd)) { \
CERROR("NULL device\n"); \
RETURN(-ENODEV); \
} \
- \
+} while (0)
+
+#define OBD_CHECK_DEV_STOPPING(obd) \
+do { \
+ OBD_CHECK_DEV(obd); \
if (!(obd)->obd_set_up) { \
CERROR("Device %d not setup\n", \
(obd)->obd_minor); \
/* ensure obd_setup and !obd_stopping */
#define OBD_CHECK_DEV_ACTIVE(obd) \
do { \
- if (!(obd)) { \
- CERROR("NULL device\n"); \
- RETURN(-ENODEV); \
- } \
- \
+ OBD_CHECK_DEV(obd); \
if (!(obd)->obd_set_up || (obd)->obd_stopping) { \
CERROR("Device %d not setup\n", \
(obd)->obd_minor); \
unsigned int coffset; \
coffset = (unsigned int)(obd)->obd_cntr_base + \
OBD_COUNTER_OFFSET(op); \
- LASSERT(coffset < obd->obd_stats->ls_num); \
- lprocfs_counter_incr(obd->obd_stats, coffset); \
+ LASSERT(coffset < (obd)->obd_stats->ls_num); \
+ lprocfs_counter_incr((obd)->obd_stats, coffset);\
+ }
+
+#define MD_COUNTER_OFFSET(op) \
+ ((offsetof(struct md_ops, m_ ## op) - \
+ offsetof(struct md_ops, m_getstatus)) \
+ / sizeof(((struct md_ops *)(0))->m_getstatus))
+
+#define MD_COUNTER_INCREMENT(obd, op) \
+ if ((obd)->md_stats != NULL) { \
+ unsigned int coffset; \
+ coffset = (unsigned int)(obd)->md_cntr_base + \
+ MD_COUNTER_OFFSET(op); \
+ LASSERT(coffset < (obd)->md_stats->ls_num); \
+ lprocfs_counter_incr((obd)->md_stats, coffset); \
}
+
#else
#define OBD_COUNTER_OFFSET(op)
#define OBD_COUNTER_INCREMENT(obd, op)
+#define MD_COUNTER_INCREMENT(obd, op)
#endif
+#define OBD_CHECK_MD_OP(obd, op, err) \
+do { \
+ if (!OBT(obd) || !MDP((obd), op)) {\
+ if (err) \
+ CERROR("md_" #op ": dev %s/%d no operation\n", \
+ obd->obd_name, obd->obd_minor); \
+ RETURN(err); \
+ } \
+} while (0)
+
+#define EXP_CHECK_MD_OP(exp, op) \
+do { \
+ if ((exp) == NULL) { \
+ CERROR("obd_" #op ": NULL export\n"); \
+ portals_debug_dumplog(); \
+ RETURN(-ENODEV); \
+ } \
+ if ((exp)->exp_obd == NULL || !OBT((exp)->exp_obd)) { \
+ CERROR("obd_" #op ": cleaned up obd\n"); \
+ RETURN(-EOPNOTSUPP); \
+ } \
+ if (!OBT((exp)->exp_obd) || !MDP((exp)->exp_obd, op)) { \
+ CERROR("obd_" #op ": dev %s/%d no operation\n", \
+ (exp)->exp_obd->obd_name, \
+ (exp)->exp_obd->obd_minor); \
+ RETURN(-EOPNOTSUPP); \
+ } \
+} while (0)
+
#define OBD_CHECK_OP(obd, op, err) \
do { \
if (!OBT(obd) || !OBP((obd), op)) {\
if (err) \
- CERROR("obd_" #op ": dev %d no operation\n", \
- obd->obd_minor); \
+ CERROR("obd_" #op ": dev %s/%d no operation\n", \
+ obd->obd_name, obd->obd_minor); \
RETURN(err); \
} \
} while (0)
do { \
if ((exp) == NULL) { \
CERROR("obd_" #op ": NULL export\n"); \
+ portals_debug_dumplog(); \
RETURN(-ENODEV); \
} \
if ((exp)->exp_obd == NULL || !OBT((exp)->exp_obd)) { \
RETURN(-EOPNOTSUPP); \
} \
if (!OBT((exp)->exp_obd) || !OBP((exp)->exp_obd, op)) { \
- CERROR("obd_" #op ": dev %d no operation\n", \
- (exp)->exp_obd->obd_minor); \
+ CERROR("obd_" #op ": dev %s/%d no operation\n", \
+ (exp)->exp_obd->obd_name, \
+ (exp)->exp_obd->obd_minor); \
RETURN(-EOPNOTSUPP); \
} \
} while (0)
-#define CTXT_CHECK_OP(ctxt, op, err) \
+#define CTXT_CHECK_OP(ctxt, op, err) \
do { \
- if (!OBT(ctxt->loc_obd) || !CTXTP((ctxt), op)) { \
+ if (!OBT(ctxt->loc_obd) || !CTXTP((ctxt), op)) { \
if (err) \
CERROR("lop_" #op ": dev %d no operation\n", \
- ctxt->loc_obd->obd_minor); \
+ ctxt->loc_obd->obd_minor); \
RETURN(err); \
} \
} while (0)
RETURN(rc);
}
+static inline int
+obd_process_config(struct obd_device *obd, int datalen, void *data)
+{
+ int rc;
+ ENTRY;
+
+ OBD_CHECK_OP(obd, process_config, -EOPNOTSUPP);
+ OBD_COUNTER_INCREMENT(obd, process_config);
+
+ rc = OBP(obd, process_config)(obd, datalen, data);
+ RETURN(rc);
+}
+
/* Pack an in-memory MD struct for storage on disk.
* Returns +ve size of packed MD (0 for free), or -ve error.
*
return obd_unpackmd(exp, mem_tgt, NULL, 0);
}
+static inline int obd_revalidate_md(struct obd_export *exp, struct obdo *obdo,
+ struct lov_stripe_md *ea,
+ struct obd_trans_info *oti)
+{
+ int rc;
+ ENTRY;
+
+ EXP_CHECK_OP(exp, revalidate_md);
+ OBD_COUNTER_INCREMENT(exp->exp_obd, revalidate_md);
+
+ rc = OBP(exp->exp_obd, revalidate_md)(exp, obdo, ea, oti);
+ RETURN(rc);
+}
+
static inline int obd_create(struct obd_export *exp, struct obdo *obdo,
+ void *acl, int acl_size,
struct lov_stripe_md **ea,
struct obd_trans_info *oti)
{
EXP_CHECK_OP(exp, create);
OBD_COUNTER_INCREMENT(exp->exp_obd, create);
- rc = OBP(exp->exp_obd, create)(exp, obdo, ea, oti);
+ rc = OBP(exp->exp_obd, create)(exp, obdo, acl, acl_size, ea, oti);
RETURN(rc);
}
static inline int obd_setattr(struct obd_export *exp, struct obdo *obdo,
struct lov_stripe_md *ea,
- struct obd_trans_info *oti)
+ struct obd_trans_info *oti,
+ struct lustre_capa *capa)
{
int rc;
ENTRY;
EXP_CHECK_OP(exp, setattr);
OBD_COUNTER_INCREMENT(exp->exp_obd, setattr);
- rc = OBP(exp->exp_obd, setattr)(exp, obdo, ea, oti);
+ rc = OBP(exp->exp_obd, setattr)(exp, obdo, ea, oti, capa);
RETURN(rc);
}
+static inline int obd_add_conn(struct obd_import *imp, struct obd_uuid *uuid,
+ int priority)
+{
+ struct obd_device *obd = imp->imp_obd;
+ int rc;
+ ENTRY;
+
+ OBD_CHECK_DEV_ACTIVE(obd);
+ OBD_CHECK_OP(obd, add_conn, -EOPNOTSUPP);
+ OBD_COUNTER_INCREMENT(obd, add_conn);
+
+ rc = OBP(obd, add_conn)(imp, uuid, priority);
+ RETURN(rc);
+}
+
+static inline int obd_del_conn(struct obd_import *imp,
+ struct obd_uuid *uuid)
+{
+ struct obd_device *obd = imp->imp_obd;
+ int rc;
+ ENTRY;
+
+ OBD_CHECK_DEV_ACTIVE(obd);
+ OBD_CHECK_OP(obd, del_conn, -EOPNOTSUPP);
+ OBD_COUNTER_INCREMENT(obd, del_conn);
+
+ rc = OBP(obd, del_conn)(imp, uuid);
+ RETURN(rc);
+}
+
static inline int obd_connect(struct lustre_handle *conn,
- struct obd_device *obd, struct obd_uuid *cluuid)
+ struct obd_device *obd,
+ struct obd_uuid *cluuid,
+ struct obd_connect_data *data,
+ unsigned long flags)
{
int rc;
ENTRY;
OBD_CHECK_OP(obd, connect, -EOPNOTSUPP);
OBD_COUNTER_INCREMENT(obd, connect);
- rc = OBP(obd, connect)(conn, obd, cluuid);
+ rc = OBP(obd, connect)(conn, obd, cluuid, data, flags);
+ RETURN(rc);
+}
+
+static inline int obd_connect_post(struct obd_export *exp,
+ unsigned initial,
+ unsigned long flags)
+{
+ int rc;
+ ENTRY;
+
+ OBD_CHECK_DEV_ACTIVE(exp->exp_obd);
+ if (!OBT(exp->exp_obd) || !OBP((exp->exp_obd), connect_post))
+ RETURN(0);
+ OBD_COUNTER_INCREMENT(exp->exp_obd, connect_post);
+ rc = OBP(exp->exp_obd, connect_post)(exp, initial, flags);
RETURN(rc);
}
-static inline int obd_disconnect(struct obd_export *exp, int flags)
+static inline int obd_disconnect(struct obd_export *exp,
+ unsigned long flags)
{
int rc;
ENTRY;
}
static inline struct dentry *
-obd_lvfs_fid2dentry(struct obd_export *exp, __u64 id_ino, __u32 gen, __u64 gr)
+obd_lvfs_id2dentry(struct obd_export *exp, __u64 ino,
+ __u32 gen, __u64 gr)
{
LASSERT(exp->exp_obd);
- return lvfs_fid2dentry(&exp->exp_obd->obd_lvfs_ctxt, id_ino, gen, gr,
- exp->exp_obd);
+ return lvfs_id2dentry(&exp->exp_obd->obd_lvfs_ctxt,
+ ino, gen, gr, exp->exp_obd);
}
#ifndef time_before
}
static inline int obd_sync(struct obd_export *exp, struct obdo *oa,
- struct lov_stripe_md *ea, obd_size start,
+ struct lov_stripe_md *ea, obd_size start,
obd_size end)
{
int rc;
static inline int obd_punch(struct obd_export *exp, struct obdo *oa,
struct lov_stripe_md *ea, obd_size start,
- obd_size end, struct obd_trans_info *oti)
+ obd_size end, struct obd_trans_info *oti,
+ struct lustre_capa *capa)
{
int rc;
ENTRY;
EXP_CHECK_OP(exp, punch);
OBD_COUNTER_INCREMENT(exp->exp_obd, punch);
- rc = OBP(exp->exp_obd, punch)(exp, oa, ea, start, end, oti);
+ rc = OBP(exp->exp_obd, punch)(exp, oa, ea, start, end, oti, capa);
RETURN(rc);
}
RETURN(rc);
}
-static inline int obd_prep_async_page(struct obd_export *exp,
- struct lov_stripe_md *lsm,
- struct lov_oinfo *loi,
- struct page *page, obd_off offset,
- struct obd_async_page_ops *ops,
- void *data, void **res)
+static inline int obd_prep_async_page(struct obd_export *exp,
+ struct lov_stripe_md *lsm,
+ struct lov_oinfo *loi,
+ struct page *page, obd_off offset,
+ struct obd_async_page_ops *ops,
+ void *data, void **res)
{
int ret;
ENTRY;
struct lov_stripe_md *lsm,
struct lov_oinfo *loi, void *cookie,
int cmd, obd_off off, int count,
- obd_flag brw_flags, obd_flag async_flags)
+ obd_flags brw_flags, obd_flags async_flags)
{
int rc;
ENTRY;
static inline int obd_set_async_flags(struct obd_export *exp,
struct lov_stripe_md *lsm,
struct lov_oinfo *loi, void *cookie,
- obd_flag async_flags)
+ obd_flags async_flags)
{
int rc;
ENTRY;
OBD_CHECK_OP(exp->exp_obd, set_async_flags, -EOPNOTSUPP);
OBD_COUNTER_INCREMENT(exp->exp_obd, set_async_flags);
- rc = OBP(exp->exp_obd, set_async_flags)(exp, lsm, loi, cookie,
+ rc = OBP(exp->exp_obd, set_async_flags)(exp, lsm, loi, cookie,
async_flags);
RETURN(rc);
}
-static inline int obd_queue_group_io(struct obd_export *exp,
- struct lov_stripe_md *lsm,
- struct lov_oinfo *loi,
- struct obd_io_group *oig,
- void *cookie, int cmd, obd_off off,
- int count, obd_flag brw_flags,
- obd_flag async_flags)
+static inline int obd_queue_group_io(struct obd_export *exp,
+ struct lov_stripe_md *lsm,
+ struct lov_oinfo *loi,
+ struct obd_io_group *oig,
+ void *cookie, int cmd, obd_off off,
+ int count, obd_flags brw_flags,
+ obd_flags async_flags)
{
int rc;
ENTRY;
OBD_COUNTER_INCREMENT(exp->exp_obd, queue_group_io);
LASSERT(cmd & OBD_BRW_RWMASK);
- rc = OBP(exp->exp_obd, queue_group_io)(exp, lsm, loi, oig, cookie,
+ rc = OBP(exp->exp_obd, queue_group_io)(exp, lsm, loi, oig, cookie,
cmd, off, count, brw_flags,
async_flags);
RETURN(rc);
}
-static inline int obd_trigger_group_io(struct obd_export *exp,
- struct lov_stripe_md *lsm,
+static inline int obd_trigger_group_io(struct obd_export *exp,
+ struct lov_stripe_md *lsm,
struct lov_oinfo *loi,
struct obd_io_group *oig)
{
int objcount, struct obd_ioobj *obj,
int niocount, struct niobuf_remote *remote,
struct niobuf_local *local,
- struct obd_trans_info *oti)
+ struct obd_trans_info *oti,
+ struct lustre_capa *capa)
{
int rc;
ENTRY;
OBD_COUNTER_INCREMENT(exp->exp_obd, preprw);
rc = OBP(exp->exp_obd, preprw)(cmd, exp, oa, objcount, obj, niocount,
- remote, local, oti);
+ remote, local, oti, capa);
RETURN(rc);
}
RETURN(rc);
}
+static inline int obd_do_cow(struct obd_export *exp, struct obd_ioobj *obj,
+ int objcount,struct niobuf_remote *rnb)
+{
+ int rc;
+ ENTRY;
+
+ /* there are cases when write_extents is not implemented. */
+ if (!OBP(exp->exp_obd, do_cow))
+ RETURN(0);
+
+ OBD_COUNTER_INCREMENT(exp->exp_obd, do_cow);
+
+ rc = OBP(exp->exp_obd, do_cow)(exp, obj, objcount, rnb);
+
+ RETURN(rc);
+}
+
+static inline int obd_write_extents(struct obd_export *exp,
+ struct obd_ioobj *obj,
+ int objcount, int niocount,
+ struct niobuf_local *local,
+ int rc)
+{
+ ENTRY;
+
+ /* there are cases when write_extents is not implemented. */
+ if (!OBP(exp->exp_obd, write_extents))
+ RETURN(0);
+
+ OBD_COUNTER_INCREMENT(exp->exp_obd, write_extents);
+
+ rc = OBP(exp->exp_obd, write_extents)(exp, obj, objcount, niocount,
+ local, rc);
+ RETURN(rc);
+}
+
+static inline int obd_adjust_kms(struct obd_export *exp,
+ struct lov_stripe_md *lsm,
+ obd_off size, int shrink)
+{
+ int rc;
+ ENTRY;
+
+ OBD_CHECK_OP(exp->exp_obd, adjust_kms, -EOPNOTSUPP);
+ OBD_COUNTER_INCREMENT(exp->exp_obd, adjust_kms);
+
+ rc = OBP(exp->exp_obd, adjust_kms)(exp, lsm, size, shrink);
+ RETURN(rc);
+}
+
static inline int obd_iocontrol(unsigned int cmd, struct obd_export *exp,
int len, void *karg, void *uarg)
{
}
static inline int obd_change_cbdata(struct obd_export *exp,
- struct lov_stripe_md *lsm,
+ struct lov_stripe_md *lsm,
ldlm_iterator_t it, void *data)
{
int rc;
struct obd_import *imp,
enum obd_import_event event)
{
+ if (!obd) {
+ CERROR("NULL device\n");
+ EXIT;
+ return;
+ }
if (obd->obd_set_up && OBP(obd, import_event)) {
OBD_COUNTER_INCREMENT(obd, import_event);
OBP(obd, import_event)(obd, imp, event);
}
}
-static inline int obd_notify(struct obd_device *obd,
- struct obd_device *watched,
- int active)
+static inline int obd_llog_connect(struct obd_export *exp,
+ struct llogd_conn_body *body)
+{
+ ENTRY;
+ EXP_CHECK_OP(exp, llog_connect);
+ return OBP(exp->exp_obd, llog_connect)(exp, body);
+}
+
+static inline int obd_notify(struct obd_device *obd, struct obd_device *watched,
+ int active, void *data)
{
+ OBD_CHECK_DEV(obd);
if (!obd->obd_set_up) {
CERROR("obd %s not set up\n", obd->obd_name);
return -EINVAL;
}
OBD_COUNTER_INCREMENT(obd, notify);
- return OBP(obd, notify)(obd, watched, active);
+ return OBP(obd, notify)(obd, watched, active, data);
}
static inline int obd_register_observer(struct obd_device *obd,
struct obd_device *observer)
{
ENTRY;
+ OBD_CHECK_DEV(obd);
if (obd->obd_observer && observer)
RETURN(-EALREADY);
obd->obd_observer = observer;
RETURN(0);
}
+static inline int obd_init_ea_size(struct obd_export *exp, int size, int size2)
+{
+ int rc;
+ ENTRY;
+ LASSERT(OBP(exp->exp_obd, init_ea_size) != NULL);
+ OBD_COUNTER_INCREMENT(exp->exp_obd, init_ea_size);
+ rc = OBP(exp->exp_obd, init_ea_size)(exp, size, size2);
+ RETURN(rc);
+}
+
+static inline int md_getstatus(struct obd_export *exp, struct lustre_id *id)
+{
+ int rc;
+
+ EXP_CHECK_MD_OP(exp, getstatus);
+ MD_COUNTER_INCREMENT(exp->exp_obd, getstatus);
+ rc = MDP(exp->exp_obd, getstatus)(exp, id);
+ RETURN(rc);
+}
+
+static inline int md_delete_inode(struct obd_export *exp,
+ struct lustre_id *id)
+{
+ int rc;
+ ENTRY;
+
+ if (MDP(exp->exp_obd, delete_inode) == NULL)
+ RETURN(0);
+
+ MD_COUNTER_INCREMENT(exp->exp_obd, delete_inode);
+ rc = MDP(exp->exp_obd, delete_inode)(exp, id);
+ RETURN(rc);
+}
+
+static inline int md_getattr(struct obd_export *exp, struct lustre_id *id,
+ __u64 valid, const char *xattr_name,
+ const void *xattr_data, unsigned int xattr_datalen,
+ unsigned int ea_size, struct obd_capa *ocapa,
+ struct ptlrpc_request **request)
+{
+ int rc;
+ ENTRY;
+ EXP_CHECK_MD_OP(exp, getattr);
+ MD_COUNTER_INCREMENT(exp->exp_obd, getattr);
+ rc = MDP(exp->exp_obd, getattr)(exp, id, valid, xattr_name,
+ xattr_data, xattr_datalen,
+ ea_size, ocapa, request);
+ RETURN(rc);
+}
+
+static inline int md_access_check(struct obd_export *exp, struct lustre_id *id,
+ struct ptlrpc_request **request)
+{
+ int rc;
+ ENTRY;
+ EXP_CHECK_MD_OP(exp, access_check);
+ MD_COUNTER_INCREMENT(exp->exp_obd, access_check);
+ rc = MDP(exp->exp_obd, access_check)(exp, id, request);
+ RETURN(rc);
+}
+
+static inline int md_change_cbdata(struct obd_export *exp, struct lustre_id *id,
+ ldlm_iterator_t it, void *data)
+{
+ int rc;
+ ENTRY;
+ EXP_CHECK_MD_OP(exp, change_cbdata);
+ MD_COUNTER_INCREMENT(exp->exp_obd, change_cbdata);
+ rc = MDP(exp->exp_obd, change_cbdata)(exp, id, it, data);
+ RETURN(rc);
+}
+
+static inline int md_change_cbdata_name(struct obd_export *exp,
+ struct lustre_id *id, char *name,
+ int namelen, struct lustre_id *id2,
+ ldlm_iterator_t it, void *data)
+{
+ int rc;
+
+ /* this seem to be needed only for lmv. */
+ if (!MDP(exp->exp_obd, change_cbdata_name))
+ return 0;
+
+ ENTRY;
+
+ MD_COUNTER_INCREMENT(exp->exp_obd, change_cbdata_name);
+ rc = MDP(exp->exp_obd, change_cbdata_name)(exp, id, name, namelen,
+ id2, it, data);
+ RETURN(rc);
+}
+
+static inline int md_close(struct obd_export *exp,
+ struct mdc_op_data *op_data,
+ struct obd_client_handle *och,
+ struct ptlrpc_request **request)
+{
+ int rc;
+ ENTRY;
+ EXP_CHECK_MD_OP(exp, close);
+ MD_COUNTER_INCREMENT(exp->exp_obd, close);
+ rc = MDP(exp->exp_obd, close)(exp, op_data, och, request);
+ RETURN(rc);
+}
+
+static inline int md_create(struct obd_export *exp, struct mdc_op_data *op_data,
+ const void *data, int datalen, int mode,
+ __u32 uid, __u32 gid, __u64 rdev,
+ struct ptlrpc_request **request)
+{
+ int rc;
+ ENTRY;
+ EXP_CHECK_MD_OP(exp, create);
+ MD_COUNTER_INCREMENT(exp->exp_obd, create);
+ rc = MDP(exp->exp_obd, create)(exp, op_data, data, datalen, mode,
+ uid, gid, rdev, request);
+ RETURN(rc);
+}
+
+static inline int md_done_writing(struct obd_export *exp, struct obdo *obdo)
+{
+ int rc;
+ ENTRY;
+ EXP_CHECK_MD_OP(exp, done_writing);
+ MD_COUNTER_INCREMENT(exp->exp_obd, done_writing);
+ rc = MDP(exp->exp_obd, done_writing)(exp, obdo);
+ RETURN(rc);
+}
+
+static inline int md_enqueue(struct obd_export *exp, int lock_type,
+ struct lookup_intent *it, int lock_mode,
+ struct mdc_op_data *data,
+ struct lustre_handle *lockh,
+ void *lmm, int lmmsize,
+ ldlm_completion_callback cb_completion,
+ ldlm_blocking_callback cb_blocking,
+ void *cb_data)
+{
+ int rc;
+ ENTRY;
+ EXP_CHECK_MD_OP(exp, enqueue);
+ MD_COUNTER_INCREMENT(exp->exp_obd, enqueue);
+ rc = MDP(exp->exp_obd, enqueue)(exp, lock_type, it, lock_mode,
+ data, lockh, lmm, lmmsize,
+ cb_completion, cb_blocking,
+ cb_data);
+ RETURN(rc);
+}
+
+static inline int md_getattr_lock(struct obd_export *exp, struct lustre_id *id,
+ char *filename, int namelen,
+ __u64 valid, unsigned int ea_size,
+ struct ptlrpc_request **request)
+{
+ int rc;
+ ENTRY;
+ EXP_CHECK_MD_OP(exp, getattr_lock);
+ MD_COUNTER_INCREMENT(exp->exp_obd, getattr_lock);
+ rc = MDP(exp->exp_obd, getattr_lock)(exp, id, filename, namelen,
+ valid, ea_size, request);
+ RETURN(rc);
+}
+
+static inline int md_intent_lock(struct obd_export *exp,
+ struct lustre_id *pid, const char *name,
+ int len, void *lmm, int lmmsize,
+ struct lustre_id *cid,
+ struct lookup_intent *it,
+ int flags, struct ptlrpc_request **reqp,
+ ldlm_blocking_callback cb_blocking)
+{
+ int rc;
+ ENTRY;
+ EXP_CHECK_MD_OP(exp, intent_lock);
+ MD_COUNTER_INCREMENT(exp->exp_obd, intent_lock);
+ rc = MDP(exp->exp_obd, intent_lock)(exp, pid, name, len, lmm,
+ lmmsize, cid, it, flags,
+ reqp, cb_blocking);
+ RETURN(rc);
+}
+
+static inline int md_link(struct obd_export *exp, struct mdc_op_data *data,
+ struct ptlrpc_request **request)
+{
+ int rc;
+ ENTRY;
+ EXP_CHECK_MD_OP(exp, link);
+ MD_COUNTER_INCREMENT(exp->exp_obd, link);
+ rc = MDP(exp->exp_obd, link)(exp, data, request);
+ RETURN(rc);
+}
+
+static inline int md_rename(struct obd_export *exp, struct mdc_op_data *data,
+ const char *old, int oldlen,
+ const char *new, int newlen,
+ struct ptlrpc_request **request)
+{
+ int rc;
+ ENTRY;
+ EXP_CHECK_MD_OP(exp, rename);
+ MD_COUNTER_INCREMENT(exp->exp_obd, rename);
+ rc = MDP(exp->exp_obd, rename)(exp, data, old, oldlen, new,
+ newlen, request);
+ RETURN(rc);
+}
+
+static inline int md_setattr(struct obd_export *exp, struct mdc_op_data *data,
+ struct iattr *iattr, void *ea, int ealen,
+ void *ea2, int ea2len, void *ea3, int ea3len,
+ struct ptlrpc_request **request)
+{
+ int rc;
+ ENTRY;
+ EXP_CHECK_MD_OP(exp, setattr);
+ MD_COUNTER_INCREMENT(exp->exp_obd, setattr);
+ rc = MDP(exp->exp_obd, setattr)(exp, data, iattr, ea, ealen,
+ ea2, ea2len, ea3, ea3len, request);
+ RETURN(rc);
+}
+
+static inline int md_sync(struct obd_export *exp, struct lustre_id *id,
+ struct ptlrpc_request **request)
+{
+ int rc;
+ ENTRY;
+ EXP_CHECK_MD_OP(exp, sync);
+ MD_COUNTER_INCREMENT(exp->exp_obd, sync);
+ rc = MDP(exp->exp_obd, sync)(exp, id, request);
+ RETURN(rc);
+}
+
+static inline int md_readpage(struct obd_export *exp, struct lustre_id *id,
+ __u64 offset, struct page *page,
+ struct ptlrpc_request **request)
+{
+ int rc;
+ ENTRY;
+ EXP_CHECK_MD_OP(exp, readpage);
+ MD_COUNTER_INCREMENT(exp->exp_obd, readpage);
+ rc = MDP(exp->exp_obd, readpage)(exp, id, offset, page, request);
+ RETURN(rc);
+}
+
+static inline int md_unlink(struct obd_export *exp, struct mdc_op_data *data,
+ struct ptlrpc_request **request)
+{
+ int rc;
+ ENTRY;
+ EXP_CHECK_MD_OP(exp, unlink);
+ MD_COUNTER_INCREMENT(exp->exp_obd, unlink);
+ rc = MDP(exp->exp_obd, unlink)(exp, data, request);
+ RETURN(rc);
+}
+
+static inline struct obd_device *md_get_real_obd(struct obd_export *exp,
+ struct lustre_id *fid)
+{
+ ENTRY;
+ if (MDP(exp->exp_obd, get_real_obd) == NULL)
+ return exp->exp_obd;
+ MD_COUNTER_INCREMENT(exp->exp_obd, get_real_obd);
+ return MDP(exp->exp_obd, get_real_obd)(exp, fid);
+}
+
+static inline int md_valid_attrs(struct obd_export *exp,
+ struct lustre_id *id)
+{
+ ENTRY;
+ EXP_CHECK_MD_OP(exp, valid_attrs);
+ MD_COUNTER_INCREMENT(exp->exp_obd, valid_attrs);
+ return MDP(exp->exp_obd, valid_attrs)(exp, id);
+}
+
+static inline int md_req2lustre_md(struct obd_export *exp,
+ struct ptlrpc_request *req,
+ unsigned int offset,
+ struct obd_export *osc_exp,
+ struct lustre_md *md)
+{
+ ENTRY;
+ EXP_CHECK_MD_OP(exp, req2lustre_md);
+ MD_COUNTER_INCREMENT(exp->exp_obd, req2lustre_md);
+ return MDP(exp->exp_obd, req2lustre_md)(exp, req, offset, osc_exp, md);
+}
+
+static inline int md_set_open_replay_data(struct obd_export *exp,
+ struct obd_client_handle *och,
+ struct ptlrpc_request *open_req)
+{
+ ENTRY;
+ EXP_CHECK_MD_OP(exp, set_open_replay_data);
+ MD_COUNTER_INCREMENT(exp->exp_obd, set_open_replay_data);
+ return MDP(exp->exp_obd, set_open_replay_data)(exp, och, open_req);
+}
+
+static inline int md_clear_open_replay_data(struct obd_export *exp,
+ struct obd_client_handle *och)
+{
+ ENTRY;
+ EXP_CHECK_MD_OP(exp, clear_open_replay_data);
+ MD_COUNTER_INCREMENT(exp->exp_obd, clear_open_replay_data);
+ return MDP(exp->exp_obd, clear_open_replay_data)(exp, och);
+}
+
+static inline int md_store_inode_generation(struct obd_export *exp,
+ struct ptlrpc_request *req,
+ int reqoff, int repoff)
+{
+ ENTRY;
+ EXP_CHECK_MD_OP(exp, store_inode_generation);
+ MD_COUNTER_INCREMENT(exp->exp_obd, store_inode_generation);
+ return MDP(exp->exp_obd, store_inode_generation)(exp, req,
+ reqoff, repoff);
+}
+
+static inline int md_set_lock_data(struct obd_export *exp, __u64 *l,
+ void *data)
+{
+ ENTRY;
+ EXP_CHECK_MD_OP(exp, set_lock_data);
+ MD_COUNTER_INCREMENT(exp->exp_obd, set_lock_data);
+ return MDP(exp->exp_obd, set_lock_data)(exp, l, data);
+}
+
/* OBD Metadata Support */
extern int obd_init_caches(void);
{
struct obdo *oa;
- oa = kmem_cache_alloc(obdo_cachep, SLAB_KERNEL);
- if (oa == NULL)
- LBUG();
- CDEBUG(D_MALLOC, "kmem_cache_alloced oa at %p\n", oa);
- memset(oa, 0, sizeof (*oa));
-
+ OBD_SLAB_ALLOC(oa, obdo_cachep, GFP_KERNEL,
+ sizeof(*oa));
return oa;
}
static inline void obdo_free(struct obdo *oa)
{
- if (!oa)
- return;
- CDEBUG(D_MALLOC, "kmem_cache_freed oa at %p\n", oa);
- kmem_cache_free(obdo_cachep, oa);
+ OBD_SLAB_FREE(oa, obdo_cachep, sizeof(*oa));
+}
+
+static inline void obdo2id(struct lustre_id *id,
+ struct obdo *oa)
+{
+ LASSERT(oa && id);
+ id_ino(id) = oa->o_id;
+ id_fid(id) = oa->o_fid;
+ id_group(id) = oa->o_mds;
+ id_gen(id) = oa->o_generation;
+}
+
+static inline void id2obdo(struct obdo *oa,
+ struct lustre_id *id)
+{
+ LASSERT(oa && id);
+ oa->o_id = id_ino(id);
+ oa->o_fid = id_fid(id);
+ oa->o_mds = id_group(id);
+ oa->o_generation = id_gen(id);
}
#if !defined(__KERNEL__) || (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
int class_del_uuid (char *uuid);
void class_init_uuidlist(void);
void class_exit_uuidlist(void);
+
+/* mea.c */
+int mea_name2idx(struct mea *mea, char *name, int namelen);
+int raw_name2idx(int hashtype, int count, const char *name, int namelen);
+
#endif /* __LINUX_OBD_CLASS_H */