Whamcloud - gitweb
* new network config snapshot
[fs/lustre-release.git] / lustre / obdecho / echo_client.c
index c232078..806788d 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/iobuf.h>
 #endif
 #include <asm/div64.h>
+#include <linux/smp_lock.h>
 #else
 #include <liblustre.h>
 #endif
@@ -218,7 +219,8 @@ static int echo_create_object(struct obd_device *obd, int on_target,
                 oa->o_id = ++last_object_id;
 
         if (on_target) {
-                oa->o_gr = FILTER_GROUP_ECHO;
+                /* XXX get some filter group constants */
+                oa->o_gr = 2;
                 oa->o_valid |= OBD_MD_FLGROUP;
                 rc = obd_create(ec->ec_exp, oa, &lsm, oti);
                 if (rc != 0)
@@ -479,10 +481,8 @@ echo_client_page_debug_check(struct lov_stripe_md *lsm,
                 rc2 = block_debug_check("test_brw", 
                                         addr + delta, OBD_ECHO_BLOCK_SIZE, 
                                         stripe_off, stripe_id);
-                if (rc2 != 0) {
-                        CERROR ("Error in echo object "LPX64"\n", id);
+                if (rc2 != 0)
                         rc = rc2;
-                }
         }
 
         kunmap(page);
@@ -500,7 +500,7 @@ static int echo_client_kbrw(struct obd_device *obd, int rw, struct obdo *oa,
         obd_off                 off;
         int                     i;
         int                     rc;
-        int                     verify = 0;
+        int                     verify;
         int                     gfp_mask;
 
         verify = ((oa->o_id) != ECHO_PERSISTENT_OBJID &&
@@ -536,7 +536,7 @@ static int echo_client_kbrw(struct obd_device *obd, int rw, struct obdo *oa,
                         goto out;
 
                 pgp->count = PAGE_SIZE;
-                pgp->disk_offset = pgp->page_offset = off;
+                pgp->off = off;
                 pgp->flag = 0;
 
                 if (verify)
@@ -557,8 +557,7 @@ static int echo_client_kbrw(struct obd_device *obd, int rw, struct obdo *oa,
                 if (verify) {
                         int vrc;
                         vrc = echo_client_page_debug_check(lsm, pgp->pg, oa->o_id,
-                                                           pgp->page_offset, 
-                                                           pgp->count);
+                                                           pgp->off, pgp->count);
                         if (vrc != 0 && rc == 0)
                                 rc = vrc;
                 }
@@ -617,7 +616,7 @@ static int echo_client_ubrw(struct obd_device *obd, int rw,
         for (i = 0, off = offset, pgp = pga;
              i < npages;
              i++, off += PAGE_SIZE, pgp++) {
-                pgp->disk_offset = pgp->page_offset = off;
+                pgp->off = off;
                 pgp->pg = kiobuf->maplist[i];
                 pgp->count = PAGE_SIZE;
                 pgp->flag = 0;
@@ -660,6 +659,10 @@ struct echo_async_page {
         struct list_head        eap_item;
 };
 
+#define EAP_FROM_COOKIE(c)                                                      \
+        (LASSERT(((struct echo_async_page *)(c))->eap_magic == EAP_MAGIC),      \
+         (struct echo_async_page *)(c))
+
 struct echo_async_state {
         spinlock_t              eas_lock;
         obd_off                 eas_next_offset;
@@ -683,14 +686,6 @@ static int eas_should_wake(struct echo_async_state *eas)
         return rc;
 };
 
-struct echo_async_page *eap_from_cookie(void *cookie)
-{
-        struct echo_async_page *eap = cookie;
-        if (eap->eap_magic != EAP_MAGIC)
-                return ERR_PTR(-EINVAL);
-        return eap;
-};
-
 static int ec_ap_make_ready(void *data, int cmd)
 {
         /* our pages are issued ready */
@@ -705,22 +700,17 @@ static int ec_ap_refresh_count(void *data, int cmd)
 }
 static void ec_ap_fill_obdo(void *data, int cmd, struct obdo *oa)
 {
-        struct echo_async_page *eap;
-        eap = eap_from_cookie(data);
-        if (IS_ERR(eap))
-                return;
+        struct echo_async_page *eap = EAP_FROM_COOKIE(data);
 
         memcpy(oa, &eap->eap_eas->eas_oa, sizeof(*oa));
 }
 
 static void ec_ap_completion(void *data, int cmd, struct obdo *oa, int rc)
 {
-        struct echo_async_page *eap = eap_from_cookie(data);
+        struct echo_async_page *eap = EAP_FROM_COOKIE(data);
         struct echo_async_state *eas;
         unsigned long flags;
 
-        if (IS_ERR(eap))
-                return;
         eas = eap->eap_eas;
 
         if (cmd == OBD_BRW_READ &&
@@ -762,11 +752,12 @@ static int echo_client_async_page(struct obd_export *exp, int rw,
 #if 0
         int                     verify;
         int                     gfp_mask;
-        /* oa_id  == 0    => speed test (no verification) else...
-         * oa & 1         => use HIGHMEM
-         */
-        verify = (oa->o_id != 0);
-        gfp_mask = ((oa->o_id & 1) == 0) ? GFP_KERNEL : GFP_HIGHUSER;
+
+        verify = ((oa->o_id) != ECHO_PERSISTENT_OBJID &&
+                  (oa->o_valid & OBD_MD_FLFLAGS) != 0 &&
+                  (oa->o_flags & OBD_FL_DEBUG_CHECK) != 0);
+
+        gfp_mask = ((oa->o_id & 2) == 0) ? GFP_KERNEL : GFP_HIGHUSER;
 #endif
 
         LASSERT(rw == OBD_BRW_WRITE || rw == OBD_BRW_READ);
@@ -962,7 +953,6 @@ static int echo_client_prep_commit(struct obd_export *exp, int rw,
                             (oa->o_flags & OBD_FL_DEBUG_CHECK) == 0)
                                 continue;
 
-
                         if (rw == OBD_BRW_WRITE)
                                 echo_client_page_debug_setup(lsm, page, rw,
                                                              oa->o_id,
@@ -1006,7 +996,7 @@ int echo_client_brw_ioctl(int rw, struct obd_export *exp,
 
         data->ioc_obdo1.o_valid &= ~OBD_MD_FLHANDLE;
         data->ioc_obdo1.o_valid |= OBD_MD_FLGROUP;
-        data->ioc_obdo1.o_gr = FILTER_GROUP_ECHO;
+        data->ioc_obdo1.o_gr = 2;
 
         switch((long)data->ioc_pbuf1) {
         case 1:
@@ -1203,6 +1193,8 @@ echo_client_iocontrol(unsigned int cmd, struct obd_export *exp,
         int                     i;
         ENTRY;
 
+        unlock_kernel();
+
         memset(&dummy_oti, 0, sizeof(dummy_oti));
 
         obd = exp->exp_obd;
@@ -1225,7 +1217,7 @@ echo_client_iocontrol(unsigned int cmd, struct obd_export *exp,
                 rc = echo_get_object (&eco, obd, &data->ioc_obdo1);
                 if (rc == 0) {
                         oa = &data->ioc_obdo1;
-                        oa->o_gr = FILTER_GROUP_ECHO;
+                        oa->o_gr = 2;
                         oa->o_valid |= OBD_MD_FLGROUP;
                         rc = obd_destroy(ec->ec_exp, oa, eco->eco_lsm, 
                                          &dummy_oti);
@@ -1321,6 +1313,8 @@ echo_client_iocontrol(unsigned int cmd, struct obd_export *exp,
                 ldlm_lock_decref(&ack_lock->lock, ack_lock->mode);
         }
 
+        lock_kernel();
+
         return rc;
 }
 
@@ -1335,15 +1329,15 @@ echo_client_setup(struct obd_device *obddev, obd_count len, void *buf)
         int rc;
         ENTRY;
 
-        if (lcfg->lcfg_inllen1 < 1) {
+        if (lcfg->lcfg_bufcount < 2 || LUSTRE_CFG_BUFLEN(lcfg, 1) < 1) {
                 CERROR("requires a TARGET OBD name\n");
                 RETURN(-EINVAL);
         }
 
-        tgt = class_name2obd(lcfg->lcfg_inlbuf1);
+        tgt = class_name2obd(lustre_cfg_string(lcfg, 1));
         if (!tgt || !tgt->obd_attached || !tgt->obd_set_up) {
                 CERROR("device not attached or not set up (%s)\n",
-                       lcfg->lcfg_inlbuf1);
+                       lustre_cfg_string(lcfg, 1));
                 RETURN(-EINVAL);
         }
 
@@ -1351,9 +1345,10 @@ echo_client_setup(struct obd_device *obddev, obd_count len, void *buf)
         INIT_LIST_HEAD (&ec->ec_objects);
         ec->ec_unique = 0;
 
-        rc = obd_connect(&conn, tgt, &echo_uuid, 0);
+        rc = obd_connect(&conn, tgt, &echo_uuid, NULL /* obd_connect_data */);
         if (rc) {
-                CERROR("fail to connect to device %s\n", lcfg->lcfg_inlbuf1);
+                CERROR("fail to connect to device %s\n",
+                       lustre_cfg_string(lcfg, 1));
                 return (rc);
         }
         ec->ec_exp = class_conn2export(&conn);
@@ -1361,7 +1356,7 @@ echo_client_setup(struct obd_device *obddev, obd_count len, void *buf)
         RETURN(rc);
 }
 
-static int echo_client_cleanup(struct obd_device *obddev, int flags)
+static int echo_client_cleanup(struct obd_device *obddev)
 {
         struct list_head       *el;
         struct ec_object       *eco;
@@ -1385,7 +1380,7 @@ static int echo_client_cleanup(struct obd_device *obddev, int flags)
                 echo_put_object(eco);
         }
 
-        rc = obd_disconnect(ec->ec_exp, 0);
+        rc = obd_disconnect(ec->ec_exp);
         if (rc != 0)
                 CERROR("fail to disconnect device: %d\n", rc);
 
@@ -1393,9 +1388,8 @@ static int echo_client_cleanup(struct obd_device *obddev, int flags)
 }
 
 static int echo_client_connect(struct lustre_handle *conn,
-                               struct obd_device *src, 
-                              struct obd_uuid *cluuid,
-                               unsigned long flags)
+                               struct obd_device *src, struct obd_uuid *cluuid,
+                               struct obd_connect_data *data)
 {
         struct obd_export *exp;
         int                rc;
@@ -1410,8 +1404,7 @@ static int echo_client_connect(struct lustre_handle *conn,
         RETURN (rc);
 }
 
-static int echo_client_disconnect(struct obd_export *exp, 
-                                 unsigned long flags)
+static int echo_client_disconnect(struct obd_export *exp)
 {
         struct obd_device      *obd;
         struct echo_client_obd *ec;
@@ -1441,7 +1434,7 @@ static int echo_client_disconnect(struct obd_export *exp,
                 OBD_FREE (ecl, sizeof (*ecl));
         }
 
-        rc = class_disconnect(exp, 0);
+        rc = class_disconnect(exp);
         GOTO(out, rc);
  out:
         return rc;
@@ -1461,7 +1454,7 @@ int echo_client_init(void)
         struct lprocfs_static_vars lvars;
 
         lprocfs_init_vars(echo, &lvars);
-        return class_register_type(&echo_obd_ops, NULL, lvars.module_vars,
+        return class_register_type(&echo_obd_ops, lvars.module_vars,
                                    OBD_ECHO_CLIENT_DEVICENAME);
 }