Whamcloud - gitweb
- make clo_split enum type
authortappro <tappro>
Wed, 1 Nov 2006 23:20:28 +0000 (23:20 +0000)
committertappro <tappro>
Wed, 1 Nov 2006 23:20:28 +0000 (23:20 +0000)
- fix is_subdir() -EREMOTE issues
- avoid usage of mdt_body  mode field to store the result

lustre/cmm/cmm_internal.h
lustre/cmm/mdc_object.c
lustre/mdc/mdc_request.c
lustre/mdd/mdd_dir.c
lustre/mdt/mdt_handler.c
lustre/mdt/mdt_reint.c

index 1d3357d..a7dae08 100644 (file)
@@ -80,7 +80,7 @@ static inline struct lu_device *cmm2lu_dev(struct cmm_device *d)
 }
 
 #ifdef HAVE_SPLIT_SUPPORT
-enum {
+enum cmm_split_state {
         CMM_SPLIT_UNKNOWN,
         CMM_SPLIT_NONE,
         CMM_SPLIT_NEEDED,
@@ -88,16 +88,17 @@ enum {
         CMM_SPLIT_DENIED
 };
 #endif
+
 struct cmm_object {
         struct md_object cmo_obj;
 };
 
 /* local CMM object */
 struct cml_object {
-        struct cmm_object cmm_obj;
+        struct cmm_object    cmm_obj;
 #ifdef HAVE_SPLIT_SUPPORT
         /* split state of object (for dirs only)*/
-        __u32             clo_split;
+        enum cmm_split_state clo_split;
 #endif
 };
 
index 101503f..7d4d111 100644 (file)
@@ -248,6 +248,7 @@ static int mdc_object_create(const struct lu_env *env,
         ENTRY;
 
         LASSERT(spec->u.sp_pfid != NULL);
+        LASSERT(S_ISDIR(la->la_mode));
         mci = mdc_info_init(env);
         mci->mci_opdata.fid2 = *lu_object_fid(&mo->mo_lu);
         /* parent fid is needed to create dotdot on the remote node */
@@ -459,7 +460,11 @@ static int mdc_rename_tgt(const struct lu_env *env, struct md_object *mo_p,
 
         RETURN(rc);
 }
-
+/* 
+ * Return resulting fid in sfid
+ * 0: fids are not relatives
+ * fid: fid at which search stopped
+ */
 static int mdc_is_subdir(const struct lu_env *env, struct md_object *mo,
                          const struct lu_fid *fid, struct lu_fid *sfid)
 {
@@ -473,21 +478,14 @@ static int mdc_is_subdir(const struct lu_env *env, struct md_object *mo,
 
         rc = md_is_subdir(mc->mc_desc.cl_exp, lu_object_fid(&mo->mo_lu),
                           fid, &mci->mci_req);
-        if (rc)
-                GOTO(out, rc);
-
-        body = lustre_msg_buf(mci->mci_req->rq_repmsg, REPLY_REC_OFF,
-                              sizeof(*body));
-
-        LASSERT(body->valid & (OBD_MD_FLMODE | OBD_MD_FLID) &&
-                (body->mode == 0 || body->mode == 1 || body->mode == EREMOTE));
-
-        rc = body->mode;
-        if (rc == EREMOTE) {
-                CDEBUG(D_INFO, "Remote mdo_is_subdir(), new src "
-                       DFID"\n", PFID(&body->fid1));
+        if (rc == 0 || rc == -EREMOTE) {
+                body = lustre_msg_buf(mci->mci_req->rq_repmsg, REPLY_REC_OFF,
+                                      sizeof(*body));
+                LASSERT(body->valid & OBD_MD_FLID);
+        
+                CDEBUG(D_INFO, "Remote mdo_is_subdir(), new src "DFID"\n",
+                       PFID(&body->fid1));
                 *sfid = body->fid1;
-                rc = -EREMOTE;
         }
         EXIT;
 out:
index fd203dc..e2767cc 100644 (file)
@@ -320,7 +320,7 @@ static int mdc_is_subdir(struct obd_export *exp, const struct lu_fid *pfid,
 
         ptlrpc_req_set_repsize(req, 2, size);
         rc = ptlrpc_queue_wait(req);
-        if (rc != 0)
+        if (rc != 0 && rc != -EREMOTE)
                 GOTO(out, rc);
 
         body = lustre_swab_repbuf(req, REPLY_REC_OFF, sizeof(*body),
index 4530819..f8b34a4 100644 (file)
@@ -172,7 +172,14 @@ static int mdd_is_subdir(const struct lu_env *env,
                 RETURN(0);
 
         rc = mdd_is_parent(env, mdd, md2mdd_obj(mo), fid, sfid);
-
+        if (rc == 0) {
+                /* found root */
+                fid_zero(sfid);
+        } else if (rc == 1) {
+                /* found @fid is parent */
+                *sfid = *fid;
+                rc = 0;
+        }
         RETURN(rc);
 }
 
index 98c7529..0cc0938 100644 (file)
@@ -672,20 +672,10 @@ static int mdt_is_subdir(struct mdt_thread_info *info)
         LASSERT(mdt_object_exists(o) > 0);
         rc = mdo_is_subdir(info->mti_env, mdt_object_child(o),
                            &body->fid2, &repbody->fid1);
-        if (rc < 0 && rc != -EREMOTE)
-                RETURN(rc);
-
-        /*
-         * Save error code to ->mode. Later it it is used for detecting the case
-         * of remote subdir.
-         */
-        repbody->mode = rc < 0 ? -rc : rc;
-        repbody->valid = OBD_MD_FLMODE;
-
-        if (rc == -EREMOTE)
+        if (rc == 0 || rc == -EREMOTE)
                 repbody->valid |= OBD_MD_FLID;
 
-        RETURN(0);
+        RETURN(rc);
 }
 
 static int mdt_raw_lookup(struct mdt_thread_info *info,
index 2a6a25f..56baa84 100644 (file)
@@ -656,15 +656,19 @@ static int mdt_rename_sanity(struct mdt_thread_info *info, struct lu_fid *fid)
         ENTRY;
 
         do {
+                LASSERT(fid_is_sane(&dst_fid));
                 dst = mdt_object_find(info->mti_env, info->mti_mdt, &dst_fid);
                 if (!IS_ERR(dst)) {
-                        rc = mdo_is_subdir(info->mti_env, mdt_object_child(dst),
-                                           fid, &dst_fid);
+                        rc = mdo_is_subdir(info->mti_env,
+                                           mdt_object_child(dst), fid,
+                                           &dst_fid);
                         mdt_object_put(info->mti_env, dst);
-                        if (rc < 0 && rc != -EREMOTE) {
+                        if (rc != -EREMOTE && rc < 0) {
                                 CERROR("Failed mdo_is_subdir(), rc %d\n", rc);
-                        } else if (rc == 1) {
-                                rc = -EINVAL;
+                        } else {
+                                /* check the found fid */
+                                if (lu_fid_eq(&dst_fid, fid))
+                                        rc = -EINVAL;
                         }
                 } else {
                         rc = PTR_ERR(dst);