Whamcloud - gitweb
LU-3850 obdecho: create remote dir from echo client 02/7502/6
authorwang di <di.wang@intel.com>
Thu, 29 Aug 2013 07:00:12 +0000 (00:00 -0700)
committerOleg Drokin <oleg.drokin@intel.com>
Mon, 4 Nov 2013 16:26:49 +0000 (16:26 +0000)
Because echo client can only talk to local MDD, it will
send create remote dir req to the MDT where the dir is
located, which is different as the normal remote create
request. This patch fixes a few problem of this process

1. Not set parent during ah_init, which will make local OSD
to access the remote parent.

2. set correct attribute for remote parent in the declare
phase.

3. set root_fid for other MDT, which is needed by echo_client
to resolve the path on non-MDT0.

4. set child_base_id in oi_id directly to avoid the sanity
check in ostid_set_id,  and also child_base_id is actually
being used as the base of name, instead of FID.

5. Disable rmdir on remote MDT for echo client, i.e. echo
client can only unlink the directory on the MDT which echo
client is attached to, so lctl test_rmdir will be consistent
with normal rmdir.

Signed-off-by: wang di <di.wang@intel.com>
Change-Id: I16df8f0211afae670bfeea1ba1087a77a6b775da
Reviewed-on: http://review.whamcloud.com/7502
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Alex Zhuravlev <alexey.zhuravlev@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/lod/lod_object.c
lustre/mdd/mdd_device.c
lustre/mdd/mdd_dir.c
lustre/obdecho/echo_client.c
lustre/osp/osp_md_object.c
lustre/utils/obd.c

index 9c12c5b..8fbb322 100644 (file)
@@ -706,7 +706,8 @@ static void lod_ah_init(const struct lu_env *env,
         * can be called with local object existing
         */
        if (!dt_object_exists(nextc) || dt_object_remote(nextc))
-               nextc->do_ops->do_ah_init(env, ah, nextp, nextc, child_mode);
+               nextc->do_ops->do_ah_init(env, ah, dt_object_remote(nextp) ?
+                                         NULL : nextp, nextc, child_mode);
 
        if (S_ISDIR(child_mode)) {
                if (lp->ldo_striping_cached == 0) {
index 6c72566..f4462b7 100644 (file)
@@ -920,8 +920,8 @@ static int mdd_prepare(const struct lu_env *env,
        if (rc < 0)
                GOTO(out_los, rc);
 
+       lu_root_fid(&fid);
        if (mdd_seq_site(mdd)->ss_node_id == 0) {
-               lu_root_fid(&fid);
                rc = mdd_local_file_create(env, mdd, &mdd->mdd_local_root_fid,
                                           mdd_root_dir_name, S_IFDIR |
                                           S_IRUGO | S_IWUSR | S_IXUGO, &fid);
@@ -930,8 +930,8 @@ static int mdd_prepare(const struct lu_env *env,
                               mdd2obd_dev(mdd)->obd_name, rc);
                        GOTO(out_los, rc);
                }
-               mdd->mdd_root_fid = fid;
 
+               mdd->mdd_root_fid = fid;
                rc = mdd_dot_lustre_setup(env, mdd);
                if (rc != 0) {
                        CERROR("%s: initializing .lustre failed: rc = %d\n",
@@ -943,6 +943,10 @@ static int mdd_prepare(const struct lu_env *env,
                if (rc)
                        GOTO(out_los, rc);
 
+       } else {
+               /* Normal client usually send root access to MDT0 directly,
+                * the root FID on non-MDT0 will only be used by echo client. */
+               mdd->mdd_root_fid = fid;
        }
 
        rc = orph_index_init(env, mdd);
index 2919a3b..c4d0271 100644 (file)
@@ -1920,7 +1920,11 @@ static int mdd_declare_create(const struct lu_env *env, struct mdd_device *mdd,
         }
 
        if (!(spec->sp_cr_flags & MDS_OPEN_VOLATILE)) {
-               rc = mdo_declare_attr_set(env, p, attr, handle);
+               struct lu_attr  *la = &mdd_env_info(env)->mti_la_for_fix;
+
+               *la = *attr;
+               la->la_valid = LA_CTIME | LA_MTIME;
+               rc = mdo_declare_attr_set(env, p, la, handle);
                if (rc)
                        return rc;
        }
index e1ac975..ff5341f 100644 (file)
@@ -1949,6 +1949,11 @@ static int echo_md_destroy_internal(const struct lu_env *env,
                 GOTO(out_put, rc = -EINVAL);
         }
 
+       if (lu_object_remote(child)) {
+               CERROR("Can not destroy remote object %s: rc = %d\n",
+                      lname->ln_name, -EPERM);
+               GOTO(out_put, rc = -EPERM);
+       }
         CDEBUG(D_RPCTRACE, "Start destroy object "DFID" %s %p\n",
                PFID(lu_object_fid(&parent->mo_lu)), lname->ln_name, parent);
 
@@ -2835,8 +2840,7 @@ echo_client_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
                count = data->ioc_count;
                cmd = data->ioc_command;
 
-               id = ostid_id(&data->ioc_obdo2.o_oi);
-
+               id = data->ioc_obdo2.o_oi.oi.oi_id;
                dirlen = data->ioc_plen1;
                OBD_ALLOC(dir, dirlen + 1);
                if (dir == NULL)
index 42eeee6..b66a66a 100644 (file)
@@ -752,12 +752,8 @@ static int osp_md_index_lookup(const struct lu_env *env, struct dt_object *dt,
        }
 
        rc = osp_remote_sync(env, dt_dev, update, &req);
-       if (rc < 0) {
-               CERROR("%s: lookup "DFID" %s failed: rc = %d\n",
-                      dt_dev->dd_lu_dev.ld_obd->obd_name,
-                      PFID(lu_object_fid(&dt->do_lu)), (char *)key, rc);
+       if (rc < 0)
                GOTO(out, rc);
-       }
 
        reply = req_capsule_server_sized_get(&req->rq_pill, &RMF_UPDATE_REPLY,
                                             UPDATE_BUFFER_SIZE);
index 156f9ef..854def8 100644 (file)
@@ -1405,8 +1405,7 @@ int jt_obd_md_common(int argc, char **argv, int cmd)
                 struct lu_fid fid = { 0 };
 
                if (child_base_id != -1)
-                       ostid_set_id(&data.ioc_obdo2.o_oi, child_base_id);
-
+                       data.ioc_obdo2.o_oi.oi.oi_id = child_base_id;
                 data.ioc_obdo2.o_mode = mode | create_mode;
                 data.ioc_obdo2.o_valid = OBD_MD_FLID | OBD_MD_FLTYPE |
                                          OBD_MD_FLMODE | OBD_MD_FLFLAGS |