Whamcloud - gitweb
LU-4653 fid: only compare non-IDIF seq in lu_fid_diff
[fs/lustre-release.git] / lustre / osp / osp_internal.h
index c040efa..f2f2a2c 100644 (file)
@@ -64,7 +64,7 @@ struct osp_id_tracker {
        /* underlying shared device */
        struct dt_device        *otr_dev;
        /* how many users of this tracker */
-       cfs_atomic_t             otr_refcount;
+       atomic_t                 otr_refcount;
 };
 
 struct osp_precreate {
@@ -192,7 +192,7 @@ struct osp_device {
         * osp_device::opd_async_requests via declare() functions, these
         * requests can be packed together and sent to the remote server
         * via single OUT RPC later. */
-       struct update_request           *opd_async_requests;
+       struct dt_update_request        *opd_async_requests;
        /* Protect current operations on opd_async_requests. */
        struct mutex                     opd_async_requests_mutex;
        struct semaphore                 opd_async_fc_sem;
@@ -251,6 +251,7 @@ struct osp_object {
 extern struct lu_object_operations osp_lu_obj_ops;
 extern const struct dt_device_operations osp_dt_ops;
 extern struct dt_object_operations osp_md_obj_ops;
+extern struct dt_body_operations osp_md_body_ops;
 
 struct osp_thread_info {
        struct lu_buf            osi_lb;
@@ -393,9 +394,34 @@ static inline struct seq_server_site *osp_seq_site(struct osp_device *osp)
 #define osp_get_rpc_lock(lck, it)  mdc_get_rpc_lock(lck, it)
 #define osp_put_rpc_lock(lck, it) mdc_put_rpc_lock(lck, it)
 
+static inline int osp_fid_diff(const struct lu_fid *fid1,
+                              const struct lu_fid *fid2)
+{
+       /* In 2.6+ ost_idx is packed into IDIF FID, while in 2.4 and 2.5 IDIF
+        * is always FID_SEQ_IDIF(0x100000000ULL), which does not include OST
+        * index in the seq. So we can not compare IDIF FID seq here */
+       if (fid_is_idif(fid1) && fid_is_idif(fid2)) {
+               __u32 ost_idx1 = fid_idif_ost_idx(fid1);
+               __u32 ost_idx2 = fid_idif_ost_idx(fid2);
+
+               LASSERTF(ost_idx1 == 0 || ost_idx2 == 0 || ost_idx1 == ost_idx2,
+                        "fid1: "DFID", fid2: "DFID"\n", PFID(fid1),
+                        PFID(fid2));
+
+               return fid_idif_id(fid1->f_seq, fid1->f_oid, 0) -
+                      fid_idif_id(fid2->f_seq, fid2->f_oid, 0);
+       }
+
+       LASSERTF(fid_seq(fid1) == fid_seq(fid2), "fid1:"DFID
+                ", fid2:"DFID"\n", PFID(fid1), PFID(fid2));
+
+       return fid_oid(fid1) - fid_oid(fid2);
+}
+
+
 static inline void osp_update_last_fid(struct osp_device *d, struct lu_fid *fid)
 {
-       int diff = lu_fid_diff(fid, &d->opd_last_used_fid);
+       int diff = osp_fid_diff(fid, &d->opd_last_used_fid);
        /*
         * we might have lost precreated objects due to VBR and precreate
         * orphans, the gap in objid can be calculated properly only here
@@ -452,7 +478,8 @@ static inline int osp_is_fid_client(struct osp_device *osp)
 }
 
 typedef int (*osp_async_update_interpterer_t)(const struct lu_env *env,
-                                             struct update_reply *reply,
+                                             struct object_update_reply *reply,
+                                             struct ptlrpc_request *req,
                                              struct osp_object *obj,
                                              void *data, int index, int rc);
 
@@ -461,16 +488,16 @@ void osp_update_last_id(struct osp_device *d, obd_id objid);
 extern struct llog_operations osp_mds_ost_orig_logops;
 
 /* osp_trans.c */
-struct update_request *
+struct dt_update_request *
 osp_find_or_create_async_update_request(struct osp_device *osp);
 int osp_insert_async_update(const struct lu_env *env,
-                           struct update_request *update, int op,
+                           struct dt_update_request *update, int op,
                            struct osp_object *obj, int count,
                            int *lens, const char **bufs, void *data,
                            osp_async_update_interpterer_t interpterer);
 int osp_unplug_async_update(const struct lu_env *env,
                            struct osp_device *osp,
-                           struct update_request *update);
+                           struct dt_update_request *update);
 struct thandle *osp_trans_create(const struct lu_env *env,
                                 struct dt_device *d);
 int osp_trans_start(const struct lu_env *env, struct dt_device *dt,
@@ -511,6 +538,7 @@ int osp_md_declare_attr_set(const struct lu_env *env, struct dt_object *dt,
 int osp_md_attr_set(const struct lu_env *env, struct dt_object *dt,
                    const struct lu_attr *attr, struct thandle *th,
                    struct lustre_capa *capa);
+
 /* osp_precreate.c */
 int osp_init_precreate(struct osp_device *d);
 int osp_precreate_reserve(const struct lu_env *env, struct osp_device *d);