#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;
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, data);
+ break;
+#endif
default:
CDEBUG(D_INFO, "Unhandled notification %#x\n", ev);
}
*md_size = 0;
rc = 0;
} else if (rc < 0) {
- CERROR("Error %d reading eadata \n", rc);
+ CERROR("Error %d reading eadata - %d\n", rc, *md_size);
} else {
/* XXX: Convert lov EA but fixed after verification test. */
*md_size = rc;
RETURN(rc);
obd_free_memmd(lov_exp, &lsm);
- rc = mdd_xattr_set_txn(env, obj, buf, MDS_LOV_MD_NAME, 0, handle);
+ rc = mdd_xattr_set_txn(env, obj, buf, XATTR_NAME_LOV, 0, handle);
CDEBUG(D_INFO, "set lov ea of "DFID" rc %d \n", PFID(mdo2fid(obj)), rc);
RETURN(rc);
lum->lmm_stripe_offset == (typeof(lum->lmm_stripe_offset))(-1) &&
lum->lmm_magic != LOV_USER_MAGIC_V3) {
rc = mdd_xattr_set_txn(env, obj, &LU_BUF_NULL,
- MDS_LOV_MD_NAME, 0, handle);
+ XATTR_NAME_LOV, 0, handle);
if (rc == -ENODATA)
rc = 0;
CDEBUG(D_INFO, "delete lov ea of "DFID" rc %d \n",
rc = mdd_lov_set_stripe_md(env, child, buf, handle);
} else {
rc = mdd_xattr_set_txn(env, child, buf,
- MDS_LOV_MD_NAME, 0, handle);
+ XATTR_NAME_LOV, 0, handle);
}
} else if (S_ISDIR(mode)) {
if (lmmp == NULL && lmm_size == 0) {
/* Get parent dir stripe and set */
if (pobj != NULL)
rc = mdd_get_md_locked(env, pobj, lmm, &size,
- MDS_LOV_MD_NAME);
+ XATTR_NAME_LOV);
if (rc > 0) {
buf = mdd_buf_get(env, lmm, size);
rc = mdd_xattr_set_txn(env, child, buf,
- MDS_LOV_MD_NAME, 0, handle);
+ XATTR_NAME_LOV, 0, handle);
if (rc)
CERROR("error on copy stripe info: rc "
"= %d\n", 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().
+ * now. Right? So just borrow the cl_fid_build_ino().
*/
static obd_id mdd_lov_create_id(const struct lu_fid *fid)
{
return fid_flatten(fid);
}
-static void mdd_lov_update_objids(struct obd_device *obd, struct lov_mds_md *lmm)
+int mdd_lov_objid_prepare(struct mdd_device *mdd, struct lov_mds_md *lmm)
{
- struct mds_obd *mds = &obd->u.mds;
- int j;
- struct lov_ost_data_v1 *lmm_objects;
- ENTRY;
-
- /* if we create file without objects - lmm is NULL */
- if (lmm == NULL)
- return;
-
- if (le32_to_cpu(lmm->lmm_magic) == LOV_MAGIC_V3)
- lmm_objects = ((struct lov_mds_md_v3 *)lmm)->lmm_objects;
- else
- lmm_objects = lmm->lmm_objects;
-
- for (j = 0; j < le32_to_cpu(lmm->lmm_stripe_count); j++) {
- int i = le32_to_cpu(lmm_objects[j].l_ost_idx);
- obd_id id = le64_to_cpu(lmm_objects[j].l_object_id);
- int page = i / OBJID_PER_PAGE();
- int idx = i % OBJID_PER_PAGE();
- obd_id *data = mds->mds_lov_page_array[page];
-
- CDEBUG(D_INODE,"update last object for ost %d - new %llu"
- " old %llu\n", i, id, data[idx]);
- if (id > data[idx]) {
- data[idx] = id;
- cfs_bitmap_set(mds->mds_lov_page_dirty, page);
- }
- }
- EXIT;
+ /* copy mds_lov code is using wrong layer */
+ return mds_lov_prepare_objids(mdd->mdd_obd_dev, lmm);
}
void mdd_lov_objid_update(struct mdd_device *mdd, struct lov_mds_md *lmm)
{
- mdd_lov_update_objids(mdd->mdd_obd_dev, lmm);
+ /* copy mds_lov code is using wrong layer */
+ mds_lov_update_objids(mdd->mdd_obd_dev, lmm);
}
void mdd_lov_create_finish(const struct lu_env *env, struct mdd_device *mdd,
struct lov_mds_md *lmm, int lmm_size,
const struct md_op_spec *spec)
{
- if (lmm && !spec->u.sp_ea.no_lov_create)
+ if (lmm && !spec->no_create)
OBD_FREE(lmm, lmm_size);
}
int rc = 0;
ENTRY;
- if (!md_should_create(create_flags))
+ if (!md_should_create(create_flags)) {
+ *lmm_size = 0;
RETURN(0);
-
+ }
oti_init(oti, NULL);
/* replay case, has objects already, only get lov from eadata */
- if (spec->u.sp_ea.no_lov_create != 0) {
+ 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))
rc = mdd_get_md_locked(env, parent, _lmm,
&_lmm_size,
- MDS_LOV_MD_NAME);
+ XATTR_NAME_LOV);
if (rc > 0)
rc = obd_iocontrol(OBD_IOC_LOV_SETSTRIPE,
- lov_exp, 0, &lsm, _lmm);
+ lov_exp, *lmm_size,
+ &lsm, _lmm);
+
if (rc)
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) {
CERROR("Cannot pack lsm, err = %d\n", rc);
GOTO(out_oti, rc);
}
+ if (mdd_lov_objid_prepare(mdd, *lmm) != 0) {
+ CERROR("Not have memory for update objid\n");
+ OBD_FREE(*lmm, rc);
+ *lmm = NULL;
+ GOTO(out_oti, rc = -ENOMEM);
+ }
*lmm_size = rc;
rc = 0;
EXIT;
}
/*
- * 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)
{
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);
/* get lov ea */
- rc = mdd_get_md_locked(env, obj, ma->ma_lmm, &ma->ma_lmm_size,
- MDS_LOV_MD_NAME);
+ 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",
}
ma->ma_valid = MA_LOV;
-
+
rc = mdd_unlink_log(env, mdd, obj, ma);
if (rc) {
CWARN("mds unlink log for "DFID" failed: %d\n",
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)));
ma->ma_valid |= MA_COOKIE;
}
return 0;
}
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;
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);
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;