Whamcloud - gitweb
LU-1330 obdclass: add obd_target.h
[fs/lustre-release.git] / lustre / include / obd_class.h
index 00897af..029b21e 100644 (file)
@@ -27,7 +27,7 @@
  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2011, 2012, Intel Corporation.
+ * Copyright (c) 2011, 2013, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -68,7 +68,8 @@
                                          * interpret routine to be called.
                                          * lov_statfs_fini() must thus be called
                                          * by the request interpret routine */
-
+#define OBD_STATFS_FOR_MDT0    0x0008  /* The statfs is only for retrieving
+                                        * information from MDT0. */
 #define OBD_FL_PUNCH    0x00000001      /* To indicate it is punch operation */
 
 /* OBD Device Declarations */
@@ -104,6 +105,7 @@ struct obd_device * class_find_client_obd(struct obd_uuid *tgt_uuid,
 struct obd_device * class_devices_in_group(struct obd_uuid *grp_uuid,
                                            int *next);
 struct obd_device * class_num2obd(int num);
+int get_devices_count(void);
 
 int class_notify_sptlrpc_conf(const char *fsname, int namelen);
 
@@ -228,21 +230,19 @@ extern void (*class_export_dump_hook)(struct obd_export *);
 
 #endif
 
-#define class_export_rpc_get(exp)                                       \
+#define class_export_rpc_inc(exp)                                       \
 ({                                                                      \
         cfs_atomic_inc(&(exp)->exp_rpc_count);                          \
         CDEBUG(D_INFO, "RPC GETting export %p : new rpc_count %d\n",    \
                (exp), cfs_atomic_read(&(exp)->exp_rpc_count));          \
-        class_export_get(exp);                                          \
 })
 
-#define class_export_rpc_put(exp)                                       \
+#define class_export_rpc_dec(exp)                                       \
 ({                                                                      \
         LASSERT_ATOMIC_POS(&exp->exp_rpc_count);                        \
         cfs_atomic_dec(&(exp)->exp_rpc_count);                          \
         CDEBUG(D_INFO, "RPC PUTting export %p : new rpc_count %d\n",    \
                (exp), cfs_atomic_read(&(exp)->exp_rpc_count));          \
-        class_export_put(exp);                                          \
 })
 
 #define class_export_lock_get(exp, lock)                                \
@@ -336,6 +336,9 @@ void md_from_obdo(struct md_op_data *op_data, struct obdo *oa, obd_flag valid);
 void obdo_from_md(struct obdo *oa, struct md_op_data *op_data,
                   unsigned int valid);
 
+void obdo_cpu_to_le(struct obdo *dobdo, struct obdo *sobdo);
+void obdo_le_to_cpu(struct obdo *dobdo, struct obdo *sobdo);
+
 #define OBT(dev)        (dev)->obd_type
 #define OBP(dev, op)    (dev)->obd_type->typ_dt_ops->o_ ## op
 #define MDP(dev, op)    (dev)->obd_type->typ_md_ops->m_ ## op
@@ -748,11 +751,21 @@ static inline int obd_alloc_diskmd(struct obd_export *exp,
 }
 
 static inline int obd_free_diskmd(struct obd_export *exp,
-                                  struct lov_mds_md **disk_tgt)
-{
-        LASSERT(disk_tgt);
-        LASSERT(*disk_tgt);
-        return obd_packmd(exp, disk_tgt, NULL);
+                                 struct lov_mds_md **disk_tgt)
+{
+       LASSERT(disk_tgt);
+       LASSERT(*disk_tgt);
+       /*
+        * LU-2590, for caller's convenience, *disk_tgt could be host
+        * endianness, it needs swab to LE if necessary, while just
+        * lov_mds_md header needs it for figuring out how much memory
+        * needs to be freed.
+        */
+       if ((cpu_to_le32(LOV_MAGIC) != LOV_MAGIC) &&
+           (((*disk_tgt)->lmm_magic == LOV_MAGIC_V1) ||
+            ((*disk_tgt)->lmm_magic == LOV_MAGIC_V3)))
+               lustre_swab_lov_mds_md(*disk_tgt);
+       return obd_packmd(exp, disk_tgt, NULL);
 }
 
 /* Unpack an MD struct from disk to in-memory format.
@@ -1039,28 +1052,29 @@ static inline int obd_disconnect(struct obd_export *exp)
         RETURN(rc);
 }
 
-static inline int obd_fid_init(struct obd_export *exp)
+static inline int obd_fid_init(struct obd_device *obd, struct obd_export *exp,
+                              enum lu_cli_type type)
 {
-        int rc;
-        ENTRY;
+       int rc;
+       ENTRY;
 
-        OBD_CHECK_DT_OP(exp->exp_obd, fid_init, 0);
-        EXP_COUNTER_INCREMENT(exp, fid_init);
+       OBD_CHECK_DT_OP(obd, fid_init, 0);
+       OBD_COUNTER_INCREMENT(obd, fid_init);
 
-        rc = OBP(exp->exp_obd, fid_init)(exp);
-        RETURN(rc);
+       rc = OBP(obd, fid_init)(obd, exp, type);
+       RETURN(rc);
 }
 
-static inline int obd_fid_fini(struct obd_export *exp)
+static inline int obd_fid_fini(struct obd_device *obd)
 {
-        int rc;
-        ENTRY;
+       int rc;
+       ENTRY;
 
-        OBD_CHECK_DT_OP(exp->exp_obd, fid_fini, 0);
-        EXP_COUNTER_INCREMENT(exp, fid_fini);
+       OBD_CHECK_DT_OP(obd, fid_fini, 0);
+       OBD_COUNTER_INCREMENT(obd, fid_fini);
 
-        rc = OBP(exp->exp_obd, fid_fini)(exp);
-        RETURN(rc);
+       rc = OBP(obd, fid_fini)(obd);
+       RETURN(rc);
 }
 
 static inline int obd_fid_alloc(struct obd_export *exp,
@@ -1189,24 +1203,13 @@ static inline int obd_extent_calc(struct obd_export *exp,
 }
 
 static inline struct dentry *
-obd_lvfs_fid2dentry(struct obd_export *exp, __u64 id_ino, __u32 gen, __u64 gr)
+obd_lvfs_fid2dentry(struct obd_export *exp, struct ost_id *oi, __u32 gen)
 {
-        LASSERT(exp->exp_obd);
+       struct lvfs_run_ctxt *ctxt = &exp->exp_obd->obd_lvfs_ctxt;
+       LASSERT(exp->exp_obd);
 
-        return lvfs_fid2dentry(&exp->exp_obd->obd_lvfs_ctxt, id_ino, gen, gr,
-                               exp->exp_obd);
-}
-
-static inline int
-obd_lvfs_open_llog(struct obd_export *exp, __u64 id_ino, struct dentry *dentry)
-{
-        LASSERT(exp->exp_obd);
-        CERROR("FIXME what's the story here?  This needs to be an obd fn?\n");
-#if 0
-        return lvfs_open_llog(&exp->exp_obd->obd_lvfs_ctxt, id_ino,
-                              dentry, exp->exp_obd);
-#endif
-        return 0;
+       return ctxt->cb_ops.l_fid2dentry(ostid_id(oi), gen, ostid_seq(oi),
+                                        exp->exp_obd);
 }
 
 /* @max_age is the oldest time in jiffies that we accept using a cached data.
@@ -1854,15 +1857,14 @@ static inline int md_getattr(struct obd_export *exp, struct md_op_data *op_data,
         RETURN(rc);
 }
 
-static inline int md_change_cbdata(struct obd_export *exp,
-                                   const struct lu_fid *fid,
-                                   ldlm_iterator_t it, void *data)
+static inline int md_null_inode(struct obd_export *exp,
+                                   const struct lu_fid *fid)
 {
         int rc;
         ENTRY;
-        EXP_CHECK_MD_OP(exp, change_cbdata);
-        EXP_MD_COUNTER_INCREMENT(exp, change_cbdata);
-        rc = MDP(exp->exp_obd, change_cbdata)(exp, fid, it, data);
+        EXP_CHECK_MD_OP(exp, null_inode);
+        EXP_MD_COUNTER_INCREMENT(exp, null_inode);
+        rc = MDP(exp->exp_obd, null_inode)(exp, fid);
         RETURN(rc);
 }
 
@@ -2236,11 +2238,11 @@ extern int obd_init_caches(void);
 extern void obd_cleanup_caches(void);
 
 /* support routines */
-extern cfs_mem_cache_t *obdo_cachep;
+extern struct kmem_cache *obdo_cachep;
 
 #define OBDO_ALLOC(ptr)                                                       \
 do {                                                                          \
-        OBD_SLAB_ALLOC_PTR_GFP((ptr), obdo_cachep, CFS_ALLOC_IO);             \
+       OBD_SLAB_ALLOC_PTR_GFP((ptr), obdo_cachep, __GFP_IO);             \
 } while(0)
 
 #define OBDO_FREE(ptr)                                                        \
@@ -2259,14 +2261,14 @@ static inline void fid2obdo(struct lu_fid *fid, struct obdo *oa)
         /* something here */
 }
 
