Whamcloud - gitweb
LU-5409 obd: add CFS_FAULT_CHECK()
[fs/lustre-release.git] / lustre / include / dt_object.h
index 64c87a2..254134b 100644 (file)
@@ -105,10 +105,10 @@ typedef void (*dt_cb_t)(struct lu_env *env, struct thandle *th,
 #define MAX_COMMIT_CB_STR_LEN  32
 
 struct dt_txn_commit_cb {
-       cfs_list_t      dcb_linkage;
-       dt_cb_t         dcb_func;
-       __u32           dcb_magic;
-       char            dcb_name[MAX_COMMIT_CB_STR_LEN];
+       struct list_head        dcb_linkage;
+       dt_cb_t                 dcb_func;
+       __u32                   dcb_magic;
+       char                    dcb_name[MAX_COMMIT_CB_STR_LEN];
 };
 
 /**
@@ -451,18 +451,19 @@ struct dt_object_operations {
         int   (*do_ref_del)(const struct lu_env *env,
                             struct dt_object *dt, struct thandle *th);
 
-        struct obd_capa *(*do_capa_get)(const struct lu_env *env,
-                                        struct dt_object *dt,
-                                        struct lustre_capa *old,
-                                        __u64 opc);
-        int (*do_object_sync)(const struct lu_env *, struct dt_object *);
-        /**
-         * Get object info of next level. Currently, only get inode from osd.
-         * This is only used by quota b=16542
-         * precondition: dt_object_exists(dt);
-         */
-        int (*do_data_get)(const struct lu_env *env, struct dt_object *dt,
-                           void **data);
+       struct obd_capa *(*do_capa_get)(const struct lu_env *env,
+                                       struct dt_object *dt,
+                                       struct lustre_capa *old,
+                                       __u64 opc);
+       int (*do_object_sync)(const struct lu_env *env, struct dt_object *obj,
+                             __u64 start, __u64 end);
+       /**
+        * Get object info of next level. Currently, only get inode from osd.
+        * This is only used by quota b=16542
+        * precondition: dt_object_exists(dt);
+        */
+       int (*do_data_get)(const struct lu_env *env, struct dt_object *dt,
+                          void **data);
 
        /**
         * Lock object.
@@ -629,6 +630,9 @@ struct dt_index_operations {
                                       const struct dt_it *di,
                                       struct dt_rec *rec,
                                       __u32 attr);
+               int        (*rec_size)(const struct lu_env *env,
+                                      const struct dt_it *di,
+                                     __u32 attr);
                 __u64        (*store)(const struct lu_env *env,
                                       const struct dt_it *di);
                 int           (*load)(const struct lu_env *env,
@@ -677,7 +681,7 @@ struct dt_device {
          * way, because callbacks are supposed to be added/deleted only during
          * single-threaded start-up shut-down procedures.
          */
-        cfs_list_t                         dd_txn_callbacks;
+       struct list_head                   dd_txn_callbacks;
        unsigned int                       dd_record_fid_accessed:1;
 };
 
