From: tappro Date: Thu, 31 Aug 2006 21:40:23 +0000 (+0000) Subject: - add mdt_iocontrol() X-Git-Tag: v1_8_0_110~486^2~1049 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=85a1596396a6563260c4e39b6b62f7a907c77381;p=fs%2Flustre-release.git - add mdt_iocontrol() - move reply filling with transaction data to the transaction stop callback - special methods mdt_open_transno() to update transno for open --- diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index 9f07e00..799ec9b 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -476,7 +476,7 @@ static int lu_device_is_mdt(struct lu_device *d) return ergo(d != NULL && d->ld_ops != NULL, d->ld_ops == &mdt_lu_ops); } -static struct mdt_device *mdt_dev(struct lu_device *d) +static inline struct mdt_device *mdt_dev(struct lu_device *d) { LASSERT(lu_device_is_mdt(d)); return container_of0(d, struct mdt_device, mdt_md_dev.md_lu_dev); @@ -1228,11 +1228,13 @@ static int mdt_req_handle(struct mdt_thread_info *info, /* If we're DISCONNECTing, the mdt_export_data is already freed */ +#if 0 if (h->mh_opc != MDS_DISCONNECT && h->mh_opc != MDS_READPAGE && h->mh_opc != LDLM_ENQUEUE) { mdt_finish_reply(info, req->rq_status); } +#endif RETURN(result); } @@ -1655,9 +1657,9 @@ static int mdt_intent_reint(enum mdt_it_code opcode, rep->lock_policy_res2 = rc; mdt_set_disposition(info, rep, DISP_IT_EXECD); - +#if 0 mdt_finish_reply(info, rc); - +#endif RETURN(ELDLM_LOCK_ABORTED); } @@ -2717,6 +2719,36 @@ static int mdt_upcall(const struct lu_context *ctx, struct md_device *md, RETURN(rc); } +static int mdt_iocontrol(unsigned int cmd, struct obd_export *exp, int len, + void *karg, void *uarg) +{ + struct lu_context ctxt; + struct mdt_device *mdt = mdt_dev(exp->exp_obd->obd_lu_dev); + struct dt_device *dt = mdt->mdt_bottom; + int rc = 0; + + ENTRY; + CDEBUG(D_IOCTL, "handling ioctl cmd %#x\n", cmd); + rc = lu_context_init(&ctxt, LCT_MD_THREAD); + if (rc) + RETURN(rc); + lu_context_enter(&ctxt); + switch (cmd) { + case OBD_IOC_SYNC: + dt->dd_ops->dt_dev_sync(&ctxt, dt); + break; + case OBD_IOC_SET_READONLY: + dt->dd_ops->dt_dev_ro(&ctxt, dt, 1); + break; + default: + CDEBUG(D_INFO, "Trying old MDS iocontrol %x\n", cmd); + rc = -EOPNOTSUPP; + break; + } + lu_context_exit(&ctxt); + lu_context_fini(&ctxt); + RETURN(rc); +} static struct obd_ops mdt_obd_device_ops = { .o_owner = THIS_MODULE, @@ -2724,6 +2756,7 @@ static struct obd_ops mdt_obd_device_ops = { .o_disconnect = mdt_obd_disconnect, .o_init_export = mdt_init_export, .o_destroy_export = mdt_destroy_export, + .o_iocontrol = mdt_iocontrol }; static struct lu_device* mdt_device_fini(const struct lu_context *ctx, diff --git a/lustre/mdt/mdt_open.c b/lustre/mdt/mdt_open.c index 6fc5e66..fd03cf2 100644 --- a/lustre/mdt/mdt_open.c +++ b/lustre/mdt/mdt_open.c @@ -174,6 +174,30 @@ int mdt_query_write_access(struct mdt_device *mdt, struct mdt_object *o) RETURN(wc); } +/* there can be no real transaction so prepare the fake one */ +static void mdt_open_transno(struct mdt_thread_info* info) +{ + struct mdt_device *mdt = info->mti_mdt; + struct ptlrpc_request *req = mdt_info_req(info); + + if (info->mti_transno != 0) + return; + + CDEBUG(D_INODE, "open transno = %llu, last_committed = %llu\n", + info->mti_transno, + req->rq_export->exp_obd->obd_last_committed); + + spin_lock(&mdt->mdt_transno_lock); + info->mti_transno = ++ mdt->mdt_last_transno; + req->rq_transno = info->mti_transno; + lustre_msg_set_transno(req->rq_repmsg, info->mti_transno); + + target_committed_to_req(req); + + spin_unlock(&mdt->mdt_transno_lock); + lustre_msg_set_last_xid(req->rq_repmsg, req->rq_xid); +} + static int mdt_mfd_open(struct mdt_thread_info *info, struct mdt_object *p, struct mdt_object *o, @@ -208,7 +232,8 @@ static int mdt_mfd_open(struct mdt_thread_info *info, */ if (islnk || (!isreg && !isdir && (req->rq_export->exp_connect_flags & OBD_CONNECT_NODEVOH))) { - info->mti_trans_flags |= MDT_NONEED_TRANSNO; + //info->mti_trans_flags |= MDT_NONEED_TRANSNO; + lustre_msg_set_transno(req->rq_repmsg, 0); RETURN(0); } @@ -294,9 +319,11 @@ static int mdt_mfd_open(struct mdt_thread_info *info, spin_unlock(&med->med_open_lock); repbody->handle.cookie = mfd->mfd_handle.h_cookie; + + mdt_open_transno(info); + } else rc = -ENOMEM; - RETURN(rc); } @@ -546,9 +573,6 @@ int mdt_cross_open(struct mdt_thread_info* info, const struct lu_fid *fid, rc = lu_object_exists(&o->mot_obj.mo_lu); if (rc > 0) { struct mdt_device *mdt = info->mti_mdt; - spin_lock(&mdt->mdt_transno_lock); - info->mti_transno = ++ mdt->mdt_last_transno; - spin_unlock(&mdt->mdt_transno_lock); rc = mo_attr_get(info->mti_ctxt, mdt_object_child(o), ma); if (rc == 0) rc = mdt_mfd_open(info, NULL, o, flags, 0, rep); @@ -705,9 +729,6 @@ int mdt_open(struct mdt_thread_info *info) repbody->valid |= (OBD_MD_FLID | OBD_MD_MDS); GOTO(out_child, result = 0); } - spin_lock(&mdt->mdt_transno_lock); - info->mti_transno = ++ mdt->mdt_last_transno; - spin_unlock(&mdt->mdt_transno_lock); } /* Try to open it now. */ result = mdt_mfd_open(info, parent, child, create_flags, diff --git a/lustre/mdt/mdt_recovery.c b/lustre/mdt/mdt_recovery.c index 0b4928f..982eb19 100644 --- a/lustre/mdt/mdt_recovery.c +++ b/lustre/mdt/mdt_recovery.c @@ -489,7 +489,6 @@ free: * last_rcvd & last_committed update callbacks */ static int mdt_update_last_rcvd(struct mdt_thread_info *mti, - struct dt_device *dt, struct thandle *th) { struct mdt_device *mdt = mti->mti_mdt; @@ -556,6 +555,11 @@ static int mdt_txn_start_cb(const struct lu_context *ctx, return 0; } +static inline __u64 req_exp_last_xid(struct ptlrpc_request *req) +{ + return le64_to_cpu(req->rq_export->exp_mdt_data.med_mcd->mcd_last_xid); +} + /* Update last_rcvd records with latests transaction data */ static int mdt_txn_stop_cb(const struct lu_context *ctx, struct thandle *txn, void *cookie) @@ -563,11 +567,19 @@ static int mdt_txn_stop_cb(const struct lu_context *ctx, struct mdt_device *mdt = cookie; struct mdt_txn_info *txi; struct mdt_thread_info *mti; - + struct ptlrpc_request *req; + /* transno in two contexts - for commit_cb and for thread */ txi = lu_context_key_get(&txn->th_ctx, &mdt_txn_key); mti = lu_context_key_get(ctx, &mdt_thread_key); + /* FIXME: don't handle requests from SEQ/FLD, + * should be fixed + */ + if (mti->mti_mdt == NULL) { + txi->txi_transno = 0; + return 0; + } /*TODO: checks for recovery cases, see mds_finish_transno */ spin_lock(&mdt->mdt_transno_lock); if (txn->th_result != 0) { @@ -583,11 +595,27 @@ static int mdt_txn_stop_cb(const struct lu_context *ctx, if (mti->mti_transno > mdt->mdt_last_transno) mdt->mdt_last_transno = mti->mti_transno; } + spin_unlock(&mdt->mdt_transno_lock); + + /* filling reply data */ + req = mdt_info_req(mti); + + /* sometimes the reply message has not been successfully packed */ + LASSERT(req != NULL && req->rq_repmsg != NULL); + + CDEBUG(D_INODE, "transno = %llu, last_committed = %llu\n", + mti->mti_transno, req->rq_export->exp_obd->obd_last_committed); + + spin_lock(&mdt->mdt_transno_lock); + req->rq_transno = mti->mti_transno; + lustre_msg_set_transno(req->rq_repmsg, mti->mti_transno); + target_committed_to_req(req); + lustre_msg_set_last_xid(req->rq_repmsg, req_exp_last_xid(req)); /* save transno for the commit callback */ txi->txi_transno = mti->mti_transno; spin_unlock(&mdt->mdt_transno_lock); - return 0;//mdt_update_last_rcvd(mti, dev, txn); + return mdt_update_last_rcvd(mti, txn); } /* commit callback, need to update last_commited value */