Whamcloud - gitweb
b=23296 Fix the initialization of oti
[fs/lustre-release.git] / lustre / obdecho / echo_client.c
index 2109aa8..883b311 100644 (file)
@@ -26,7 +26,7 @@
  * GPL HEADER END
  */
 /*
- * Copyright  2008 Sun Microsystems, Inc. All rights reserved
+ * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  */
 /*
@@ -169,8 +169,10 @@ struct echo_object_conf *cl2echo_conf(const struct cl_object_conf *c)
 static inline void lsm2fid(struct lov_stripe_md *lsm, struct lu_fid *fid)
 {
         fid_zero(fid);
-        fid->f_seq = lsm->lsm_object_gr << 16 | lsm->lsm_object_id >> 32;
+        fid->f_seq = FID_SEQ_ECHO;
+        /* truncated to 32 bits by assignment */
         fid->f_oid = lsm->lsm_object_id;
+        fid->f_ver = lsm->lsm_object_id >> 32;
 }
 /** @} echo_helpers */
 
@@ -923,7 +925,7 @@ static struct echo_object *cl_echo_object_find(struct echo_device *d,
                         struct lov_oinfo *oinfo = lsm->lsm_oinfo[0];
                         LASSERT(oinfo != NULL);
                         oinfo->loi_id = lsm->lsm_object_id;
-                        oinfo->loi_gr = lsm->lsm_object_gr;
+                        oinfo->loi_seq = lsm->lsm_object_seq;
                         conf->eoc_cl.u.coc_oinfo = oinfo;
                 } else {
                         struct lustre_md *md;
@@ -998,7 +1000,7 @@ static int cl_echo_enqueue0(struct lu_env *env, struct echo_object *eco,
         descr->cld_start = cl_index(obj, start);
         descr->cld_end   = cl_index(obj, end);
         descr->cld_mode  = mode == LCK_PW ? CLM_WRITE : CLM_READ;
-        descr->cld_enq_flags = CEF_ASYNC | enqflags;
+        descr->cld_enq_flags = enqflags;
         io->ci_obj = obj;
 
         lck = cl_lock_request(env, io, descr, "ec enqueue", eco);
@@ -1067,7 +1069,7 @@ static int cl_echo_cancel0(struct lu_env *env, struct echo_device *ed,
         cfs_spin_lock (&ec->ec_lock);
         cfs_list_for_each (el, &ec->ec_locks) {
                 ecl = cfs_list_entry (el, struct echo_lock, el_chain);
-                CDEBUG(D_INFO, "ecl: %p, cookie: %llx\n", ecl, ecl->el_cookie);
+                CDEBUG(D_INFO, "ecl: %p, cookie: "LPX64"\n", ecl, ecl->el_cookie);
                 found = (ecl->el_cookie == cookie);
                 if (found) {
                         if (cfs_atomic_dec_and_test(&ecl->el_refcount))
@@ -1157,8 +1159,8 @@ static int cl_echo_object_brw(struct echo_object *eco, int rw, obd_off offset,
 
         rc = cl_echo_enqueue0(env, eco, offset,
                               offset + npages * CFS_PAGE_SIZE - 1,
-                              rw == READ ? LCK_PW : LCK_PW, &lh.cookie,
-                              CILR_NEVER);
+                              rw == READ ? LCK_PR : LCK_PW, &lh.cookie,
+                              CEF_NEVER);
         if (rc < 0)
                 GOTO(error_lock, rc);
 
@@ -1329,7 +1331,7 @@ static int echo_create_object(struct echo_device *ed, int on_target,
         if (on_target) {
                 /* Only echo objects are allowed to be created */
                 LASSERT((oa->o_valid & OBD_MD_FLGROUP) &&
-                        (oa->o_gr == FILTER_GROUP_ECHO));
+                        (oa->o_seq == FID_SEQ_ECHO));
                 rc = obd_create(ec->ec_exp, oa, &lsm, oti);
                 if (rc != 0) {
                         CERROR("Cannot create objects, rc = %d\n", rc);
@@ -1382,9 +1384,9 @@ static int echo_get_object(struct echo_object **ecop, struct echo_device *ed,
 
         lsm->lsm_object_id = oa->o_id;
         if (oa->o_valid & OBD_MD_FLGROUP)
-                lsm->lsm_object_gr = oa->o_gr;
+                lsm->lsm_object_seq = oa->o_seq;
         else
-                lsm->lsm_object_gr = FILTER_GROUP_ECHO;
+                lsm->lsm_object_seq = FID_SEQ_ECHO;
 
         rc = 0;
         eco = cl_echo_object_find(ed, &lsm);
@@ -1513,6 +1515,7 @@ static int echo_client_kbrw(struct echo_device *ed, int rw, struct obdo *oa,
         int                     rc;
         int                     verify;
         int                     gfp_mask;
+        int                     brw_flags = 0;
         ENTRY;
 
         verify = ((oa->o_id) != ECHO_PERSISTENT_OBJID &&
@@ -1532,6 +1535,9 @@ static int echo_client_kbrw(struct echo_device *ed, int rw, struct obdo *oa,
         /* XXX think again with misaligned I/O */
         npages = count >> CFS_PAGE_SHIFT;
 
+        if (rw == OBD_BRW_WRITE)
+                brw_flags = OBD_BRW_ASYNC;
+
         OBD_ALLOC(pga, npages * sizeof(*pga));
         if (pga == NULL)
                 RETURN(-ENOMEM);
@@ -1556,7 +1562,7 @@ static int echo_client_kbrw(struct echo_device *ed, int rw, struct obdo *oa,
                 pages[i] = pgp->pg;
                 pgp->count = CFS_PAGE_SIZE;
                 pgp->off = off;
-                pgp->flag = 0;
+                pgp->flag = brw_flags;
 
                 if (verify)
                         echo_client_page_debug_setup(lsm, pgp->pg, rw,
@@ -1691,7 +1697,7 @@ static int echo_client_brw_ioctl(int rw, struct obd_export *exp,
         struct obd_device *obd = class_exp2obd(exp);
         struct echo_device *ed = obd2echo_dev(obd);
         struct echo_client_obd *ec = ed->ed_ec;
-        struct obd_trans_info dummy_oti = { .oti_thread = NULL };
+        struct obd_trans_info dummy_oti = { 0 };
         struct obdo *oa = &data->ioc_obdo1;
         struct echo_object *eco;
         int rc;
@@ -1757,7 +1763,7 @@ echo_client_enqueue(struct obd_export *exp, struct obdo *oa,
         rc = cl_echo_enqueue(eco, offset, end, mode, &ulh->cookie);
         if (rc == 0) {
                 oa->o_valid |= OBD_MD_FLHANDLE;
-                CDEBUG(D_INFO, "Cookie is %llx\n", ulh->cookie);
+                CDEBUG(D_INFO, "Cookie is "LPX64"\n", ulh->cookie);
         }
         echo_put_object(eco);
         RETURN(rc);
@@ -1772,7 +1778,7 @@ echo_client_cancel(struct obd_export *exp, struct obdo *oa)
         if ((oa->o_valid & OBD_MD_FLHANDLE) == 0)
                 return -EINVAL;
 
-        CDEBUG(D_INFO, "Cookie is %llx\n", cookie);
+        CDEBUG(D_INFO, "Cookie is "LPX64"\n", cookie);
         return cl_echo_cancel(ed, cookie);
 }
 
@@ -1788,6 +1794,7 @@ echo_client_iocontrol(unsigned int cmd, struct obd_export *exp,
         struct obd_trans_info   dummy_oti;
         struct oti_req_ack_lock *ack_lock;
         struct obdo            *oa;
+        struct lu_fid           fid;
         int                     rw = OBD_BRW_READ;
         int                     rc = 0;
         int                     i;
@@ -1800,10 +1807,13 @@ echo_client_iocontrol(unsigned int cmd, struct obd_export *exp,
         oa = &data->ioc_obdo1;
         if (!(oa->o_valid & OBD_MD_FLGROUP)) {
                 oa->o_valid |= OBD_MD_FLGROUP;
-                oa->o_gr = FILTER_GROUP_ECHO;
+                oa->o_seq = FID_SEQ_ECHO;
         }
-        /* assume we can touch filter native objects with echo device. */
-        /* LASSERT(oa->o_gr == FILTER_GROUP_ECHO); */
+
+        /* This FID is unpacked just for validation at this point */
+        rc = fid_ostid_unpack(&fid, &oa->o_oi, 0);
+        if (rc < 0)
+                RETURN(rc);
 
         switch (cmd) {
         case OBD_IOC_CREATE:                    /* may create echo object */
@@ -1961,9 +1971,9 @@ static int echo_client_setup(struct obd_device *obddev, struct lustre_cfg *lcfg)
         }
 
         ocd->ocd_connect_flags = OBD_CONNECT_VERSION | OBD_CONNECT_REQPORTAL |
-                                 OBD_CONNECT_GRANT;
+                                 OBD_CONNECT_GRANT | OBD_CONNECT_FULL20;
         ocd->ocd_version = LUSTRE_VERSION_CODE;
-        ocd->ocd_group = FILTER_GROUP_ECHO;
+        ocd->ocd_group = FID_SEQ_ECHO;
 
         rc = obd_connect(NULL, &ec->ec_exp, tgt, &echo_uuid, ocd, NULL);
         if (rc == 0) {