@@ -707,7 +711,7 @@ struct dt_object {
  */
 struct local_oid_storage {
        /* all initialized llog systems on this node linked by this */
-       cfs_list_t        los_list;
+       struct list_head  los_list;
 
        /* how many handle's reference this los has */
        atomic_t          los_refcount;
@@ -836,9 +840,9 @@ struct dt_txn_callback {
         int (*dtc_txn_stop)(const struct lu_env *env,
                             struct thandle *txn, void *cookie);
         void (*dtc_txn_commit)(struct thandle *txn, void *cookie);
-        void                *dtc_cookie;
-        __u32                dtc_tag;
-        cfs_list_t           dtc_linkage;
+       void                    *dtc_cookie;
+       __u32                   dtc_tag;
+       struct list_head        dtc_linkage;
 };
 
 void dt_txn_callback_add(struct dt_device *dev, struct dt_txn_callback *cb);
@@ -965,13 +969,13 @@ static inline int dt_object_unlock(const struct lu_env *env,
 int dt_lookup_dir(const struct lu_env *env, struct dt_object *dir,
                  const char *name, struct lu_fid *fid);
 
-static inline int dt_object_sync(const struct lu_env *env,
-                                 struct dt_object *o)
+static inline int dt_object_sync(const struct lu_env *env, struct dt_object *o,
+                                __u64 start, __u64 end)
 {
-        LASSERT(o);
-        LASSERT(o->do_ops);
-        LASSERT(o->do_ops->do_object_sync);
-        return o->do_ops->do_object_sync(env, o);
+       LASSERT(o);
+       LASSERT(o->do_ops);
+       LASSERT(o->do_ops->do_object_sync);
+       return o->do_ops->do_object_sync(env, o, start, end);
 }
 
 int dt_declare_version_set(const struct lu_env *env, struct dt_object *o,
@@ -1063,6 +1067,10 @@ static inline int dt_declare_create(const struct lu_env *env,
         LASSERT(dt);
         LASSERT(dt->do_ops);
         LASSERT(dt->do_ops->do_declare_create);
+
+       if (CFS_FAULT_CHECK(OBD_FAIL_DT_DECLARE_CREATE))
+               return cfs_fail_err;
+
         return dt->do_ops->do_declare_create(env, dt, attr, hint, dof, th);
 }
 
@@ -1076,6 +1084,10 @@ static inline int dt_create(const struct lu_env *env,
         LASSERT(dt);
         LASSERT(dt->do_ops);
         LASSERT(dt->do_ops->do_create);
+
+       if (CFS_FAULT_CHECK(OBD_FAIL_DT_CREATE))
+               return cfs_fail_err;
+
         return dt->do_ops->do_create(env, dt, attr, hint, dof, th);
 }
 
@@ -1086,6 +1098,10 @@ static inline int dt_declare_destroy(const struct lu_env *env,
         LASSERT(dt);
         LASSERT(dt->do_ops);
         LASSERT(dt->do_ops->do_declare_destroy);
+
+       if (CFS_FAULT_CHECK(OBD_FAIL_DT_DECLARE_DESTROY))
+               return cfs_fail_err;
+
         return dt->do_ops->do_declare_destroy(env, dt, th);
 }
 
@@ -1096,6 +1112,10 @@ static inline int dt_destroy(const struct lu_env *env,
         LASSERT(dt);
         LASSERT(dt->do_ops);
         LASSERT(dt->do_ops->do_destroy);
+
+       if (CFS_FAULT_CHECK(OBD_FAIL_DT_DESTROY))
+               return cfs_fail_err;
+
         return dt->do_ops->do_destroy(env, dt, th);
 }
 
@@ -1153,6 +1173,10 @@ static inline int dt_declare_attr_get(const struct lu_env *env,
        LASSERT(dt);
        LASSERT(dt->do_ops);
        LASSERT(dt->do_ops->do_declare_attr_get);
+
+       if (CFS_FAULT_CHECK(OBD_FAIL_DT_DECLARE_ATTR_GET))
+               return cfs_fail_err;
+
        return dt->do_ops->do_declare_attr_get(env, dt, capa);
 }
 
@@ -1162,6 +1186,10 @@ static inline int dt_attr_get(const struct lu_env *env, struct dt_object *dt,
         LASSERT(dt);
         LASSERT(dt->do_ops);
         LASSERT(dt->do_ops->do_attr_get);
+
+       if (CFS_FAULT_CHECK(OBD_FAIL_DT_ATTR_GET))
+               return cfs_fail_err;
+
         return dt->do_ops->do_attr_get(env, dt, la, arg);
 }
 
@@ -1173,6 +1201,10 @@ static inline int dt_declare_attr_set(const struct lu_env *env,
         LASSERT(dt);
         LASSERT(dt->do_ops);
         LASSERT(dt->do_ops->do_declare_attr_set);
+
+       if (CFS_FAULT_CHECK(OBD_FAIL_DT_DECLARE_ATTR_SET))
+               return cfs_fail_err;
+
         return dt->do_ops->do_declare_attr_set(env, dt, la, th);
 }
 
@@ -1183,6 +1215,10 @@ static inline int dt_attr_set(const struct lu_env *env, struct dt_object *dt,
         LASSERT(dt);
         LASSERT(dt->do_ops);
         LASSERT(dt->do_ops->do_attr_set);
+
+       if (CFS_FAULT_CHECK(OBD_FAIL_DT_ATTR_SET))
+               return cfs_fail_err;
+
         return dt->do_ops->do_attr_set(env, dt, la, th, capa);
 }
 
@@ -1192,6 +1228,10 @@ static inline int dt_declare_ref_add(const struct lu_env *env,
         LASSERT(dt);
         LASSERT(dt->do_ops);
         LASSERT(dt->do_ops->do_declare_ref_add);
+
+       if (CFS_FAULT_CHECK(OBD_FAIL_DT_DECLARE_REF_ADD))
+               return cfs_fail_err;
+
         return dt->do_ops->do_declare_ref_add(env, dt, th);
 }
 
@@ -1201,6 +1241,10 @@ static inline int dt_ref_add(const struct lu_env *env,
         LASSERT(dt);
         LASSERT(dt->do_ops);
         LASSERT(dt->do_ops->do_ref_add);
+
+       if (CFS_FAULT_CHECK(OBD_FAIL_DT_REF_ADD))
+               return cfs_fail_err;
+
         return dt->do_ops->do_ref_add(env, dt, th);
 }
 
@@ -1210,6 +1254,10 @@ static inline int dt_declare_ref_del(const struct lu_env *env,
         LASSERT(dt);
         LASSERT(dt->do_ops);
         LASSERT(dt->do_ops->do_declare_ref_del);
+
+       if (CFS_FAULT_CHECK(OBD_FAIL_DT_DECLARE_REF_DEL))
+               return cfs_fail_err;
+
         return dt->do_ops->do_declare_ref_del(env, dt, th);
 }
 
@@ -1219,6 +1267,10 @@ static inline int dt_ref_del(const struct lu_env *env,
         LASSERT(dt);
         LASSERT(dt->do_ops);
         LASSERT(dt->do_ops->do_ref_del);
+
+       if (CFS_FAULT_CHECK(OBD_FAIL_DT_REF_DEL))
+               return cfs_fail_err;
+
         return dt->do_ops->do_ref_del(env, dt, th);
 }
 
@@ -1233,15 +1285,15 @@ static inline struct obd_capa *dt_capa_get(const struct lu_env *env,
 }
 
 static inline int dt_bufs_get(const struct lu_env *env, struct dt_object *d,
-                              struct niobuf_remote *rnb,
-                              struct niobuf_local *lnb, int rw,
-                              struct lustre_capa *capa)
+                             struct niobuf_remote *rnb,
+                             struct niobuf_local *lnb, int rw,
+                             struct lustre_capa *capa)
 {
-        LASSERT(d);
-        LASSERT(d->do_body_ops);
-        LASSERT(d->do_body_ops->dbo_bufs_get);
-        return d->do_body_ops->dbo_bufs_get(env, d, rnb->offset,
-                                            rnb->len, lnb, rw, capa);
+       LASSERT(d);
+       LASSERT(d->do_body_ops);
+       LASSERT(d->do_body_ops->dbo_bufs_get);
+       return d->do_body_ops->dbo_bufs_get(env, d, rnb->rnb_offset,
+                                           rnb->rnb_len, lnb, rw, capa);
 }
 
 static inline int dt_bufs_put(const struct lu_env *env, struct dt_object *d,
@@ -1376,6 +1428,10 @@ static inline int dt_declare_insert(const struct lu_env *env,
         LASSERT(dt);
         LASSERT(dt->do_index_ops);
         LASSERT(dt->do_index_ops->dio_declare_insert);
+
+       if (CFS_FAULT_CHECK(OBD_FAIL_DT_DECLARE_INSERT))
+               return cfs_fail_err;
+
         return dt->do_index_ops->dio_declare_insert(env, dt, rec, key, th);
 }
 
@@ -1390,6 +1446,10 @@ static inline int dt_insert(const struct lu_env *env,
         LASSERT(dt);
         LASSERT(dt->do_index_ops);
         LASSERT(dt->do_index_ops->dio_insert);
+
+       if (CFS_FAULT_CHECK(OBD_FAIL_DT_INSERT))
+               return cfs_fail_err;
+
         return dt->do_index_ops->dio_insert(env, dt, rec, key, th,
                                             capa, noquota);
 }
@@ -1402,6 +1462,10 @@ static inline int dt_declare_xattr_del(const struct lu_env *env,
         LASSERT(dt);
         LASSERT(dt->do_ops);
         LASSERT(dt->do_ops->do_declare_xattr_del);
+
+       if (CFS_FAULT_CHECK(OBD_FAIL_DT_DECLARE_XATTR_DEL))
+               return cfs_fail_err;
+
         return dt->do_ops->do_declare_xattr_del(env, dt, name, th);
 }
 
@@ -1413,6 +1477,10 @@ static inline int dt_xattr_del(const struct lu_env *env,
         LASSERT(dt);
         LASSERT(dt->do_ops);
         LASSERT(dt->do_ops->do_xattr_del);
+
+       if (CFS_FAULT_CHECK(OBD_FAIL_DT_XATTR_DEL))
+               return cfs_fail_err;
+
         return dt->do_ops->do_xattr_del(env, dt, name, th, capa);
 }
 
@@ -1425,6 +1493,10 @@ static inline int dt_declare_xattr_set(const struct lu_env *env,
         LASSERT(dt);
         LASSERT(dt->do_ops);
         LASSERT(dt->do_ops->do_declare_xattr_set);
+
+       if (CFS_FAULT_CHECK(OBD_FAIL_DT_DECLARE_XATTR_SET))
+               return cfs_fail_err;
+
         return dt->do_ops->do_declare_xattr_set(env, dt, buf, name, fl, th);
 }
 
@@ -1436,6 +1508,10 @@ static inline int dt_xattr_set(const struct lu_env *env,
         LASSERT(dt);
         LASSERT(dt->do_ops);
         LASSERT(dt->do_ops->do_xattr_set);
+
+       if (CFS_FAULT_CHECK(OBD_FAIL_DT_XATTR_SET))
+               return cfs_fail_err;
+
         return dt->do_ops->do_xattr_set(env, dt, buf, name, fl, th, capa);
 }
 
@@ -1448,6 +1524,10 @@ static inline int dt_declare_xattr_get(const struct lu_env *env,
        LASSERT(dt);
        LASSERT(dt->do_ops);
        LASSERT(dt->do_ops->do_declare_xattr_get);
+
+       if (CFS_FAULT_CHECK(OBD_FAIL_DT_DECLARE_XATTR_GET))
+               return cfs_fail_err;
+
        return dt->do_ops->do_declare_xattr_get(env, dt, buf, name, capa);
 }
 
@@ -1458,6 +1538,10 @@ static inline int dt_xattr_get(const struct lu_env *env,
         LASSERT(dt);
         LASSERT(dt->do_ops);
         LASSERT(dt->do_ops->do_xattr_get);
+
+       if (CFS_FAULT_CHECK(OBD_FAIL_DT_XATTR_GET))
+               return cfs_fail_err;
+
         return dt->do_ops->do_xattr_get(env, dt, buf, name, capa);
 }
 
@@ -1468,6 +1552,10 @@ static inline int dt_xattr_list(const struct lu_env *env,
         LASSERT(dt);
         LASSERT(dt->do_ops);
         LASSERT(dt->do_ops->do_xattr_list);
+
+       if (CFS_FAULT_CHECK(OBD_FAIL_DT_XATTR_LIST))
+               return cfs_fail_err;
+
         return dt->do_ops->do_xattr_list(env, dt, buf, capa);
 }
 
@@ -1479,6 +1567,10 @@ static inline int dt_declare_delete(const struct lu_env *env,
         LASSERT(dt);
         LASSERT(dt->do_index_ops);
         LASSERT(dt->do_index_ops->dio_declare_delete);
+
+       if (CFS_FAULT_CHECK(OBD_FAIL_DT_DECLARE_DELETE))
+               return cfs_fail_err;
+
         return dt->do_index_ops->dio_declare_delete(env, dt, key, th);
 }
 
@@ -1491,6 +1583,10 @@ static inline int dt_delete(const struct lu_env *env,
         LASSERT(dt);
         LASSERT(dt->do_index_ops);
         LASSERT(dt->do_index_ops->dio_delete);
+
+       if (CFS_FAULT_CHECK(OBD_FAIL_DT_DELETE))
+               return cfs_fail_err;
+
         return dt->do_index_ops->dio_delete(env, dt, key, th, capa);
 }
 
@@ -1527,6 +1623,9 @@ static inline int dt_lookup(const struct lu_env *env,
         LASSERT(dt->do_index_ops);
         LASSERT(dt->do_index_ops->dio_lookup);
 
+       if (CFS_FAULT_CHECK(OBD_FAIL_DT_LOOKUP))
+               return cfs_fail_err;
+
         ret = dt->do_index_ops->dio_lookup(env, dt, rec, key, capa);
         if (ret > 0)
                 ret = 0;
@@ -1543,6 +1642,20 @@ struct dt_find_hint {
        struct dt_object     *dfh_o;
 };
 
+struct dt_insert_rec {
+       union {
+               const struct lu_fid     *rec_fid;
+               void                    *rec_data;
+       };
+       union {
+               struct {
+                       __u32            rec_type;
+                       __u32            rec_padding;
+               };
+               __u64                    rec_misc;
+       };
+};
+
 struct dt_thread_info {
        char                     dti_buf[DT_MAX_PATH];
        struct dt_find_hint      dti_dfh;
@@ -1553,6 +1666,7 @@ struct dt_thread_info {
        struct lu_buf            dti_lb;
        struct lu_object_conf    dti_conf;
        loff_t                   dti_off;
+       struct dt_insert_rec     dti_dt_rec;
 };
 
 extern struct lu_context_key dt_key;