From: wangdi Date: Sat, 9 Sep 2006 07:52:51 +0000 (+0000) Subject: Branch: b_new_cmd X-Git-Tag: v1_8_0_110~486^2~979 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=43789284c30b0a3a0ef0303297b150201d902936;p=fs%2Flustre-release.git Branch: b_new_cmd add mdd_txn callback to write objids in mds to fix runtests bugs --- diff --git a/lustre/include/lustre_mds.h b/lustre/include/lustre_mds.h index 6bba43a..8eee98d 100644 --- a/lustre/include/lustre_mds.h +++ b/lustre/include/lustre_mds.h @@ -85,6 +85,8 @@ int mds_log_op_setattr(struct obd_device *obd, struct inode *inode, struct lov_mds_md *lmm, int lmm_size, struct llog_cookie *logcookies, int cookies_size); +int mds_lov_write_objids(struct obd_device *obd); +void mds_lov_update_objids(struct obd_device *obd, obd_id *ids); /* ioctls for trying requests */ #define IOC_REQUEST_TYPE 'f' #define IOC_REQUEST_MIN_NR 30 diff --git a/lustre/mdd/mdd_handler.c b/lustre/mdd/mdd_handler.c index 581f8aa..7bc6f1e 100644 --- a/lustre/mdd/mdd_handler.c +++ b/lustre/mdd/mdd_handler.c @@ -482,26 +482,60 @@ static int mdd_mount(const struct lu_context *ctx, struct mdd_device *mdd) RETURN(rc); } +static int mdd_txn_start_cb(const struct lu_context *ctx, + struct txn_param *param, void *cookie) +{ + return 0; +} + +static int mdd_txn_stop_cb(const struct lu_context *ctx, + struct thandle *txn, void *cookie) +{ + struct mdd_device *mdd = cookie; + struct obd_device *obd = mdd2obd_dev(mdd); + + return mds_lov_write_objids(obd); +} + +static int mdd_txn_commit_cb(const struct lu_context *ctx, + struct thandle *txn, void *cookie) +{ + return 0; +} + static int mdd_device_init(const struct lu_context *ctx, struct lu_device *d, struct lu_device *next) { struct mdd_device *mdd = lu2mdd_dev(d); + struct dt_device *dt; int rc = 0; ENTRY; mdd->mdd_child = lu2dt_dev(next); + dt = mdd->mdd_child; + /* prepare transactions callbacks */ + mdd->mdd_txn_cb.dtc_txn_start = mdd_txn_start_cb; + mdd->mdd_txn_cb.dtc_txn_stop = mdd_txn_stop_cb; + mdd->mdd_txn_cb.dtc_txn_commit = mdd_txn_commit_cb; + mdd->mdd_txn_cb.dtc_cookie = mdd; + + dt_txn_callback_add(dt, &mdd->mdd_txn_cb); + RETURN(rc); } static struct lu_device *mdd_device_fini(const struct lu_context *ctx, struct lu_device *d) { - struct mdd_device *m = lu2mdd_dev(d); - struct lu_device *next = &m->mdd_child->dd_lu_dev; + struct mdd_device *mdd = lu2mdd_dev(d); + struct lu_device *next = &mdd->mdd_child->dd_lu_dev; + dt_txn_callback_del(mdd->mdd_child, &mdd->mdd_txn_cb); + return next; } + static void mdd_device_shutdown(const struct lu_context *ctxt, struct mdd_device *m) { diff --git a/lustre/mdd/mdd_internal.h b/lustre/mdd/mdd_internal.h index b45a933..5a21424 100644 --- a/lustre/mdd/mdd_internal.h +++ b/lustre/mdd/mdd_internal.h @@ -40,6 +40,7 @@ struct mdd_device { struct lu_fid mdd_root_fid; struct dt_device_param mdd_dt_conf; struct dt_object *mdd_orphans; + struct dt_txn_callback mdd_txn_cb; }; enum mod_flags { @@ -76,6 +77,7 @@ struct mdd_thread_info { struct lov_mds_md mti_lmm; struct obd_info mti_oi; struct orph_key mti_orph_key; + struct obd_trans_info mti_oti; }; int mdd_init_obd(const struct lu_context *ctxt, struct mdd_device *mdd, diff --git a/lustre/mdd/mdd_lov.c b/lustre/mdd/mdd_lov.c index 719d245..cd82381 100644 --- a/lustre/mdd/mdd_lov.c +++ b/lustre/mdd/mdd_lov.c @@ -333,6 +333,8 @@ int mdd_lov_create(const struct lu_context *ctxt, struct mdd_device *mdd, const void *eadata = spec->u.sp_ea.eadata; __u32 create_flags = spec->sp_cr_flags; int rc = 0; + struct obd_trans_info *oti = &mdd_ctx_info(ctxt)->mti_oti; + obd_id *ids = NULL; /* object IDs created */ ENTRY; if (create_flags & MDS_OPEN_DELAY_CREATE || @@ -355,6 +357,13 @@ int mdd_lov_create(const struct lu_context *ctxt, struct mdd_device *mdd, OBD_MD_FLMODE | OBD_MD_FLUID | OBD_MD_FLGID | OBD_MD_FLGROUP; oa->o_size = 0; + OBD_ALLOC(ids, obd->u.mds.mds_lov_desc.ld_tgt_count * sizeof(*ids)); + if (ids == NULL) + RETURN(-ENOMEM); + + oti_init(oti, NULL); + oti->oti_objid = ids; + if (!(create_flags & MDS_OPEN_HAS_OBJS)) { if (create_flags & MDS_OPEN_HAS_EA) { LASSERT(eadata != NULL); @@ -384,7 +393,7 @@ int mdd_lov_create(const struct lu_context *ctxt, struct mdd_device *mdd, if (rc) GOTO(out_oa, rc); } - rc = obd_create(lov_exp, oa, &lsm, NULL); + rc = obd_create(lov_exp, oa, &lsm, oti); if (rc) { if (rc > 0) { CERROR("create errro for "DFID": %d \n", @@ -444,6 +453,9 @@ int mdd_lov_create(const struct lu_context *ctxt, struct mdd_device *mdd, /* blksize should be changed after create data object */ la->la_valid |= LA_BLKSIZE; la->la_blksize = oa->o_blksize; + + mds_lov_update_objids(obd, ids); + rc = obd_packmd(lov_exp, lmm, lsm); if (rc < 0) { @@ -453,6 +465,9 @@ int mdd_lov_create(const struct lu_context *ctxt, struct mdd_device *mdd, *lmm_size = rc; rc = 0; out_oa: + if (ids) + OBD_FREE(ids, sizeof(*ids) * + obd->u.mds.mds_lov_desc.ld_tgt_count); obdo_free(oa); if (lsm) obd_free_memmd(lov_exp, &lsm); diff --git a/lustre/mds/mds_lov.c b/lustre/mds/mds_lov.c index b5f74e8..cb5330c 100644 --- a/lustre/mds/mds_lov.c +++ b/lustre/mds/mds_lov.c @@ -57,6 +57,7 @@ void mds_lov_update_objids(struct obd_device *obd, obd_id *ids) unlock_kernel(); EXIT; } +EXPORT_SYMBOL(mds_lov_update_objids); static int mds_lov_read_objids(struct obd_device *obd) { @@ -126,6 +127,7 @@ int mds_lov_write_objids(struct obd_device *obd) RETURN(rc); } +EXPORT_SYMBOL(mds_lov_write_objids); int mds_lov_clear_orphans(struct mds_obd *mds, struct obd_uuid *ost_uuid) {