From c13874ddf2b5a27bcac79b1db10cf426f487613c Mon Sep 17 00:00:00 2001 From: "Alexander.Boyko" Date: Thu, 15 Mar 2012 14:14:27 +0800 Subject: [PATCH] LU-352 obdfilter: fix obdfilter-survey to work on verify mode. 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 Signed-off-by: Vitaly Fertman Signed-off-by: Alexander Boyko Signed-off-by: Hongchao Zhang Reviewed-by: Vitaly Fertman Xyratex-bug-id: MRP-131, MRP-277 Change-Id: I562784b3e9fe537929e78e0197256949cb27a9e1 Reviewed-on: http://review.whamcloud.com/598 Tested-by: Hudson Tested-by: Maloo Reviewed-by: Yu Jian Reviewed-by: Oleg Drokin --- lustre-iokit/obdfilter-survey/obdfilter-survey | 19 +++++++++-- lustre/obdecho/echo_client.c | 38 +++++++++++++++------- lustre/obdfilter/filter.c | 1 - lustre/obdfilter/filter_internal.h | 2 -- lustre/obdfilter/filter_io.c | 44 -------------------------- lustre/tests/obdfilter-survey.sh | 6 ++++ 6 files changed, 48 insertions(+), 62 deletions(-) diff --git a/lustre-iokit/obdfilter-survey/obdfilter-survey b/lustre-iokit/obdfilter-survey/obdfilter-survey index 896808e..b55d01d 100755 --- a/lustre-iokit/obdfilter-survey/obdfilter-survey +++ b/lustre-iokit/obdfilter-survey/obdfilter-survey @@ -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} +# 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 @@ -170,6 +175,15 @@ testname2type () { 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 @@ -184,8 +198,6 @@ print_summary () { ##################################################################### # 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 @@ -468,7 +480,8 @@ for ((rsz = $rszlo; rsz <= $rszhi; rsz*=2)); do 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 diff --git a/lustre/obdecho/echo_client.c b/lustre/obdecho/echo_client.c index 51aff35..cef8317 100644 --- a/lustre/obdecho/echo_client.c +++ b/lustre/obdecho/echo_client.c @@ -51,6 +51,7 @@ #include #include #include +#include #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; diff --git a/lustre/obdfilter/filter.c b/lustre/obdfilter/filter.c index ab8896f..527b02f 100644 --- a/lustre/obdfilter/filter.c +++ b/lustre/obdfilter/filter.c @@ -4763,7 +4763,6 @@ static struct obd_ops filter_obd_ops = { .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, diff --git a/lustre/obdfilter/filter_internal.h b/lustre/obdfilter/filter_internal.h index 83bc311..65c645d8 100644 --- a/lustre/obdfilter/filter_internal.h +++ b/lustre/obdfilter/filter_internal.h @@ -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_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 *); diff --git a/lustre/obdfilter/filter_io.c b/lustre/obdfilter/filter_io.c index 4424546..2d6e213 100644 --- a/lustre/obdfilter/filter_io.c +++ b/lustre/obdfilter/filter_io.c @@ -1014,47 +1014,3 @@ int filter_commitrw(int cmd, struct obd_export *exp, struct obdo *oa, 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); -} diff --git a/lustre/tests/obdfilter-survey.sh b/lustre/tests/obdfilter-survey.sh index 30ac28d..37a4d28 100644 --- a/lustre/tests/obdfilter-survey.sh +++ b/lustre/tests/obdfilter-survey.sh @@ -161,6 +161,12 @@ test_1b () { } 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 } -- 1.8.3.1