Whamcloud - gitweb
Introduce .gitignore files.
[fs/lustre-release.git] / lustre / mdd / mdd_lov.c
index 6044429..f9cdc02 100644 (file)
@@ -60,7 +60,7 @@
 #include "mdd_internal.h"
 
 static int mdd_notify(struct obd_device *host, struct obd_device *watched,
-                      enum obd_notify_event ev, void *owner)
+                      enum obd_notify_event ev, void *owner, void *data)
 {
         struct mdd_device *mdd = owner;
         int rc = 0;
@@ -72,14 +72,17 @@ static int mdd_notify(struct obd_device *host, struct obd_device *watched,
                 case OBD_NOTIFY_ACTIVE:
                 case OBD_NOTIFY_SYNC:
                 case OBD_NOTIFY_SYNC_NONBLOCK:
-                        rc = md_do_upcall(NULL, &mdd->mdd_md_dev, MD_LOV_SYNC);
+                        rc = md_do_upcall(NULL, &mdd->mdd_md_dev,
+                                          MD_LOV_SYNC, data);
                         break;
                 case OBD_NOTIFY_CONFIG:
-                        rc = md_do_upcall(NULL, &mdd->mdd_md_dev, MD_LOV_CONFIG);
+                        rc = md_do_upcall(NULL, &mdd->mdd_md_dev,
+                                          MD_LOV_CONFIG, data);
                         break;
 #ifdef HAVE_QUOTA_SUPPORT
                 case OBD_NOTIFY_QUOTA:
-                        rc = md_do_upcall(NULL, &mdd->mdd_md_dev, MD_LOV_QUOTA);
+                        rc = md_do_upcall(NULL, &mdd->mdd_md_dev,
+                                          MD_LOV_QUOTA, data);
                         break;
 #endif
                 default:
@@ -354,7 +357,7 @@ int mdd_lov_set_md(const struct lu_env *env, struct mdd_object *pobj,
 /*
  * 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().
+ * now. Right? So just borrow the cl_fid_build_ino().
  */
 static obd_id mdd_lov_create_id(const struct lu_fid *fid)
 {
@@ -407,7 +410,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))
@@ -457,6 +466,7 @@ int mdd_lov_create(const struct lu_env *env, struct mdd_device *mdd,
                                 GOTO(out_oti, rc);
                 }
 
+                OBD_FAIL_TIMEOUT(OBD_FAIL_MDS_OPEN_WAIT_CREATE, 10);
                 rc = obd_create(lov_exp, oa, &lsm, oti);
                 if (rc) {
                         if (rc > 0) {
@@ -599,9 +609,8 @@ int mdd_lovobj_unlink(const struct lu_env *env, struct mdd_device *mdd,
 }
 
 /*
- * called with obj not locked. 
+ * called with obj locked. 
  */
-
 int mdd_lov_destroy(const struct lu_env *env, struct mdd_device *mdd,
                     struct mdd_object *obj, struct lu_attr *la)
 {
@@ -609,6 +618,11 @@ int mdd_lov_destroy(const struct lu_env *env, struct mdd_device *mdd,
         int                rc;
         ENTRY;
 
+        LASSERT(mdd_write_locked(env, obj) != 0);
+
+        if (unlikely(!S_ISREG(mdd_object_type(obj))))
+                RETURN(0);
+
         if (unlikely(la->la_nlink != 0)) {
                 CWARN("Attempt to destroy OSS object when nlink == %d\n",
                       la->la_nlink);
@@ -624,8 +638,8 @@ int mdd_lov_destroy(const struct lu_env *env, struct mdd_device *mdd,
 
         /* get lov ea */
 
-        rc = mdd_get_md_locked(env, obj, ma->ma_lmm, &ma->ma_lmm_size,
-                               XATTR_NAME_LOV);
+        rc = mdd_get_md(env, obj, ma->ma_lmm, &ma->ma_lmm_size,
+                        XATTR_NAME_LOV);
 
         if (rc <= 0) {
                 CWARN("Get lov ea failed for "DFID" rc = %d\n",
@@ -636,7 +650,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",
@@ -651,54 +665,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)));
@@ -708,8 +681,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;
@@ -725,10 +698,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);
@@ -799,12 +768,6 @@ static int mdd_osc_setattr_async(struct obd_device *obd, __u32 uid, __u32 gid,
                 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);
-                GOTO(out, rc);
-        }
-
         /* then fill oa */
         oinfo.oi_oa->o_uid = uid;
         oinfo.oi_oa->o_gid = gid;