From fc6a639d5514117889a584530b8293d4fd9f6ca2 Mon Sep 17 00:00:00 2001 From: tappro Date: Mon, 10 Jul 2006 15:52:18 +0000 Subject: [PATCH] add transaction callback in mdt --- lustre/mdt/mdt_fs.c | 56 +++++++++++++++++++++++++++++++++++++++++++---- lustre/mdt/mdt_internal.h | 9 ++++++-- 2 files changed, 59 insertions(+), 6 deletions(-) diff --git a/lustre/mdt/mdt_fs.c b/lustre/mdt/mdt_fs.c index 7afdbf5..d89e9f0 100644 --- a/lustre/mdt/mdt_fs.c +++ b/lustre/mdt/mdt_fs.c @@ -391,6 +391,42 @@ out: return rc; } +/* + * last_rcvd update callbacks + */ + +#define MDT_TXN_LAST_RCVD_CREDITS 1 +/* add credits for last_rcvd update */ +static int mdt_txn_start_cb(const struct lu_context *ctx, + struct dt_device *dev, + struct txn_param *param, void *cookie) +{ + param->tp_credits += MDT_TXN_LAST_RCVD_CREDITS; + return 0; +} +/* Update last_rcvd records with latests transaction data */ +static int mdt_txn_stop_cb(const struct lu_context *ctx, + struct dt_device *dev, + struct thandle *txn, void *cookie) +{ +/* + struct mdt_device *mdt = cookie; + TODO: write last_rcvd +*/ + return 0; +} +/* + * commit callback, need to update last_commited value */ +static int mdt_txn_commit_cb(const struct lu_context *ctx, + struct dt_device *dev, + struct thandle *txn, void *cookie) +{ + struct mdt_device *mdt = cookie; + /* TODO: update mdt_last_commited, need current transno here */ + ++ mdt->mdt_last_committed; + return 0; +} + int mdt_fs_setup(const struct lu_context *ctxt, struct mdt_device *mdt) { @@ -399,9 +435,17 @@ int mdt_fs_setup(const struct lu_context *ctxt, int rc; ENTRY; + /* prepare transactions callbacks */ + mdt->mdt_txn_cb.dtc_txn_start = mdt_txn_start_cb; + mdt->mdt_txn_cb.dtc_txn_stop = mdt_txn_stop_cb; + mdt->mdt_txn_cb.dtc_txn_commit = mdt_txn_commit_cb; + mdt->mdt_txn_cb.dtc_cookie = mdt; + + dt_txn_callback_add(mdt->mdt_bottom, &mdt->mdt_txn_cb); +/* last = dt_store_open(ctxt, mdt->mdt_bottom, LAST_RCVD, &last_fid); if(!IS_ERR(last)) { - mdt->mdt_last = last; + mdt->mdt_last_rcvd = last; rc = mdt_init_server_data(ctxt, mdt); if (rc) { lu_object_put(ctxt, &last->do_lu); @@ -411,6 +455,7 @@ int mdt_fs_setup(const struct lu_context *ctxt, rc = PTR_ERR(last); CERROR("cannot open %s: rc = %d\n", LAST_RCVD, rc); } +*/ return rc; } @@ -419,11 +464,14 @@ void mdt_fs_cleanup(const struct lu_context *ctxt, struct mdt_device *mdt) { struct obd_device *obd = mdt->mdt_md_dev.md_lu_dev.ld_obd; + + /* remove transaction callback */ + dt_txn_callback_del(mdt->mdt_bottom, &mdt->mdt_txn_cb); class_disconnect_exports(obd); /* cleans up client info too */ - if (mdt->mdt_last) - lu_object_put(ctxt, &mdt->mdt_last->do_lu); - mdt->mdt_last = NULL; + if (mdt->mdt_last_rcvd) + lu_object_put(ctxt, &mdt->mdt_last_rcvd->do_lu); + mdt->mdt_last_rcvd = NULL; } diff --git a/lustre/mdt/mdt_internal.h b/lustre/mdt/mdt_internal.h index f94e0ef..32184e0 100644 --- a/lustre/mdt/mdt_internal.h +++ b/lustre/mdt/mdt_internal.h @@ -121,6 +121,11 @@ struct mdt_device { spinlock_t mdt_transno_lock; __u64 mdt_last_transno; __u64 mdt_last_committed; + /* transaction callbacks */ + struct dt_txn_callback mdt_txn_cb; + /* last_rcvd file */ + struct dt_object *mdt_last_rcvd; + /* these values should be updated from lov if necessary. * or should be placed somewhere else. */ int mdt_max_mdsize; @@ -128,8 +133,7 @@ struct mdt_device { __u64 mdt_mount_count; struct mdt_server_data mdt_msd; - unsigned long mdt_client_bitmap[LR_MAX_CLIENTS / sizeof(long)]; - struct dt_object *mdt_last; + unsigned long mdt_client_bitmap[(LR_MAX_CLIENTS >> 3) / sizeof(long)]; }; /*XXX copied from mds_internal.h */ @@ -230,6 +234,7 @@ struct mdt_thread_info { * XXX this is probably huge overkill, because statfs is not that * frequent. */ + struct kstatfs mti_sfs; /* temporary stuff used by thread */ -- 1.8.3.1