Whamcloud - gitweb
LU-352 obdfilter: fix obdfilter-survey to work on verify mode.
[fs/lustre-release.git] / lustre / obdecho / echo_client.c
index 51aff35..cef8317 100644 (file)
@@ -51,6 +51,7 @@
 #include <cl_object.h>
 #include <lustre_fid.h>
 #include <lustre_acl.h>
+#include <lustre_net.h>
 
 #include "echo_internal.h"
 
@@ -2285,7 +2286,6 @@ static int echo_client_kbrw(struct echo_device *ed, int rw, struct obdo *oa,
                             obd_size count, int async,
                             struct obd_trans_info *oti)
 {
-        struct echo_client_obd *ec  = ed->ed_ec;
         struct lov_stripe_md   *lsm = eco->eo_lsm;
         obd_count               npages;
         struct brw_page        *pga;
@@ -2350,13 +2350,9 @@ static int echo_client_kbrw(struct echo_device *ed, int rw, struct obdo *oa,
                                                      oa->o_id, off, pgp->count);
         }
 
-        if (ed->ed_next == NULL) {
-                struct obd_info oinfo = { { { 0 } } };
-                oinfo.oi_oa = oa;
-                oinfo.oi_md = lsm;
-                rc = obd_brw(rw, ec->ec_exp, &oinfo, npages, pga, oti);
-        } else
-                rc = cl_echo_object_brw(eco, rw, offset, pages, npages, async);
+        /* brw mode can only be used at client */
+        LASSERT(ed->ed_next != NULL);
+        rc = cl_echo_object_brw(eco, rw, offset, pages, npages, async);
 
  out:
         if (rc != 0 || rw != OBD_BRW_READ)
@@ -2383,7 +2379,8 @@ static int echo_client_kbrw(struct echo_device *ed, int rw, struct obdo *oa,
 static int echo_client_prep_commit(struct obd_export *exp, int rw,
                                    struct obdo *oa, struct echo_object *eco,
                                    obd_off offset, obd_size count,
-                                   obd_size batch, struct obd_trans_info *oti)
+                                   obd_size batch, struct obd_trans_info *oti,
+                                   int async)
 {
         struct lov_stripe_md *lsm = eco->eo_lsm;
         struct obd_ioobj ioo;
@@ -2439,6 +2436,9 @@ static int echo_client_prep_commit(struct obd_export *exp, int rw,
                         if (page == NULL && lnb[i].rc == 0)
                                 continue;
 
+                        if (async)
+                                lnb[i].flags |= OBD_BRW_ASYNC;
+
                         if (oa->o_id == ECHO_PERSISTENT_OBJID ||
                             (oa->o_valid & OBD_MD_FLFLAGS) == 0 ||
                             (oa->o_flags & OBD_FL_DEBUG_CHECK) == 0)
@@ -2483,6 +2483,7 @@ static int echo_client_brw_ioctl(int rw, struct obd_export *exp,
         struct echo_object *eco;
         int rc;
         int async = 1;
+        long test_mode;
         ENTRY;
 
         LASSERT(oa->o_valid & OBD_MD_FLGROUP);
@@ -2493,9 +2494,22 @@ static int echo_client_brw_ioctl(int rw, struct obd_export *exp,
 
         oa->o_valid &= ~OBD_MD_FLHANDLE;
 
-        switch((long)data->ioc_pbuf1) {
-        case 1:
+        /* obdfilter doesn't support obd_brw now, simulate via prep + commit */
+        test_mode = (long)data->ioc_pbuf1;
+        if (test_mode == 1)
                 async = 0;
+
+        if (ed->ed_next == NULL && test_mode != 3) {
+                test_mode = 3;
+                data->ioc_plen1 = data->ioc_count;
+        }
+
+        /* Truncate batch size to maximum */
+        if (data->ioc_plen1 > PTLRPC_MAX_BRW_SIZE)
+                data->ioc_plen1 = PTLRPC_MAX_BRW_SIZE;
+
+        switch (test_mode) {
+        case 1:
                 /* fall through */
         case 2:
                 rc = echo_client_kbrw(ed, rw, oa,
@@ -2506,7 +2520,7 @@ static int echo_client_brw_ioctl(int rw, struct obd_export *exp,
                 rc = echo_client_prep_commit(ec->ec_exp, rw, oa,
                                             eco, data->ioc_offset,
                                             data->ioc_count, data->ioc_plen1,
-                                            &dummy_oti);
+                                            &dummy_oti, async);
                 break;
         default:
                 rc = -EINVAL;