Whamcloud - gitweb
Branch: HEAD
[fs/lustre-release.git] / lustre / include / linux / obd_class.h
index 08f8523..3c54d3c 100644 (file)
@@ -25,7 +25,7 @@
 
 #ifndef __KERNEL__
 #include <sys/types.h>
-#include <portals/list.h>
+#include <libcfs/list.h>
 #else
 #include <asm/segment.h>
 #include <asm/uaccess.h>
@@ -84,13 +84,13 @@ int oig_wait(struct obd_io_group *oig);
 int class_process_config(struct lustre_cfg *lcfg);
 
 /* 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;
+        int  cfg_flags;
 };
-int class_config_parse_llog(struct llog_ctxt *ctxt, char *name,
-                            struct config_llog_instance *cfg);
 
 int class_config_process_llog(struct llog_ctxt *ctxt, char *name,
                               struct config_llog_instance *cfg);
@@ -102,6 +102,7 @@ struct lustre_profile {
         char *lp_profile;
         char *lp_lov;
         char *lp_lmv;
+        char *lp_gkc;
 };
 
 struct lustre_profile *class_get_profile(char * prof);
@@ -156,8 +157,10 @@ 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, unsigned long flags);
-void class_disconnect_exports(struct obd_device *obddev, unsigned long flags);
-void class_disconnect_stale_exports(struct obd_device *obddev, 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);
@@ -175,103 +178,24 @@ 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);                       \
@@ -288,11 +212,7 @@ do {                                                            \
 /* 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);                       \
@@ -313,7 +233,7 @@ do {                                                            \
                 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); \
+                lprocfs_counter_incr((obd)->obd_stats, coffset);\
         }
 
 #define MD_COUNTER_OFFSET(op)                                  \
@@ -340,8 +260,8 @@ do {                                                            \
 do {                                                            \
         if (!OBT(obd) || !MDP((obd), op)) {\
                 if (err)                                        \
-                        CERROR("obd_md" #op ": dev %d no operation\n",    \
-                               obd->obd_minor);                 \
+                        CERROR("md_" #op ": dev %s/%d no operation\n", \
+                               obd->obd_name, obd->obd_minor);  \
                 RETURN(err);                                    \
         }                                                       \
 } while (0)
@@ -358,8 +278,9 @@ do {                                                            \
                 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);              \
+                CERROR("obd_" #op ": dev %s/%d no operation\n", \
+                       (exp)->exp_obd->obd_name,                \
+                      (exp)->exp_obd->obd_minor);              \
                 RETURN(-EOPNOTSUPP);                            \
         }                                                       \
 } while (0)
@@ -368,8 +289,8 @@ do {                                                            \
 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)
@@ -386,8 +307,9 @@ do {                                                            \
                 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)
@@ -576,6 +498,7 @@ static inline int obd_revalidate_md(struct obd_export *exp, struct obdo *obdo,
 }
 
 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)
 {
@@ -585,7 +508,7 @@ static inline int obd_create(struct obd_export *exp, struct obdo *obdo,
         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);
 }
 
@@ -632,7 +555,8 @@ static inline int obd_getattr_async(struct obd_export *exp,
 
 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;
@@ -640,7 +564,7 @@ static inline int obd_setattr(struct obd_export *exp, struct obdo *obdo,
         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,
@@ -658,7 +582,8 @@ static inline int obd_add_conn(struct obd_import *imp, struct obd_uuid *uuid,
         RETURN(rc);
 }
 
-static inline int obd_del_conn(struct obd_import *imp, struct obd_uuid *uuid)
+static inline int obd_del_conn(struct obd_import *imp,
+                               struct obd_uuid *uuid)
 {
         struct obd_device *obd = imp->imp_obd;
         int rc;
@@ -674,8 +599,10 @@ static inline int obd_del_conn(struct obd_import *imp, struct obd_uuid *uuid)
 
 
 static inline int obd_connect(struct lustre_handle *conn,
-                              struct obd_device *obd, struct obd_uuid *cluuid,
-                              unsigned long connect_flags)
+                              struct obd_device *obd,
+                              struct obd_uuid *cluuid,
+                              struct obd_connect_data *data,
+                              unsigned long flags)
 {
         int rc;
         ENTRY;
@@ -684,11 +611,13 @@ static inline int obd_connect(struct lustre_handle *conn,
         OBD_CHECK_OP(obd, connect, -EOPNOTSUPP);
         OBD_COUNTER_INCREMENT(obd, connect);
 
-        rc = OBP(obd, connect)(conn, obd, cluuid, connect_flags);
+        rc = OBP(obd, connect)(conn, obd, cluuid, data, flags);
         RETURN(rc);
 }
 
-static inline int obd_connect_post(struct obd_export *exp, unsigned long flags)
+static inline int obd_connect_post(struct obd_export *exp,
+                                   unsigned initial,
+                                   unsigned long flags)
 {
         int rc;
         ENTRY;
@@ -697,11 +626,12 @@ static inline int obd_connect_post(struct obd_export *exp, unsigned long flags)
         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, flags);
+        rc = OBP(exp->exp_obd, connect_post)(exp, initial, flags);
         RETURN(rc);
 }
 
-static inline int obd_disconnect(struct obd_export *exp, unsigned long flags)
+static inline int obd_disconnect(struct obd_export *exp,
+                                 unsigned long flags)
 {
         int rc;
         ENTRY;
@@ -713,17 +643,6 @@ static inline int obd_disconnect(struct obd_export *exp, unsigned long flags)
         RETURN(rc);
 }
 
-static inline int obd_getready(struct obd_export *exp)
-{
-        int rc;
-        ENTRY;
-
-        if (!OBP(exp->exp_obd, getready))
-                RETURN(0);
-        rc = OBP(exp->exp_obd, getready)(exp);
-        RETURN(rc);
-}
-
 static inline int obd_init_export(struct obd_export *exp)
 {
         int rc = 0;
@@ -807,7 +726,8 @@ static inline int obd_sync(struct obd_export *exp, struct obdo *oa,
 
 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;
@@ -815,7 +735,7 @@ static inline int obd_punch(struct obd_export *exp, struct obdo *oa,
         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);
 }
 
@@ -967,7 +887,8 @@ static inline int obd_preprw(int cmd, struct obd_export *exp, struct obdo *oa,
                              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;
@@ -976,7 +897,7 @@ static inline int obd_preprw(int cmd, struct obd_export *exp, struct obdo *oa,
         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);
 }
 
@@ -1031,6 +952,20 @@ static inline int obd_write_extents(struct obd_export *exp,
         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)
 {
@@ -1165,6 +1100,11 @@ static inline void obd_import_event(struct obd_device *obd,
                                     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);
@@ -1182,6 +1122,7 @@ static inline int obd_llog_connect(struct obd_export *exp,
 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;
@@ -1200,6 +1141,7 @@ 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;
@@ -1241,14 +1183,29 @@ static inline int md_delete_inode(struct obd_export *exp,
 }
 
 static inline int md_getattr(struct obd_export *exp, struct lustre_id *id,
-                             __u64 valid, unsigned int ea_size,
+                             __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, ea_size, request);
+        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);
 }
 
@@ -1282,7 +1239,8 @@ static inline int md_change_cbdata_name(struct obd_export *exp,
         RETURN(rc);
 }
 
-static inline int md_close(struct obd_export *exp, struct obdo *obdo,
+static inline int md_close(struct obd_export *exp,
+                           struct mdc_op_data *op_data,
                            struct obd_client_handle *och,
                            struct ptlrpc_request **request)
 {
@@ -1290,7 +1248,7 @@ static inline int md_close(struct obd_export *exp, struct obdo *obdo,
         ENTRY;
         EXP_CHECK_MD_OP(exp, close);
         MD_COUNTER_INCREMENT(exp->exp_obd, close);
-        rc = MDP(exp->exp_obd, close)(exp, obdo, och, request);
+        rc = MDP(exp->exp_obd, close)(exp, op_data, och, request);
         RETURN(rc);
 }
 
@@ -1355,7 +1313,8 @@ static inline int md_getattr_lock(struct obd_export *exp, struct lustre_id *id,
 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,
+                                 struct lustre_id *cid,
+                                 struct lookup_intent *it,
                                  int flags, struct ptlrpc_request **reqp,
                                  ldlm_blocking_callback cb_blocking)
 {
@@ -1363,8 +1322,8 @@ static inline int md_intent_lock(struct obd_export *exp,
         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,
+        rc = MDP(exp->exp_obd, intent_lock)(exp, pid, name, len, lmm,
+                                            lmmsize, cid, it, flags,
                                             reqp, cb_blocking);
         RETURN(rc);
 }
@@ -1396,7 +1355,7 @@ static inline int md_rename(struct obd_export *exp, struct mdc_op_data *data,
 
 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 *ea2, int ea2len, void *ea3, int ea3len,
                              struct ptlrpc_request **request)
 {
         int rc;
@@ -1404,7 +1363,7 @@ static inline int md_setattr(struct obd_export *exp, struct mdc_op_data *data,
         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);
+                                        ea2, ea2len, ea3, ea3len, request);
         RETURN(rc);
 }
 
@@ -1443,13 +1402,13 @@ static inline int md_unlink(struct obd_export *exp, struct mdc_op_data *data,
 }
 
 static inline struct obd_device *md_get_real_obd(struct obd_export *exp,
-                                                 char *name, int len)
+                                                 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, name, len);
+        return MDP(exp->exp_obd, get_real_obd)(exp, fid);
 }
 
 static inline int md_valid_attrs(struct obd_export *exp,
@@ -1530,8 +1489,6 @@ static inline struct obdo *obdo_alloc(void)
 
 static inline void obdo_free(struct obdo *oa)
 {
-        if (!oa)
-                return;
         OBD_SLAB_FREE(oa, obdo_cachep, sizeof(*oa));
 }