Whamcloud - gitweb
LU-717 ldiskfs: MRP-222 Replace sysname with nodename in MMP
[fs/lustre-release.git] / lustre / mdt / mdt_internal.h
index 5b3f836..1317643 100644 (file)
  * GPL HEADER END
  */
 /*
- * Copyright  2008 Sun Microsystems, Inc. All rights reserved
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
+ *
+ * Copyright (c) 2011 Whamcloud, Inc.
+ *
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -175,7 +178,7 @@ struct mdt_device {
 #define MDT_ROCOMPAT_SUPP       (OBD_ROCOMPAT_LOVOBJID)
 #define MDT_INCOMPAT_SUPP       (OBD_INCOMPAT_MDT | OBD_INCOMPAT_COMMON_LR | \
                                  OBD_INCOMPAT_FID | OBD_INCOMPAT_IAM_DIR)
-#define MDT_COS_DEFAULT         (1)
+#define MDT_COS_DEFAULT         (0)
 
 struct mdt_object {
         struct lu_object_header mot_header;
@@ -185,7 +188,9 @@ struct mdt_object {
         int                     mot_ioepoch_count;
         int                     mot_writecount;
         /* Lock to protect object's IO epoch. */
-        cfs_semaphore_t        mot_ioepoch_sem;
+        cfs_semaphore_t         mot_ioepoch_sem;
+        /* Lock to protect create_data */
+        cfs_semaphore_t         mot_lov_sem;
 };
 
 enum mdt_object_flags {
@@ -204,6 +209,8 @@ enum mdt_object_flags {
         MOF_SOM_RECOV   = (1 << 1),
         /** File has been just created. */
         MOF_SOM_CREATED = (1 << 2),
+        /** lov object has been created. */
+        MOF_LOV_CREATED = (1 << 3),
 };
 
 struct mdt_lock_handle {
@@ -337,8 +344,8 @@ struct mdt_thread_info {
         struct mdt_reint_record    mti_rr;
 
         /** md objects included in operation */
-        struct mdt_object         *mti_mos[PTLRPC_NUM_VERSIONS];
-
+        struct mdt_object         *mti_mos;
+        __u64                      mti_ver[PTLRPC_NUM_VERSIONS];
         /*
          * Operation specification (currently create and lookup)
          */
@@ -393,11 +400,6 @@ struct mdt_thread_info {
         struct md_attr             mti_tmp_attr;
 };
 
-#define mti_parent      mti_mos[0]
-#define mti_child       mti_mos[1]
-#define mti_parent1     mti_mos[2]
-#define mti_child1      mti_mos[3]
-
 typedef void (*mdt_cb_t)(const struct mdt_device *mdt, __u64 transno,
                          void *data, int err);
 struct mdt_commit_cb {
@@ -410,32 +412,6 @@ enum mdt_txn_op {
         MDT_TXN_LAST_RCVD_WRITE_OP,
 };
 
-/*
- * Info allocated per-transaction.
- */
-#define MDT_MAX_COMMIT_CB       4
-struct mdt_txn_info {
-        __u64                 txi_transno;
-        unsigned int          txi_cb_count;
-        struct lut_commit_cb  txi_cb[MDT_MAX_COMMIT_CB];
-};
-
-extern struct lu_context_key mdt_txn_key;
-
-static inline void mdt_trans_add_cb(const struct thandle *th,
-                                    lut_cb_t cb_func, void *cb_data)
-{
-        struct mdt_txn_info *txi;
-
-        txi = lu_context_key_get(&th->th_ctx, &mdt_txn_key);
-        LASSERT(txi->txi_cb_count < ARRAY_SIZE(txi->txi_cb));
-
-        /* add new callback */
-        txi->txi_cb[txi->txi_cb_count].lut_cb_func = cb_func;
-        txi->txi_cb[txi->txi_cb_count].lut_cb_data = cb_data;
-        txi->txi_cb_count++;
-}
-
 static inline const struct md_device_operations *
 mdt_child_ops(struct mdt_device * m)
 {
@@ -454,6 +430,12 @@ static inline struct ptlrpc_request *mdt_info_req(struct mdt_thread_info *info)
          return info->mti_pill ? info->mti_pill->rc_req : NULL;
 }
 
+static inline int req_is_replay(struct ptlrpc_request *req)
+{
+        LASSERT(req->rq_reqmsg);
+        return !!(lustre_msg_get_flags(req->rq_reqmsg) & MSG_REPLAY);
+}
+
 static inline __u64 mdt_conn_flags(struct mdt_thread_info *info)
 {
         LASSERT(info->mti_exp);
@@ -644,7 +626,10 @@ int mdt_check_ucred(struct mdt_thread_info *);
 int mdt_init_ucred(struct mdt_thread_info *, struct mdt_body *);
 int mdt_init_ucred_reint(struct mdt_thread_info *);
 void mdt_exit_ucred(struct mdt_thread_info *);
-int mdt_version_get_check(struct mdt_thread_info *, int);
+int mdt_version_get_check(struct mdt_thread_info *, struct mdt_object *, int);
+void mdt_version_get_save(struct mdt_thread_info *, struct mdt_object *, int);
+int mdt_version_get_check_save(struct mdt_thread_info *, struct mdt_object *,
+                               int);
 
 /* mdt_idmap.c */
 int mdt_init_sec_level(struct mdt_thread_info *);
@@ -686,7 +671,7 @@ static inline void mdt_fail_write(const struct lu_env *env,
                                   struct dt_device *dd, int id)
 {
         if (OBD_FAIL_CHECK_ORSET(id, OBD_FAIL_ONCE)) {
-                CERROR(LUSTRE_MDT_NAME": obd_fail_loc=%x, fail write ops\n",
+                CERROR(LUSTRE_MDT_NAME": cfs_fail_loc=%x, fail write ops\n",
                        id);
                 dd->dd_ops->dt_ro(env, dd);
                 /* We set FAIL_ONCE because we never "un-fail" a device */
@@ -801,6 +786,25 @@ int mdt_cos_is_enabled(struct mdt_device *);
 int mdt_hsm_copytool_send(struct obd_export *exp);
 
 /* lprocfs stuff */
+enum {
+        LPROC_MDT_OPEN = 0,
+        LPROC_MDT_CLOSE,
+        LPROC_MDT_MKNOD,
+        LPROC_MDT_LINK,
+        LPROC_MDT_UNLINK,
+        LPROC_MDT_MKDIR,
+        LPROC_MDT_RMDIR,
+        LPROC_MDT_RENAME,
+        LPROC_MDT_GETATTR,
+        LPROC_MDT_SETATTR,
+        LPROC_MDT_GETXATTR,
+        LPROC_MDT_SETXATTR,
+        LPROC_MDT_STATFS,
+        LPROC_MDT_SYNC,
+        LPROC_MDT_LAST,
+};
+void mdt_counter_incr(struct obd_export *exp, int opcode);
+void mdt_stats_counter_init(struct lprocfs_stats *stats);
 void lprocfs_mdt_init_vars(struct lprocfs_static_vars *lvars);
 int mdt_procfs_init(struct mdt_device *mdt, const char *name);
 int mdt_procfs_fini(struct mdt_device *mdt);
@@ -808,10 +812,6 @@ int mdt_procfs_fini(struct mdt_device *mdt);
 void mdt_time_start(const struct mdt_thread_info *info);
 void mdt_time_end(const struct mdt_thread_info *info, int idx);
 
-enum {
-        LPROC_MDT_NR
-};
-
 /* Capability */
 int mdt_ck_thread_start(struct mdt_device *mdt);
 void mdt_ck_thread_stop(struct mdt_device *mdt);