Whamcloud - gitweb
change error msg to warning.
[fs/lustre-release.git] / lustre / mds / mds_audit_path.c
index 0dc21f6..c1ffd4b 100644 (file)
@@ -141,8 +141,8 @@ id2pid(struct obd_device *obd, struct lustre_id *id, struct lustre_id *pid,
         }
         inode = dentry->d_inode;
 
-        if (S_ISDIR(id_type(id))) {
-                LASSERT(S_ISDIR(inode->i_mode));
+        if (S_ISDIR(inode->i_mode)) {
+                //LASSERT(S_ISDIR(id_type(id)));
                 rc = mds_md_get_attr(obd, inode, &mea, &mea_size);
                 if (rc)
                         GOTO(out, rc);
@@ -159,7 +159,7 @@ id2pid(struct obd_device *obd, struct lustre_id *id, struct lustre_id *pid,
                 }
                                 
         } else {
-                LASSERT(!S_ISDIR(inode->i_mode));
+                //LASSERT(!S_ISDIR(id_type(id)));
                 *type = PP_FILE;
 read_pid:
                 rc = mds_read_inode_pid(obd, inode, pid);
@@ -197,9 +197,10 @@ static int local_parse_id(struct obd_device *obd, struct parseid_pkg *pkg)
         /* pp_id2 is present, which indicating we want to scan parent 
          * dir(pp_id2) to find the cross-ref entry(pp_id1) */
         if (id_fid(&pkg->pp_id2)) {
+                /* 
                 LASSERT(S_ISDIR(id_type(&pkg->pp_id1)));
                 LASSERT(S_ISDIR(id_type(&pkg->pp_id2)));
-
+                */
                 pkg->pp_type = PP_DIR;
                 goto scan;
         }
@@ -281,8 +282,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);
@@ -311,6 +321,7 @@ out:
         RETURN(rc);
 }
 
+#define ROOT_FID        2
 struct name_item {
         struct list_head link;
         char             name[NAME_MAX + 1];
@@ -318,8 +329,7 @@ struct name_item {
 
 int 
 mds_id2name(struct obd_device *obd, struct lustre_id *id, 
-            struct lustre_id *rootid, struct list_head *list, 
-            struct lustre_id *lastid)
+            struct list_head *list, struct lustre_id *lastid)
 {
         struct name_item *item;
         struct parseid_pkg *pkg;
@@ -331,7 +341,7 @@ mds_id2name(struct obd_device *obd, struct lustre_id *id,
                 RETURN(-ENOMEM);
 
         pkg->pp_id1 = *id;
-        while (!id_equal(&pkg->pp_id1, rootid)) {
+        while (id_fid(&pkg->pp_id1) != ROOT_FID) {
                 
                 rc = parse_id(obd, pkg);
                 if (rc) {
@@ -462,8 +472,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);
@@ -516,31 +535,19 @@ mds_audit_id2name(struct obd_device *obd, char **name, int *namelen,
         int rc = 0;
         struct list_head list, *pos, *n;
         struct name_item *item;
-        struct lustre_id parent_id, cur_id, rootid;
+        struct lustre_id parent_id, cur_id;
         ENTRY;
 
         *namelen = 0;
         INIT_LIST_HEAD(&list);
 
-        if (obd->u.mds.mds_num) {
-                int valsize = sizeof(rootid);
-                rc = obd_get_info(obd->u.mds.mds_md_exp, strlen("rootid"),
-                                  "rootid", &valsize, &rootid);
-                if (rc) {
-                        CERROR("cann't get rootid!\n");
-                        RETURN(rc);
-                }
-        } else {
-                rootid = obd->u.mds.mds_rootid;
-        }
-        
         cur_id = *id;
-        if (id_equal(&cur_id, &rootid))
+        if (id_fid(&cur_id) == ROOT_FID)
                 RETURN(0);
 next:
         memset(&parent_id, 0, sizeof(parent_id));
 
-        rc = mds_id2name(obd, &cur_id, &rootid, &list, &parent_id);
+        rc = mds_id2name(obd, &cur_id, &list, &parent_id);
         if (rc == -ENOENT) {
                 /* can't reconstruct name from id, turn to audit log */
                 LASSERT(id_fid(&parent_id));