Whamcloud - gitweb
LU-352 obdfilter: fix obdfilter-survey to work on verify mode.
authorAlexander.Boyko <alexander_boyko@xyratex.com>
Thu, 15 Mar 2012 06:14:27 +0000 (14:14 +0800)
committerOleg Drokin <green@whamcloud.com>
Fri, 6 Apr 2012 05:57:46 +0000 (01:57 -0400)
With r/o cache landing lctl test_brw command needs to choose a type
of operation with backend device. osc needs to use obd_brw mode,
but obdfilter doesn't work in that mode. It needs to force to use a
obd_prep + obd_commit more.

Signed-off-by: Alexey Lyashkov <alexey_lyashkov@xyratex.com>
Signed-off-by: Vitaly Fertman <vitaly_fertman@xyratex.com>
Signed-off-by: Alexander Boyko <alexander_boyko@xyratex.com>
Signed-off-by: Hongchao Zhang <hongchao.zhang@whamcloud.com>
Reviewed-by: Vitaly Fertman <vitaly_fertman@xyratex.com>
Xyratex-bug-id: MRP-131, MRP-277
Change-Id: I562784b3e9fe537929e78e0197256949cb27a9e1
Reviewed-on: http://review.whamcloud.com/598
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Yu Jian <yujian@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre-iokit/obdfilter-survey/obdfilter-survey
lustre/obdecho/echo_client.c
lustre/obdfilter/filter.c
lustre/obdfilter/filter_internal.h
lustre/obdfilter/filter_io.c
lustre/tests/obdfilter-survey.sh

index 896808e..b55d01d 100755 (executable)
@@ -48,6 +48,11 @@ rslt=${rslt:-"$rslt_loc/obdfilter_survey_`date +%F@%R`_`uname -n`"}
 # Set this true to check file contents
 verify=${verify:-0}
 
 # Set this true to check file contents
 verify=${verify:-0}
 
+# test targets
+targets=${targets:-""}
+# test case
+case=${case:-"disk"}
+
 # total size (MBytes) per obd instance
 # large enough to avoid cache effects 
 # and to make test startup/shutdown overhead insignificant
 # total size (MBytes) per obd instance
 # large enough to avoid cache effects 
 # and to make test startup/shutdown overhead insignificant
@@ -170,6 +175,15 @@ testname2type () {
     esac
 }
 
     esac
 }
 
