#include <linux/lustre_lib.h>
#include <linux/lustre_idl.h>
#include <linux/lprocfs_status.h>
-#include <linux/lustre_mds.h>
+#include <linux/lustre_log.h>
/* OBD Device Declarations */
#define MAX_OBD_DEVICES 256
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() */
struct config_llog_instance {
char * cfg_instance;
struct obd_uuid cfg_uuid;
- ptl_nid_t cfg_local_nid;
+ ptl_nid_t cfg_local_nid;
};
-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 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; \
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,
struct lov_stripe_md **ea,
struct obd_trans_info *oti)
{
LASSERT(exp->exp_obd);
- return lvfs_fid2dentry(&exp->exp_obd->obd_ctxt, id_ino, gen, gr,
+ return lvfs_fid2dentry(&exp->exp_obd->obd_lvfs_ctxt, id_ino, gen, gr,
exp->exp_obd);
}
#define time_before(t1, t2) ((long)t2 - (long)t1 > 0)
#endif
+/* @max_age is the oldest time in jiffies that we accept using a cached data.
+ * If the cache is older than @max_age we will get a new value from the
+ * target. Use a value of "jiffies + HZ" to guarantee freshness. */
static inline int obd_statfs(struct obd_device *obd, struct obd_statfs *osfs,
unsigned long max_age)
{
CDEBUG(D_SUPER, "osfs %lu, max_age %lu\n", obd->obd_osfs_age, max_age);
if (time_before(obd->obd_osfs_age, max_age)) {
rc = OBP(obd, statfs)(obd, osfs, max_age);
- spin_lock(&obd->obd_osfs_lock);
- memcpy(&obd->obd_osfs, osfs, sizeof(obd->obd_osfs));
- obd->obd_osfs_age = jiffies;
- spin_unlock(&obd->obd_osfs_lock);
+ if (rc == 0) {
+ spin_lock(&obd->obd_osfs_lock);
+ memcpy(&obd->obd_osfs, osfs, sizeof(obd->obd_osfs));
+ obd->obd_osfs_age = jiffies;
+ spin_unlock(&obd->obd_osfs_lock);
+ }
} else {
CDEBUG(D_SUPER, "using cached obd_statfs data\n");
spin_lock(&obd->obd_osfs_lock);
}
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;
RETURN(rc);
}
-static inline int obd_prep_async_page(struct obd_export *exp,
+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,
+ struct lov_oinfo *loi,
+ struct page *page, obd_off offset,
+ struct obd_async_page_ops *ops,
void *data, void **res)
{
int ret;
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,
+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)
{
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)
{
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_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;
RETURN(rc);
}
+/* this function notifies MDC, that inode described by @fid gets removed from
+ * memory.*/
+static inline int md_delete_object(struct obd_export *exp,
+ struct ll_fid *fid)
+{
+ int rc;
+ ENTRY;
+
+ /* as this method only notifies MDC that inode gets deleted, we can
+ * return zero if method is not implemented, this means, that OBD does
+ * not need such a notification. */
+ if (MDP(exp->exp_obd, delete_object) == NULL)
+ RETURN(0);
+
+ MD_COUNTER_INCREMENT(exp->exp_obd, delete_object);
+ rc = MDP(exp->exp_obd, delete_object)(exp, fid);
+ RETURN(rc);
+}
+
static inline int md_getattr(struct obd_export *exp, struct ll_fid *fid,
- unsigned long valid, unsigned int ea_size,
- struct ptlrpc_request **request)
+ unsigned long valid, unsigned int ea_size,
+ 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, fid, valid, ea_size, request);
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;
- EXP_CHECK_MD_OP(exp, change_cbdata_name);
+
MD_COUNTER_INCREMENT(exp->exp_obd, change_cbdata_name);
rc = MDP(exp->exp_obd, change_cbdata_name)(exp, fid, name, namelen,
fid2, it, data);
}
static inline int md_close(struct obd_export *exp, struct obdo *obdo,
- struct obd_client_handle *och,
- struct ptlrpc_request **request)
+ struct obd_client_handle *och,
+ struct ptlrpc_request **request)
{
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);
+ data, lockh, lmm, lmmsize,
+ cb_completion, cb_blocking,
+ cb_data);
RETURN(rc);
}
}
static inline int md_link(struct obd_export *exp, struct mdc_op_data *data,
- struct ptlrpc_request **request)
+ struct ptlrpc_request **request)
{
int rc;
ENTRY;
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)
+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;
RETURN(rc);
}
-static inline struct obd_device * md_get_real_obd(struct obd_export *exp,
- char *name, int len)
+static inline struct obd_device *md_get_real_obd(struct obd_export *exp,
+ char *name, int len)
{
ENTRY;
if (MDP(exp->exp_obd, get_real_obd) == NULL)
return MDP(exp->exp_obd, valid_attrs)(exp, fid);
}
+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);
void class_uuid_unparse(class_uuid_t in, struct obd_uuid *out);
/* lustre_peer.c */
-int lustre_uuid_to_peer(char *uuid, ptl_handle_ni_t *peer_ni, ptl_nid_t *peer_nid);
+int lustre_uuid_to_peer(char *uuid, __u32 *peer_nal, ptl_nid_t *peer_nid);
int class_add_uuid(char *uuid, __u64 nid, __u32 nal);
int class_del_uuid (char *uuid);
void class_init_uuidlist(void);
void class_exit_uuidlist(void);
/* mea.c */
-int mea_name2idx(struct mea *, char *, int);
-int raw_name2idx(int, const char *, int);
+int mea_name2idx(struct mea *mea, char *name, int namelen);
+int raw_name2idx(int count, const char *name, int namelen);
#endif /* __LINUX_OBD_CLASS_H */