-typedef int (*register_osp_cb)(void *data);
+typedef int (*register_lwp_cb)(void *data);
 
-struct osp_register_item {
-       struct obd_export **ori_exp;
-       register_osp_cb     ori_cb_func;
-       void               *ori_cb_data;
-       cfs_list_t          ori_list;
-       char                ori_name[MTI_NAME_MAXLEN];
+struct lwp_register_item {
+       struct obd_export **lri_exp;
+       register_lwp_cb     lri_cb_func;
+       void               *lri_cb_data;
+       cfs_list_t          lri_list;
+       char                lri_name[MTI_NAME_MAXLEN];
 };
 
 /* I'm as embarrassed about this as you are.
@@ -2276,11 +2278,12 @@ struct osp_register_item {
 extern int (*ptlrpc_put_connection_superhack)(struct ptlrpc_connection *c);
 
 /* obd_mount.c */
-int server_name2fsname(char *svname, char *fsname, char **endptr);
-int lustre_register_osp_item(char *ospname, struct obd_export **exp,
-                            register_osp_cb cb_func, void *cb_data);
-void lustre_deregister_osp_item(struct obd_export **exp);
-int tgt_name2ospname(char *ost_name, char *osp_name);
+#ifdef HAVE_SERVER_SUPPORT
+int lustre_register_lwp_item(const char *lwpname, struct obd_export **exp,
+                            register_lwp_cb cb_func, void *cb_data);
+void lustre_deregister_lwp_item(struct obd_export **exp);
+int tgt_name2lwpname(const char *tgt_name, char *lwp_name);
+#endif /* HAVE_SERVER_SUPPORT */
 
 /* sysctl.c */
 extern void obd_sysctl_init (void);