From 81954f77625848c56790eaa88849dcff3fa40a58 Mon Sep 17 00:00:00 2001 From: huanghua Date: Sun, 10 Sep 2006 17:11:58 +0000 Subject: [PATCH] (1) add some debug code for last_rcvd; (2) allocate memory for d_attr(->lmm,cookie) which is passed into mdt_mfd_close() --- lustre/mdt/mdt_handler.c | 29 +++++++++++++++++++++++----- lustre/mdt/mdt_recovery.c | 48 ++++++++++++++++++++++++++++++++++++----------- 2 files changed, 61 insertions(+), 16 deletions(-) diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index 9f842c2..834c44e 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -2635,7 +2635,6 @@ static void mdt_fini(const struct lu_context *ctx, struct mdt_device *m) ENTRY; target_cleanup_recovery(m->mdt_md_dev.md_lu_dev.ld_obd); - mdt_fs_cleanup(ctx, m); ping_evictor_stop(); mdt_stop_ptlrpc_service(m); @@ -2649,6 +2648,7 @@ static void mdt_fini(const struct lu_context *ctx, struct mdt_device *m) mdt_fld_fini(ctx, m); + mdt_fs_cleanup(ctx, m); /* finish the stack */ mdt_stack_fini(ctx, m, md2lu_dev(m->mdt_child)); @@ -3018,10 +3018,13 @@ static int mdt_init_export(struct obd_export *exp) static int mdt_destroy_export(struct obd_export *export) { struct mdt_export_data *med; - struct obd_device *obd = export->exp_obd; - struct mdt_device *mdt; + struct obd_device *obd = export->exp_obd; + struct mdt_device *mdt; struct mdt_thread_info *info; - struct lu_context ctxt; + struct lu_context ctxt; + struct md_attr *ma; + int lmm_size; + int cookie_size; int rc = 0; ENTRY; @@ -3044,6 +3047,17 @@ static int mdt_destroy_export(struct obd_export *export) info = lu_context_key_get(&ctxt, &mdt_thread_key); LASSERT(info != NULL); memset(info, 0, sizeof *info); + + ma = &info->mti_attr; + lmm_size = mdt->mdt_max_mdsize; + cookie_size = mdt->mdt_max_cookiesize; + OBD_ALLOC(ma->ma_lmm, lmm_size); + OBD_ALLOC(ma->ma_cookie, cookie_size); + + if (ma->ma_lmm == NULL || ma->ma_cookie == NULL) + GOTO(out, rc = -ENOMEM); + ma->ma_need = MA_LOV | MA_COOKIE; + /* Close any open files (which may also cause orphan unlinking). */ spin_lock(&med->med_open_lock); while (!list_empty(&med->med_open_head)) { @@ -3057,7 +3071,7 @@ static int mdt_destroy_export(struct obd_export *export) class_handle_unhash(&mfd->mfd_handle); list_del_init(&mfd->mfd_list); spin_unlock(&med->med_open_lock); - mdt_mfd_close(&ctxt, mdt, mfd, &info->mti_attr); + mdt_mfd_close(&ctxt, mdt, mfd, ma); /* TODO: if we close the unlinked file, * we need to remove it's objects from OST */ mdt_object_put(&ctxt, o); @@ -3066,6 +3080,11 @@ static int mdt_destroy_export(struct obd_export *export) spin_unlock(&med->med_open_lock); mdt_client_free(&ctxt, mdt, med); +out: + if (ma->ma_lmm) + OBD_FREE(ma->ma_lmm, lmm_size); + if (ma->ma_cookie) + OBD_FREE(ma->ma_cookie, cookie_size); lu_context_exit(&ctxt); lu_context_fini(&ctxt); diff --git a/lustre/mdt/mdt_recovery.c b/lustre/mdt/mdt_recovery.c index f8a6148..b5bd3c1 100644 --- a/lustre/mdt/mdt_recovery.c +++ b/lustre/mdt/mdt_recovery.c @@ -45,9 +45,7 @@ static /*inline*/ ssize_t mdt_read_record(const struct lu_context *ctx, { int rc; - /* FIXME: this should be an ASSERT */ - if (dt == NULL) - return -EFAULT; + LASSERTF(dt != NULL, "dt is NULL when we want to read record\n"); rc = dt->do_body_ops->dbo_read(ctx, dt, buf, count, pos); @@ -67,9 +65,7 @@ static /*inline*/ ssize_t mdt_write_record(const struct lu_context *ctx, { int rc; - /* FIXME: this should be an ASSERT */ - if (dt == NULL) - return -EFAULT; + LASSERTF(dt != NULL, "dt is NULL when we want to write record\n"); rc = dt->do_body_ops->dbo_write(ctx, dt, buf, count, pos, th); if (rc == count) @@ -94,9 +90,19 @@ static int mdt_write_last_rcvd_header(const struct lu_context *ctx, struct mdt_server_data *msd, struct thandle *th) { + int rc; loff_t off = 0; - return mdt_write_record(ctx, mdt->mdt_last_rcvd, - msd, sizeof(*msd), &off, th); + + rc = mdt_write_record(ctx, mdt->mdt_last_rcvd, + msd, sizeof(*msd), &off, th); + + CDEBUG(D_INFO, "write last_rcvd header rc = %d:\n" + "uuid = %s\n" + "last_transno = "LPU64"\n", + rc, + msd->msd_uuid, + msd->msd_last_transno); + return rc; } static int mdt_read_last_rcvd(const struct lu_context *ctx, @@ -112,8 +118,29 @@ static int mdt_write_last_rcvd(const struct lu_context *ctx, struct mdt_client_data *mcd, loff_t *off, struct thandle *th) { - return mdt_write_record(ctx, mdt->mdt_last_rcvd, - mcd, sizeof(*mcd), off, th); + int rc; + rc = mdt_write_record(ctx, mdt->mdt_last_rcvd, + mcd, sizeof(*mcd), off, th); + + CDEBUG(D_INFO, "write mcd rc = %d:\n" + "uuid = %s\n" + "last_transno = "LPU64"\n" + "last_xid = "LPU64"\n" + "last_result = %d\n" + "last_data = %d\n" + "last_close_transno = "LPU64"\n" + "last_close_xid = "LPU64"\n" + "last_close_result = %d\n", + rc, + mcd->mcd_uuid, + mcd->mcd_last_transno, + mcd->mcd_last_xid, + mcd->mcd_last_result, + mcd->mcd_last_data, + mcd->mcd_last_close_transno, + mcd->mcd_last_close_xid, + mcd->mcd_last_close_result); + return rc; } static int mdt_init_clients_data(const struct lu_context *ctx, @@ -706,7 +733,6 @@ void mdt_fs_cleanup(const struct lu_context *ctx, struct mdt_device *mdt) dt_txn_callback_del(mdt->mdt_bottom, &mdt->mdt_txn_cb); class_disconnect_exports(obd); /* cleans up client info too */ - if (mdt->mdt_last_rcvd) lu_object_put(ctx, &mdt->mdt_last_rcvd->do_lu); mdt->mdt_last_rcvd = NULL; -- 1.8.3.1