Whamcloud - gitweb
- don't call obd_set_info() on the NULL mdc export on rename.
authorniu <niu>
Fri, 12 Aug 2005 06:17:18 +0000 (06:17 +0000)
committerniu <niu>
Fri, 12 Aug 2005 06:17:18 +0000 (06:17 +0000)
- 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
lustre/mds/mds_audit_path.c
lustre/mds/mds_reint.c
lustre/smfs/audit.c
lustre/smfs/audit_transfer.c

index 6f2e061..45017df 100644 (file)
@@ -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);
 }
 
index 54b5c9d..59d371f 100644 (file)
@@ -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);
index 8b68109..9e155c6 100644 (file)
@@ -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);
index e37eed1..0e9d572 100644 (file)
@@ -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,
index 19320af..5ae1c87 100644 (file)
@@ -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);