Whamcloud - gitweb
LU-354 test: Change dev_set_rdonly() check to warning
[fs/lustre-release.git] / lustre / mdt / mdt_internal.h
index b2889ed..8913d67 100644 (file)
@@ -29,8 +29,7 @@
  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2011 Whamcloud, Inc.
- *
+ * Copyright (c) 2011, 2012, Whamcloud, Inc.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -190,9 +189,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_mutex_t             mot_ioepoch_mutex;
         /* Lock to protect create_data */
-        cfs_semaphore_t         mot_lov_sem;
+        cfs_mutex_t             mot_lov_mutex;
 };
 
 enum mdt_object_flags {
@@ -413,11 +412,6 @@ enum mdt_txn_op {
         MDT_TXN_LAST_RCVD_WRITE_OP,
 };
 
-enum mdt_obj_exist{
-        MDT_OBJ_MUST_EXIST,
-        MDT_OBJ_MAY_NOT_EXIST,
-};
-
 static inline const struct md_device_operations *
 mdt_child_ops(struct mdt_device * m)
 {
@@ -469,11 +463,16 @@ static inline int mdt_object_exists(const struct mdt_object *o)
         return lu_object_exists(&o->mot_obj.mo_lu);
 }
 
-static inline const struct lu_fid *mdt_object_fid(struct mdt_object *o)
+static inline const struct lu_fid *mdt_object_fid(const struct mdt_object *o)
 {
         return lu_object_fid(&o->mot_obj.mo_lu);
 }
 
+static inline int mdt_object_obf(const struct mdt_object *o)
+{
+        return lu_fid_eq(mdt_object_fid(o), &LU_OBF_FID);
+}
+
 static inline struct lu_site *mdt_lu_site(const struct mdt_device *mdt)
 {
         return mdt->mdt_md_dev.md_lu_dev.ld_site;
@@ -490,11 +489,6 @@ static inline void mdt_export_evict(struct obd_export *exp)
         class_export_put(exp);
 }
 
-static inline const char *mdt_obj_dev_name(const struct mdt_object *obj)
-{
-        return lu_dev_name(obj->mot_obj.mo_lu.lo_dev);
-}
-
 int mdt_get_disposition(struct ldlm_reply *rep, int flag);
 void mdt_set_disposition(struct mdt_thread_info *info,
                         struct ldlm_reply *rep, int flag);
@@ -524,13 +518,11 @@ void mdt_object_unlock(struct mdt_thread_info *,
 
 struct mdt_object *mdt_object_find(const struct lu_env *,
                                    struct mdt_device *,
-                                   const struct lu_fid *,
-                                   enum mdt_obj_exist check_exist);
+                                   const struct lu_fid *);
 struct mdt_object *mdt_object_find_lock(struct mdt_thread_info *,
                                         const struct lu_fid *,
                                         struct mdt_lock_handle *,
-                                        __u64 ibits,
-                                        enum mdt_obj_exist check_exist);
+                                        __u64);
 void mdt_object_unlock_put(struct mdt_thread_info *,
                            struct mdt_object *,
                            struct mdt_lock_handle *,
@@ -691,15 +683,17 @@ int mdt_pack_remote_perm(struct mdt_thread_info *, struct mdt_object *, void *);
 
 extern struct lu_context_key       mdt_thread_key;
 /* debug issues helper starts here*/
-static inline void mdt_fail_write(const struct lu_env *env,
-                                  struct dt_device *dd, int id)
+static inline int 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": cfs_fail_loc=%x, fail write ops\n",
                        id);
-                dd->dd_ops->dt_ro(env, dd);
+                return dd->dd_ops->dt_ro(env, dd);
                 /* We set FAIL_ONCE because we never "un-fail" a device */
         }
+
+        return 0;
 }
 
 static inline struct mdt_export_data *mdt_req2med(struct ptlrpc_request *req)
@@ -860,7 +854,7 @@ static inline void mdt_set_capainfo(struct mdt_thread_info *info, int offset,
 
         ci = md_capainfo(info->mti_env);
         LASSERT(ci);
-        ci->mc_fid[offset]  = fid;
+        ci->mc_fid[offset]  = *fid;
         ci->mc_capa[offset] = capa;
 }
 
@@ -872,16 +866,14 @@ static inline void mdt_dump_capainfo(struct mdt_thread_info *info)
         if (!ci)
                 return;
         for (i = 0; i < MD_CAPAINFO_MAX; i++) {
-                if (!ci->mc_fid[i])
-                        continue;
                 if (!ci->mc_capa[i]) {
                         CERROR("no capa for index %d "DFID"\n",
-                               i, PFID(ci->mc_fid[i]));
+                               i, PFID(&ci->mc_fid[i]));
                         continue;
                 }
                 if (ci->mc_capa[i] == BYPASS_CAPA) {
                         CERROR("bypass for index %d "DFID"\n",
-                               i, PFID(ci->mc_fid[i]));
+                               i, PFID(&ci->mc_fid[i]));
                         continue;
                 }
                 DEBUG_CAPA(D_ERROR, ci->mc_capa[i], "index %d", i);