+# for "echo_client + obdfilter" case, "prep + commit" mode should be used
+# for "echo_client + osc" case, "BRW" mode should be used
+testcase2mode() {
+    case $case in
+    disk) echo "p$1";;
+    *)    echo "g";;
+    esac
+}
+
 print_summary () {
     if [ "$1" = "-n" ]; then
         minusn=$1; shift
 print_summary () {
     if [ "$1" = "-n" ]; then
         minusn=$1; shift
@@ -184,8 +198,6 @@ print_summary () {
 #####################################################################
 # One can change variable values in this section as per requirements
 
 #####################################################################
 # One can change variable values in this section as per requirements
 
-targets=${targets:-""}
-case=${case:-"disk"}
 if [ -n "$targets" ]; then
     declare -a ost_names
     declare -a client_names
 if [ -n "$targets" ]; then
     declare -a ost_names
     declare -a client_names
@@ -468,7 +480,8 @@ for ((rsz = $rszlo; rsz <= $rszhi; rsz*=2)); do
                    echo >> ${cmdsf}_${host} \
                        "$lctl > $tmpfi 2>&1 \\
                          --threads $thr -$snap $devno \\
                    echo >> ${cmdsf}_${host} \
                        "$lctl > $tmpfi 2>&1 \\
                          --threads $thr -$snap $devno \\
-                        test_brw $count `testname2type $test` q $pages ${thr_per_obj}t${first_obj} &"
+                         test_brw $count `testname2type $test` q $pages \\
+                         ${thr_per_obj}t${first_obj} `testcase2mode $pages` &"
                 done
                 pidcount=0
                 for host in ${unique_hosts[@]}; do
                 done
                 pidcount=0
                 for host in ${unique_hosts[@]}; do
index 51aff35..cef8317 100644 (file)
@@ -51,6 +51,7 @@
 #include <cl_object.h>
 #include <lustre_fid.h>
 #include <lustre_acl.h>
 #include <cl_object.h>
 #include <lustre_fid.h>
 #include <lustre_acl.h>
+#include <lustre_net.h>
 
 #include "echo_internal.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)
 {
                             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;
         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);
         }
 
                                                      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)
 
  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,
 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;
 {
         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 (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)
                         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;
         struct echo_object *eco;
         int rc;
         int async = 1;
+        long test_mode;
         ENTRY;
 
         LASSERT(oa->o_valid & OBD_MD_FLGROUP);
         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;
 
 
         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;
                 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,
                 /* 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,
                 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;
                 break;
         default:
                 rc = -EINVAL;
index ab8896f..527b02f 100644 (file)
@@ -4763,7 +4763,6 @@ static struct obd_ops filter_obd_ops = {
         .o_create         = filter_create,
         .o_setattr        = filter_setattr,
         .o_destroy        = filter_destroy,
         .o_create         = filter_create,
         .o_setattr        = filter_setattr,
         .o_destroy        = filter_destroy,
-        .o_brw            = filter_brw,
         .o_punch          = filter_truncate,
         .o_sync           = filter_sync,
         .o_preprw         = filter_preprw,
         .o_punch          = filter_truncate,
         .o_sync           = filter_sync,
         .o_preprw         = filter_preprw,
index 83bc311..65c645d 100644 (file)
@@ -171,8 +171,6 @@ int filter_preprw(int cmd, struct obd_export *, struct obdo *, int objcount,
 int filter_commitrw(int cmd, struct obd_export *, struct obdo *, int objcount,
                     struct obd_ioobj *, struct niobuf_remote *,  int,
                     struct niobuf_local *, struct obd_trans_info *, int rc);
 int filter_commitrw(int cmd, struct obd_export *, struct obdo *, int objcount,
                     struct obd_ioobj *, struct niobuf_remote *,  int,
                     struct niobuf_local *, struct obd_trans_info *, int rc);
-int filter_brw(int cmd, struct obd_export *, struct obd_info *oinfo,
-               obd_count oa_bufs, struct brw_page *pga, struct obd_trans_info *);
 void filter_release_cache(struct obd_device *, struct obd_ioobj *,
                           struct niobuf_remote *, struct inode *);
 
 void filter_release_cache(struct obd_device *, struct obd_ioobj *,
                           struct niobuf_remote *, struct inode *);
 
index 4424546..2d6e213 100644 (file)
@@ -1014,47 +1014,3 @@ int filter_commitrw(int cmd, struct obd_export *exp, struct obdo *oa,
         return -EPROTO;
 }
 
         return -EPROTO;
 }
 
-int filter_brw(int cmd, struct obd_export *exp, struct obd_info *oinfo,
-               obd_count oa_bufs, struct brw_page *pga,
-               struct obd_trans_info *oti)
-{
-        struct obd_ioobj ioo;
-        struct niobuf_local *lnb;
-        struct niobuf_remote *rnb;
-        obd_count i;
-        int ret = 0, npages;
-        ENTRY;
-
-        OBD_ALLOC(lnb, oa_bufs * sizeof(struct niobuf_local));
-        OBD_ALLOC(rnb, oa_bufs * sizeof(struct niobuf_remote));
-
-        if (lnb == NULL || rnb == NULL)
-                GOTO(out, ret = -ENOMEM);
-
-        for (i = 0; i < oa_bufs; i++) {
-                lnb[i].page = pga[i].pg;
-                rnb[i].offset = pga[i].off;
-                rnb[i].len = pga[i].count;
-                lnb[i].flags = rnb[i].flags = pga[i].flag;
-        }
-
-        obdo_to_ioobj(oinfo->oi_oa, &ioo);
-        ioo.ioo_bufcnt = oa_bufs;
-
-        npages = oa_bufs;
-        ret = filter_preprw(cmd, exp, oinfo->oi_oa, 1, &ioo,
-                            rnb, &npages, lnb, oti, oinfo_capa(oinfo));
-        if (ret != 0)
-                GOTO(out, ret);
-        LASSERTF(oa_bufs == npages, "%u != %u\n", oa_bufs, npages);
-
-        ret = filter_commitrw(cmd, exp, oinfo->oi_oa, 1, &ioo, rnb,
-                              npages, lnb, oti, ret);
-
-out:
-        if (lnb)
-                OBD_FREE(lnb, oa_bufs * sizeof(struct niobuf_local));
-        if (rnb)
-                OBD_FREE(rnb, oa_bufs * sizeof(struct niobuf_remote));
-        RETURN(ret);
-}
index 30ac28d..37a4d28 100644 (file)
@@ -161,6 +161,12 @@ test_1b () {
 }
 run_test 1b "Object Storage Targets survey, async journal"
 
 }
 run_test 1b "Object Storage Targets survey, async journal"
 
+test_1c () {
+       nobjlo=1 nobjhi=1 thrlo=128 thrhi=128 rszlo=1024 rszhi=1024 size=8192\
+       obdflter_survey_run disk
+}
+run_test 1c "Object Storage Targets survey, big batch"
+
 test_2a () {
        obdflter_survey_run netdisk
 }
 test_2a () {
        obdflter_survey_run netdisk
 }