From 6ce96bfe5619febdf7d0135b12a875387a7faf1e Mon Sep 17 00:00:00 2001 From: niu Date: Fri, 12 Aug 2005 06:17:18 +0000 Subject: [PATCH] - don't call obd_set_info() on the NULL mdc export on rename. - transfer only one audit record on one notify. - make sure the connection has been established before using the mdc export on name reconstruction. --- lustre/lmv/lmv_obd.c | 6 ++++++ lustre/mds/mds_audit_path.c | 22 ++++++++++++++++++++-- lustre/mds/mds_reint.c | 14 ++++++++++++-- lustre/smfs/audit.c | 4 +++- lustre/smfs/audit_transfer.c | 12 +++++++++--- 5 files changed, 50 insertions(+), 8 deletions(-) diff --git a/lustre/lmv/lmv_obd.c b/lustre/lmv/lmv_obd.c index 6f2e061..45017df 100644 --- a/lustre/lmv/lmv_obd.c +++ b/lustre/lmv/lmv_obd.c @@ -2103,6 +2103,12 @@ int lmv_set_info(struct obd_export *exp, obd_count keylen, RETURN(rc); } + if (keylen == strlen("chkconnect") && + memcpy(key, "chkconnect", keylen) == 0) { + rc = lmv_check_connect(obd); + RETURN(rc); + } + RETURN(-EINVAL); } diff --git a/lustre/mds/mds_audit_path.c b/lustre/mds/mds_audit_path.c index 54b5c9d..59d371f 100644 --- a/lustre/mds/mds_audit_path.c +++ b/lustre/mds/mds_audit_path.c @@ -281,8 +281,17 @@ static int parse_id(struct obd_device *obd, struct parseid_pkg *pkg) struct lmv_obd *lmv = &obd->u.mds.mds_md_obd->u.lmv; struct parseid_pkg *body; int size = sizeof(*body); - struct obd_export *exp = lmv->tgts[mds_num].ltd_exp; + struct obd_export *exp; + /* make sure connection established */ + rc = obd_set_info(obd->u.mds.mds_md_exp, strlen("chkconnect"), + "chkconnect", 0, NULL); + if (rc) + RETURN(rc); + + exp = lmv->tgts[mds_num].ltd_exp; + LASSERT(exp); + req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_MDS_VERSION, MDS_PARSE_ID, 1, &size, NULL); @@ -462,8 +471,17 @@ scan_audit_log(struct obd_device *obd, struct lustre_id *cur_id, struct lmv_obd *lmv = &obd->u.mds.mds_md_obd->u.lmv; struct parseid_pkg *body; int size = sizeof(*body); - struct obd_export *exp = lmv->tgts[mds_num].ltd_exp; + struct obd_export *exp; + /* make sure connection established */ + rc = obd_set_info(obd->u.mds.mds_md_exp, strlen("chkconnect"), + "chkconnect", 0, NULL); + if (rc) + RETURN(rc); + + exp = lmv->tgts[mds_num].ltd_exp; + LASSERT(exp); + req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_MDS_VERSION, MDS_PARSE_ID, 1, &size, NULL); diff --git a/lustre/mds/mds_reint.c b/lustre/mds/mds_reint.c index 8b68109..9e155c6 100644 --- a/lustre/mds/mds_reint.c +++ b/lustre/mds/mds_reint.c @@ -3288,6 +3288,7 @@ static int mds_reint_rename_create_name(struct mds_update_record *rec, int cleanup_phase = 0; int update_mode, rc = 0; struct lustre_id ids[2]; /* sid, pid */ + struct obd_export *set_exp; ENTRY; /* @@ -3323,7 +3324,11 @@ static int mds_reint_rename_create_name(struct mds_update_record *rec, GOTO(cleanup, rc); ids[0] = *(rec->ur_id1); - rc = obd_set_info(mds->mds_md_exp, strlen("ids"), "ids", + if (id_group(ids) == mds->mds_num) + set_exp = req->rq_export; + else + set_exp = mds->mds_md_exp; + rc = obd_set_info(set_exp, strlen("ids"), "ids", sizeof(struct lustre_id) * 2, ids); EXIT; @@ -3613,6 +3618,7 @@ static int mds_reint_rename(struct mds_update_record *rec, int offset, if (de_old->d_flags & DCACHE_CROSS_REF) { struct lustre_id old_id; + struct obd_export *set_exp; mds_pack_dentry2id(obd, &old_id, de_old, 1); @@ -3628,7 +3634,11 @@ static int mds_reint_rename(struct mds_update_record *rec, int offset, GOTO(cleanup, rc); ids[0] = old_id; - rc = obd_set_info(mds->mds_md_exp, strlen("ids"), "ids", + if (id_group(ids) == mds->mds_num) + set_exp = req->rq_export; + else + set_exp = mds->mds_md_exp; + rc = obd_set_info(set_exp, strlen("ids"), "ids", sizeof(struct lustre_id) * 2, ids); GOTO(cleanup, rc); diff --git a/lustre/smfs/audit.c b/lustre/smfs/audit.c index e37eed1..0e9d572 100644 --- a/lustre/smfs/audit.c +++ b/lustre/smfs/audit.c @@ -320,10 +320,12 @@ static int smfs_audit_post_op(hook_op code, struct inode * inode, void * msg, rec->nid = current->user->nid; rec->time = cur_time.tv_sec * USEC_PER_SEC + cur_time.tv_usec; - len = handler[code](inode, msg, priv, (char*)rec, &llh->lrh_type); + LASSERT(llh->lrh_type == SMFS_AUDIT_GEN_REC || + llh->lrh_type == SMFS_AUDIT_NAME_REC); + llh->lrh_len = size_round(len); rc = llog_cat_add_rec(priv->audit_ctxt->loc_handle, llh, NULL, diff --git a/lustre/smfs/audit_transfer.c b/lustre/smfs/audit_transfer.c index 19320af..5ae1c87 100644 --- a/lustre/smfs/audit_transfer.c +++ b/lustre/smfs/audit_transfer.c @@ -196,7 +196,7 @@ static int transfer_cb(struct llog_handle *llh, struct llog_rec_hdr *rec, { struct obd_device *obd = llh->lgh_ctxt->loc_obd; struct audit_record *ad_rec; - + struct llog_cookie cookie; ENTRY; if (!(le32_to_cpu(llh->lgh_hdr->llh_flags) & LLOG_F_IS_PLAIN)) { @@ -213,9 +213,15 @@ static int transfer_cb(struct llog_handle *llh, struct llog_rec_hdr *rec, LASSERT(ad_rec->opcode < AUDIT_MAX); + cookie.lgc_lgl = llh->lgh_id; + cookie.lgc_subsys = LLOG_AUDIT_ORIG_CTXT; + cookie.lgc_index = le32_to_cpu(rec->lrh_index); + transfer_record(obd, ad_rec, rec->lrh_type, data); - RETURN(LLOG_DEL_RECORD); + llog_cancel(llh->lgh_ctxt, 1, &cookie, 0, NULL); + + RETURN(LLOG_PROC_BREAK); } static int audit_transfer(struct transfer_item *ti) @@ -225,7 +231,7 @@ static int audit_transfer(struct transfer_item *ti) ENTRY; rc = llog_cat_process(llh, (llog_cb_t)&transfer_cb, ti->id2name); - if (rc) + if (rc != LLOG_PROC_BREAK) CERROR("process catalog log failed: rc(%d)\n", rc); RETURN(0); -- 1.8.3.1