Whamcloud - gitweb
LU-2682 fid: cleanup direct _id and _seq access
[fs/lustre-release.git] / lustre / osc / osc_request.c
index 64d5e3c..ad912ec 100644 (file)
@@ -82,7 +82,7 @@ static int osc_packmd(struct obd_export *exp, struct lov_mds_md **lmmp,
                OBD_FREE(*lmmp, lmm_size);
                *lmmp = NULL;
                RETURN(0);
-       } else if (unlikely(lsm != NULL && lsm->lsm_object_id == 0)) {
+       } else if (unlikely(lsm != NULL && ostid_id(&lsm->lsm_oi) == 0)) {
                RETURN(-EBADF);
        }
 
@@ -92,10 +92,8 @@ static int osc_packmd(struct obd_export *exp, struct lov_mds_md **lmmp,
                        RETURN(-ENOMEM);
        }
 
-       if (lsm != NULL) {
-               (*lmmp)->lmm_object_id = cpu_to_le64(lsm->lsm_object_id);
-               (*lmmp)->lmm_object_seq = cpu_to_le64(lsm->lsm_object_seq);
-       }
+       if (lsm)
+               ostid_cpu_to_le(&lsm->lsm_oi, &(*lmmp)->lmm_oi);
 
        RETURN(lmm_size);
 }
@@ -117,9 +115,9 @@ static int osc_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp,
                }
                /* XXX LOV_MAGIC etc check? */
 
-               if (unlikely(lmm->lmm_object_id == 0)) {
-                       CERROR("%s: zero lmm_object_id\n",
-                              exp->exp_obd->obd_name);
+               if (unlikely(ostid_id(&lmm->lmm_oi) == 0)) {
+                       CERROR("%s: zero lmm_object_id: rc = %d\n",
+                              exp->exp_obd->obd_name, -EINVAL);
                        RETURN(-EINVAL);
                }
        }
@@ -145,15 +143,13 @@ static int osc_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp,
                        RETURN(-ENOMEM);
                }
                loi_init((*lsmp)->lsm_oinfo[0]);
-       } else if (unlikely((*lsmp)->lsm_object_id == 0)) {
+       } else if (unlikely(ostid_id(&(*lsmp)->lsm_oi) == 0)) {
                RETURN(-EBADF);
        }
 
-       if (lmm != NULL) {
+       if (lmm != NULL)
                /* XXX zero *lsmp? */
-               (*lsmp)->lsm_object_id = le64_to_cpu(lmm->lmm_object_id);
-               (*lsmp)->lsm_object_seq = le64_to_cpu(lmm->lmm_object_seq);
-       }
+               ostid_le_to_cpu(&lmm->lmm_oi, &(*lsmp)->lsm_oi);
 
        if (imp != NULL &&
            (imp->imp_connect_data.ocd_connect_flags & OBD_CONNECT_MAXBYTES))
@@ -482,13 +478,12 @@ int osc_real_create(struct obd_export *exp, struct obdo *oa,
        oa->o_blksize = cli_brw_size(exp->exp_obd);
        oa->o_valid |= OBD_MD_FLBLKSZ;
 
-        /* XXX LOV STACKING: the lsm that is passed to us from LOV does not
-         * have valid lsm_oinfo data structs, so don't go touching that.
-         * This needs to be fixed in a big way.
-         */
-        lsm->lsm_object_id = oa->o_id;
-        lsm->lsm_object_seq = oa->o_seq;
-        *ea = lsm;
+       /* XXX LOV STACKING: the lsm that is passed to us from LOV does not
+        * have valid lsm_oinfo data structs, so don't go touching that.
+        * This needs to be fixed in a big way.
+        */
+       lsm->lsm_oi = oa->o_oi;
+       *ea = lsm;
 
         if (oti != NULL) {
                 oti->oti_transno = lustre_msg_get_transno(req->rq_repmsg);
@@ -2304,7 +2299,7 @@ static int osc_change_cbdata(struct obd_export *exp, struct lov_stripe_md *lsm,
         struct ldlm_res_id res_id;
         struct obd_device *obd = class_exp2obd(exp);
 
-       ostid_build_res_name(&lsm->lsm_object_oid, &res_id);
+       ostid_build_res_name(&lsm->lsm_oi, &res_id);
         ldlm_resource_iterate(obd->obd_namespace, &res_id, replace, data);
         return 0;
 }
@@ -2320,7 +2315,7 @@ static int osc_find_cbdata(struct obd_export *exp, struct lov_stripe_md *lsm,
         struct obd_device *obd = class_exp2obd(exp);
         int rc = 0;
 
-       ostid_build_res_name(&lsm->lsm_object_oid, &res_id);
+       ostid_build_res_name(&lsm->lsm_oi, &res_id);
         rc = ldlm_resource_iterate(obd->obd_namespace, &res_id, replace, data);
         if (rc == LDLM_ITER_STOP)
                 return(1);
@@ -2630,7 +2625,7 @@ static int osc_enqueue(struct obd_export *exp, struct obd_info *oinfo,
         int rc;
         ENTRY;
 
-       ostid_build_res_name(&oinfo->oi_md->lsm_object_oid, &res_id);
+       ostid_build_res_name(&oinfo->oi_md->lsm_oi, &res_id);
         rc = osc_enqueue_base(exp, &res_id, &oinfo->oi_flags, &oinfo->oi_policy,
                               &oinfo->oi_md->lsm_oinfo[0]->loi_lvb,
                               oinfo->oi_md->lsm_oinfo[0]->loi_kms_valid,
@@ -2711,7 +2706,7 @@ static int osc_cancel_unused(struct obd_export *exp,
         struct ldlm_res_id res_id, *resp = NULL;
 
        if (lsm != NULL) {
-               ostid_build_res_name(&lsm->lsm_object_oid, &res_id);
+               ostid_build_res_name(&lsm->lsm_oi, &res_id);
                resp = &res_id;
        }
 
@@ -2899,18 +2894,18 @@ static int osc_getstripe(struct lov_stripe_md *lsm, struct lov_user_md *lump)
                 if (!lumk)
                         RETURN(-ENOMEM);
 
-                if (lum.lmm_magic == LOV_USER_MAGIC_V1)
-                        lmm_objects = &(((struct lov_user_md_v1 *)lumk)->lmm_objects[0]);
-                else
-                        lmm_objects = &(lumk->lmm_objects[0]);
-                lmm_objects->l_object_id = lsm->lsm_object_id;
-        } else {
-                lum_size = lov_mds_md_size(0, lum.lmm_magic);
-                lumk = &lum;
-        }
+               if (lum.lmm_magic == LOV_USER_MAGIC_V1)
+                       lmm_objects =
+                           &(((struct lov_user_md_v1 *)lumk)->lmm_objects[0]);
+               else
+                       lmm_objects = &(lumk->lmm_objects[0]);
+               lmm_objects->l_ost_oi = lsm->lsm_oi;
+       } else {
+               lum_size = lov_mds_md_size(0, lum.lmm_magic);
+               lumk = &lum;
+       }
 
-        lumk->lmm_object_id = lsm->lsm_object_id;
-        lumk->lmm_object_seq = lsm->lsm_object_seq;
+       lumk->lmm_oi = lsm->lsm_oi;
         lumk->lmm_stripe_count = 1;
 
         if (cfs_copy_to_user(lump, lumk, lum_size))