Whamcloud - gitweb
b=1451
[fs/lustre-release.git] / lustre / include / linux / obd_class.h
index 386c393..d7e847d 100644 (file)
@@ -42,6 +42,7 @@
 #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
@@ -53,7 +54,8 @@ extern struct obd_device *class_exp2obd(struct obd_export *);
 
 /* 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);
@@ -62,36 +64,33 @@ 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() */
 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 {
@@ -104,6 +103,22 @@ 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;                                         \
@@ -193,6 +208,7 @@ static inline int obd_check_conn(struct lustre_handle *conn)
 
 #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
@@ -292,11 +308,41 @@ do {                                                            \
                 LASSERT(coffset < obd->obd_stats->ls_num);      \
                 lprocfs_counter_incr(obd->obd_stats, coffset);  \
         }
+/* FIXME: real accounting here */
+#define MD_COUNTER_INCREMENT(obd, op)
 #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("obd_md" #op ": dev %d no operation\n",    \
+                               obd->obd_minor);                 \
+                RETURN(err);                                    \
+        }                                                       \
+} while (0)
+
+#define EXP_CHECK_MD_OP(exp, op)                                \
+do {                                                            \
+        if ((exp) == NULL) {                                    \
+                CERROR("obd_" #op ": NULL export\n");           \
+                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 %d no operation\n",    \
+                       (exp)->exp_obd->obd_minor);              \
+                RETURN(-EOPNOTSUPP);                            \
+        }                                                       \
+} while (0)
+
 #define OBD_CHECK_OP(obd, op, err)                              \
 do {                                                            \
         if (!OBT(obd) || !OBP((obd), op)) {\
@@ -397,6 +443,19 @@ static inline int obd_cleanup(struct obd_device *obd, int flags)
         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.
  *
@@ -480,6 +539,20 @@ static inline int obd_free_memmd(struct obd_export *exp,
         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)
@@ -600,7 +673,7 @@ obd_lvfs_fid2dentry(struct obd_export *exp, __u64 id_ino, __u32 gen, __u64 gr)
 {
         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);
 }
 
@@ -608,6 +681,9 @@ obd_lvfs_fid2dentry(struct obd_export *exp, __u64 id_ino, __u32 gen, __u64 gr)
 #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)
 {
@@ -623,10 +699,12 @@ static inline int obd_statfs(struct obd_device *obd, struct obd_statfs *osfs,
         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);
@@ -637,7 +715,7 @@ static inline int obd_statfs(struct obd_device *obd, struct obd_statfs *osfs,
 }
 
 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;
@@ -706,11 +784,11 @@ static inline int obd_brw_async(int cmd, struct obd_export *exp,
         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;
@@ -753,16 +831,16 @@ static inline int obd_set_async_flags(struct obd_export *exp,
         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)
 {
@@ -773,14 +851,14 @@ static inline int obd_queue_group_io(struct obd_export *exp,
         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)
 {
@@ -840,6 +918,42 @@ static inline int obd_commitrw(int cmd, struct obd_export *exp, struct obdo *oa,
         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)
 {
@@ -887,7 +1001,7 @@ static inline int obd_match(struct obd_export *exp, struct lov_stripe_md *ea,
 }
 
 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;
@@ -980,6 +1094,23 @@ static inline void obd_import_event(struct obd_device *obd,
         }
 }
 
+static inline int obd_llog_connect(struct obd_device *obd,
+                                        struct llogd_conn_body *body)
+{
+        ENTRY;
+        if (!obd->obd_set_up) {
+                CERROR("obd %s not set up\n", obd->obd_name);
+                return -EINVAL;
+        }
+
+        if (!OBP(obd, llog_connect)) {
+                CERROR("obd %s has no llog_connect handler\n", obd->obd_name);
+                return -ENOSYS;
+        }
+
+        return OBP(obd, llog_connect)(obd, body);
+}
+
 static inline int obd_notify(struct obd_device *obd,
                              struct obd_device *watched,
                              int active)
@@ -1008,6 +1139,315 @@ static inline int obd_register_observer(struct obd_device *obd,
         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 ll_fid *fid)
+{
+        int rc;
+
+        EXP_CHECK_MD_OP(exp, getstatus);
+        MD_COUNTER_INCREMENT(exp->exp_obd, getstatus);
+        rc = MDP(exp->exp_obd, getstatus)(exp, fid);
+        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)
+{
+        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);
+        RETURN(rc);
+}
+
+static inline int md_change_cbdata(struct obd_export *exp, struct ll_fid *fid,
+                                   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, fid, it, data);
+        RETURN(rc);
+}
+
+static inline int md_change_cbdata_name(struct obd_export *exp,
+                                        struct ll_fid *fid, char *name,
+                                        int namelen, struct ll_fid *fid2,
+                                        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, fid, name, namelen,
+                                                   fid2, it, data);
+        RETURN(rc);
+}
+
+static inline int md_close(struct obd_export *exp, struct obdo *obdo,
+                           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, obdo, 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_name(struct obd_export *exp, struct ll_fid *fid,
+                                  char *filename, int namelen,
+                                  unsigned long valid, unsigned int ea_size,
+                                  struct ptlrpc_request **request)
+{
+        int rc;
+        ENTRY;
+        EXP_CHECK_MD_OP(exp, getattr_name);
+        MD_COUNTER_INCREMENT(exp->exp_obd, getattr_name);
+        rc = MDP(exp->exp_obd, getattr_name)(exp, fid, filename, namelen,
+                                             valid, ea_size, request);
+        RETURN(rc);
+}
+
+static inline int md_intent_lock(struct obd_export *exp, struct ll_uctxt *uctxt,
+                                 struct ll_fid *pfid, const char *name,
+                                 int len, void *lmm, int lmmsize,
+                                 struct ll_fid *cfid, 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, uctxt, pfid, name, len,
+                                            lmm, lmmsize, cfid, 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,
+                             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, request);
+        RETURN(rc);
+}
+
+static inline int md_sync(struct obd_export *exp, struct ll_fid *fid,
+                               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, fid, request);
+        RETURN(rc);
+}
+
+static inline int md_readpage(struct obd_export *exp, struct ll_fid *fid,
+                              __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, fid, 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,
+                                                 char *name, int len)
+{
+        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, name, len);
+}
+
+static inline int md_valid_attrs(struct obd_export *exp, struct ll_fid *fid)
+{
+        ENTRY;
+        EXP_CHECK_MD_OP(exp, valid_attrs);
+        MD_COUNTER_INCREMENT(exp->exp_obd, valid_attrs);
+        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);
@@ -1063,4 +1503,9 @@ 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 *mea, char *name, int namelen);
+int raw_name2idx(int count, const char *name, int namelen);
+
 #endif /* __LINUX_OBD_CLASS_H */