Whamcloud - gitweb
b=1451
[fs/lustre-release.git] / lustre / include / linux / obd_class.h
index 086e9b9..d7e847d 100644 (file)
@@ -42,7 +42,7 @@
 #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
@@ -78,21 +78,18 @@ void oig_complete_one(struct obd_io_group *oig,
 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_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);
 
@@ -106,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;                                         \
@@ -430,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.
  *
@@ -513,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)
@@ -878,8 +918,28 @@ static inline int obd_commitrw(int cmd, struct obd_export *exp, struct obdo *oa,
         RETURN(rc);
 }
 
-static inline int obd_write_extents(struct obd_export *exp, struct obd_ioobj *obj,
-                                    int niocount, struct niobuf_local *local, int 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;
 
@@ -889,7 +949,8 @@ static inline int obd_write_extents(struct obd_export *exp, struct obd_ioobj *ob
                 
         OBD_COUNTER_INCREMENT(exp->exp_obd, write_extents);
 
-        rc = OBP(exp->exp_obd, write_extents)(exp, obj, niocount, local, rc);
+        rc = OBP(exp->exp_obd, write_extents)(exp, obj, objcount, niocount, 
+                                              local, rc);
         RETURN(rc);
 }
 
@@ -1098,11 +1159,31 @@ static inline int md_getstatus(struct obd_export *exp, struct ll_fid *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);
@@ -1299,8 +1380,8 @@ static inline int md_unlink(struct obd_export *exp, struct mdc_op_data *data,
         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)