Whamcloud - gitweb
b=21962 Quote the error message in results.yaml
[fs/lustre-release.git] / lustre / mdd / mdd_lov.c
index bb2e1a8..0ea8b9a 100644 (file)
@@ -313,7 +313,7 @@ int mdd_lov_set_md(const struct lu_env *env, struct mdd_object *pobj,
                    int lmm_size, struct thandle *handle, int set_stripe)
 {
         struct lu_buf *buf;
-        umode_t mode;
+        cfs_umode_t mode;
         int rc = 0;
         ENTRY;
 
@@ -354,16 +354,6 @@ int mdd_lov_set_md(const struct lu_env *env, struct mdd_object *pobj,
         RETURN(rc);
 }
 
-/*
- * XXX: this is for create lsm object id, which should identify the lsm object
- * unique in the whole mds, as I see. But it seems, we still not need it
- * now. Right? So just borrow the ll_fid_build_ino().
- */
-static obd_id mdd_lov_create_id(const struct lu_fid *fid)
-{
-        return fid_flatten(fid);
-}
-
 int mdd_lov_objid_prepare(struct mdd_device *mdd, struct lov_mds_md *lmm)
 {
         /* copy mds_lov code is using wrong layer */
@@ -410,7 +400,13 @@ int mdd_lov_create(const struct lu_env *env, struct mdd_device *mdd,
         if (spec->no_create != 0) {
                 *lmm = (struct lov_mds_md *)spec->u.sp_ea.eadata;
                 *lmm_size = spec->u.sp_ea.eadatalen;
-                RETURN(0);
+                if (*lmm_size == lov_mds_md_size((*lmm)->lmm_stripe_count,
+                                                 (*lmm)->lmm_magic)) {
+                        RETURN(0);
+                } else {
+                        CERROR("incorrect lsm received during recovery\n");
+                        RETURN(-EPROTO);
+                }
         }
 
         if (OBD_FAIL_CHECK(OBD_FAIL_MDS_ALLOC_OBDO))
@@ -421,9 +417,9 @@ int mdd_lov_create(const struct lu_env *env, struct mdd_device *mdd,
 
         oa->o_uid = 0; /* must have 0 uid / gid on OST */
         oa->o_gid = 0;
-        oa->o_gr = mdt_to_obd_objgrp(lu_site2md(site)->ms_node_id);
+        oa->o_seq = mdt_to_obd_objseq(lu_site2md(site)->ms_node_id);
         oa->o_mode = S_IFREG | 0600;
-        oa->o_id = mdd_lov_create_id(mdd_object_fid(child));
+        oa->o_id = fid_ver_oid(mdd_object_fid(child));
         oa->o_valid = OBD_MD_FLID | OBD_MD_FLTYPE | OBD_MD_FLFLAGS |
                 OBD_MD_FLMODE | OBD_MD_FLUID | OBD_MD_FLGID | OBD_MD_FLGROUP;
         oa->o_size = 0;
@@ -435,8 +431,6 @@ int mdd_lov_create(const struct lu_env *env, struct mdd_device *mdd,
                                            0, &lsm, (void*)eadata);
                         if (rc)
                                 GOTO(out_oti, rc);
-                        lsm->lsm_object_id = oa->o_id;
-                        lsm->lsm_object_gr = oa->o_gr;
                 } else if (parent != NULL) {
                         /* get lov ea from parent and set to lov */
                         struct lov_mds_md *_lmm;
@@ -470,17 +464,18 @@ int mdd_lov_create(const struct lu_env *env, struct mdd_device *mdd,
                         }
                         GOTO(out_oti, rc);
                 }
-                LASSERT_MDS_GROUP(lsm->lsm_object_gr);
+                LASSERT_SEQ_IS_MDT(lsm->lsm_object_seq);
         } else {
                 LASSERT(eadata != NULL);
                 rc = obd_iocontrol(OBD_IOC_LOV_SETEA, lov_exp, 0, &lsm,
                                    (void*)eadata);
                 if (rc)
                         GOTO(out_oti, rc);
-                lsm->lsm_object_id = oa->o_id;
-                lsm->lsm_object_gr = oa->o_gr;
+
         }
 
+        lsm->lsm_object_id = fid_ver_oid(mdd_object_fid(child));
+        lsm->lsm_object_seq = fid_seq(mdd_object_fid(child));
         /*
          * Sometimes, we may truncate some object(without lsm) then open it
          * (with write flags), so creating lsm above.  The Nonzero(truncated)
@@ -501,9 +496,8 @@ int mdd_lov_create(const struct lu_env *env, struct mdd_device *mdd,
                  * filter_fid, but can not see what is the usages. So just pack
                  * o_seq o_ver here, maybe fix it after this cycle.
                  */
-                oa->o_fid = fid_seq(mdd_object_fid(child));
-                oa->o_generation = fid_oid(mdd_object_fid(child));
-                oa->o_valid |= OBD_MD_FLFID | OBD_MD_FLGENER;
+                obdo_from_inode(oa, NULL,
+                                (struct lu_fid *)mdd_object_fid(child), 0);
                 oinfo->oi_oa = oa;
                 oinfo->oi_md = lsm;
                 oinfo->oi_capa = NULL;
@@ -522,7 +516,6 @@ int mdd_lov_create(const struct lu_env *env, struct mdd_device *mdd,
                         GOTO(out_oti, rc);
                 }
         }
-
         /* blksize should be changed after create data object */
         la->la_valid |= LA_BLKSIZE;
         la->la_blksize = oa->o_blksize;
@@ -583,7 +576,7 @@ int mdd_lovobj_unlink(const struct lu_env *env, struct mdd_device *mdd,
         }
 
         oa->o_id = lsm->lsm_object_id;
-        oa->o_gr = mdt_to_obd_objgrp(lu_site2md(site)->ms_node_id);
+        oa->o_seq = mdt_to_obd_objseq(lu_site2md(site)->ms_node_id);
         oa->o_mode = la->la_mode & S_IFMT;
         oa->o_valid = OBD_MD_FLID | OBD_MD_FLTYPE | OBD_MD_FLGROUP;
 
@@ -593,8 +586,8 @@ int mdd_lovobj_unlink(const struct lu_env *env, struct mdd_device *mdd,
                 oti->oti_logcookies = logcookies;
         }
 
-        CDEBUG(D_INFO, "destroying OSS object %d/%d\n",
-                        (int)oa->o_id, (int)oa->o_gr);
+        CDEBUG(D_INFO, "destroying OSS object "LPU64":"LPU64"\n", oa->o_seq,
+               oa->o_id);
 
         rc = obd_destroy(lov_exp, oa, lsm, oti, NULL, NULL);
 
@@ -644,7 +637,7 @@ int mdd_lov_destroy(const struct lu_env *env, struct mdd_device *mdd,
         }
 
         ma->ma_valid = MA_LOV;
-        
+
         rc = mdd_unlink_log(env, mdd, obj, ma);
         if (rc) {
                 CWARN("mds unlink log for "DFID" failed: %d\n",
@@ -659,54 +652,13 @@ int mdd_lov_destroy(const struct lu_env *env, struct mdd_device *mdd,
         RETURN(rc);
 }
 
-int mdd_log_op_unlink(struct obd_device *obd,
-                      struct lov_mds_md *lmm, int lmm_size,
-                      struct llog_cookie *logcookies, int cookies_size)
-{
-        struct mds_obd *mds = &obd->u.mds;
-        struct lov_stripe_md *lsm = NULL;
-        struct llog_unlink_rec *lur;
-        struct llog_ctxt *ctxt;
-        int rc;
-        ENTRY;
-
-        if (IS_ERR(mds->mds_osc_obd))
-                RETURN(PTR_ERR(mds->mds_osc_obd));
-
-        rc = obd_unpackmd(mds->mds_osc_exp, &lsm, lmm, lmm_size);
-        if (rc < 0)
-                RETURN(rc);
-        rc = obd_checkmd(mds->mds_osc_exp, obd->obd_self_export, lsm);
-        if (rc)
-                GOTO(out, rc);
-        /* first prepare unlink log record */
-        OBD_ALLOC(lur, sizeof(*lur));
-        if (!lur)
-                GOTO(out, rc = -ENOMEM);
-        lur->lur_hdr.lrh_len = lur->lur_tail.lrt_len = sizeof(*lur);
-        lur->lur_hdr.lrh_type = MDS_UNLINK_REC;
-
-        ctxt = llog_get_context(obd, LLOG_MDS_OST_ORIG_CTXT);
-        rc = llog_add(ctxt, &lur->lur_hdr, lsm, logcookies,
-                      cookies_size / sizeof(struct llog_cookie));
-        llog_ctxt_put(ctxt);
-
-        OBD_FREE(lur, sizeof(*lur));
-        GOTO(out, rc);
-out:
-        obd_free_memmd(mds->mds_osc_exp, &lsm);
-        return rc;
-}
-
 int mdd_unlink_log(const struct lu_env *env, struct mdd_device *mdd,
                    struct mdd_object *mdd_cobj, struct md_attr *ma)
 {
-        struct obd_device *obd = mdd2obd_dev(mdd);
-
         LASSERT(ma->ma_valid & MA_LOV);
 
         if ((ma->ma_cookie_size > 0) &&
-            (mdd_log_op_unlink(obd, ma->ma_lmm, ma->ma_lmm_size,
+            (mds_log_op_unlink(mdd2obd_dev(mdd), ma->ma_lmm, ma->ma_lmm_size,
                                ma->ma_cookie, ma->ma_cookie_size) > 0)) {
                 CDEBUG(D_HA, "DEBUG: unlink log is added for object "DFID"\n",
                        PFID(mdd_object_fid(mdd_cobj)));
@@ -716,8 +668,8 @@ int mdd_unlink_log(const struct lu_env *env, struct mdd_device *mdd,
 }
 
 int mdd_log_op_setattr(struct obd_device *obd, __u32 uid, __u32 gid,
-                      struct lov_mds_md *lmm, int lmm_size,
-                      struct llog_cookie *logcookies, int cookies_size)
+                       struct lov_mds_md *lmm, int lmm_size,
+                       struct llog_cookie *logcookies, int cookies_size)
 {
         struct mds_obd *mds = &obd->u.mds;
         struct lov_stripe_md *lsm = NULL;
@@ -733,10 +685,6 @@ int mdd_log_op_setattr(struct obd_device *obd, __u32 uid, __u32 gid,
         if (rc < 0)
                 RETURN(rc);
 
-        rc = obd_checkmd(mds->mds_osc_exp, obd->obd_self_export, lsm);
-        if (rc)
-                GOTO(out, rc);
-
         OBD_ALLOC(lsr, sizeof(*lsr));
         if (!lsr)
                 GOTO(out, rc = -ENOMEM);
@@ -782,7 +730,7 @@ int mdd_setattr_log(const struct lu_env *env, struct mdd_device *mdd,
 
 static int mdd_osc_setattr_async(struct obd_device *obd, __u32 uid, __u32 gid,
                           struct lov_mds_md *lmm, int lmm_size,
-                          struct llog_cookie *logcookies, __u64 id, __u32 gen,
+                          struct llog_cookie *logcookies, const struct lu_fid *parent,
                           struct obd_capa *oc)
 {
         struct mds_obd *mds = &obd->u.mds;
@@ -803,13 +751,8 @@ static int mdd_osc_setattr_async(struct obd_device *obd, __u32 uid, __u32 gid,
 
         rc = obd_unpackmd(mds->mds_osc_exp, &oinfo.oi_md, lmm, lmm_size);
         if (rc < 0) {
-                CERROR("Error unpack md %p for inode "LPU64"\n", lmm, id);
-                GOTO(out, rc);
-        }
-
-        rc = obd_checkmd(mds->mds_osc_exp, obd->obd_self_export, oinfo.oi_md);
-        if (rc) {
-                CERROR("Error revalidate lsm %p \n", oinfo.oi_md);
+                CERROR("Error unpack md %p for obj "DFID"\n", lmm,
+                        PFID(parent));
                 GOTO(out, rc);
         }
 
@@ -817,7 +760,7 @@ static int mdd_osc_setattr_async(struct obd_device *obd, __u32 uid, __u32 gid,
         oinfo.oi_oa->o_uid = uid;
         oinfo.oi_oa->o_gid = gid;
         oinfo.oi_oa->o_id = oinfo.oi_md->lsm_object_id;
-        oinfo.oi_oa->o_gr = oinfo.oi_md->lsm_object_gr;
+        oinfo.oi_oa->o_seq = oinfo.oi_md->lsm_object_seq;
         oinfo.oi_oa->o_valid |= OBD_MD_FLID | OBD_MD_FLGROUP |
                                 OBD_MD_FLUID | OBD_MD_FLGID;
         if (logcookies) {
@@ -825,9 +768,7 @@ static int mdd_osc_setattr_async(struct obd_device *obd, __u32 uid, __u32 gid,
                 oti.oti_logcookies = logcookies;
         }
 
-        oinfo.oi_oa->o_fid = id;
-        oinfo.oi_oa->o_generation = gen;
-        oinfo.oi_oa->o_valid |= OBD_MD_FLFID | OBD_MD_FLGENER;
+        obdo_from_inode(oinfo.oi_oa, NULL, (struct lu_fid *)parent, 0);
         oinfo.oi_capa = oc;
 
         /* do async setattr from mds to ost not waiting for responses. */
@@ -860,7 +801,6 @@ int mdd_lov_setattr_async(const struct lu_env *env, struct mdd_object *obj,
                 RETURN(rc);
 
         rc = mdd_osc_setattr_async(obd, tmp_la->la_uid, tmp_la->la_gid, lmm,
-                                   lmm_size, logcookies, fid_seq(fid),
-                                   fid_oid(fid), NULL);
+                                   lmm_size, logcookies, fid, NULL);
         RETURN(rc);
 }