From 1175906fbc974ddd5df93b63da6feec7118df156 Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Mon, 6 Jul 2009 16:01:41 -0700 Subject: [PATCH 1/2] Update zerocopy patch to be consistent with new flags arg passed to dmu_read(). It would be nice to have one of these for dmu_write() as well but we have do without for now. --- module/zfs/dmu.c | 22 +++++++--------------- module/zfs/include/sys/dmu.h | 8 ++++---- 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/module/zfs/dmu.c b/module/zfs/dmu.c index 5aff0ee043..15f09ae883 100644 --- a/module/zfs/dmu.c +++ b/module/zfs/dmu.c @@ -601,13 +601,6 @@ dmu_read(objset_t *os, uint64_t object, uint64_t offset, uint64_t size, return (err); } -int -dmu_read(objset_t *os, uint64_t object, uint64_t offset, uint64_t size, - void *buf) -{ - return dmu_read_impl(os, object, offset, size, buf, 0); -} - void dmu_write_impl(objset_t *os, uint64_t object, uint64_t offset, uint64_t size, const void *buf, dmu_tx_t *tx, int flags) @@ -651,6 +644,13 @@ dmu_write_impl(objset_t *os, uint64_t object, uint64_t offset, uint64_t size, dmu_buf_rele_array(dbp, numbufs, FTAG); } +void +dmu_write(objset_t *os, uint64_t object, uint64_t offset, uint64_t size, + const void *buf, dmu_tx_t *tx) +{ + dmu_write_impl(os, object, offset, size, buf, tx, 0); +} + void dmu_prealloc(objset_t *os, uint64_t object, uint64_t offset, uint64_t size, dmu_tx_t *tx) @@ -672,13 +672,6 @@ dmu_prealloc(objset_t *os, uint64_t object, uint64_t offset, uint64_t size, dmu_buf_rele_array(dbp, numbufs, FTAG); } -void -dmu_write(objset_t *os, uint64_t object, uint64_t offset, uint64_t size, - const void *buf, dmu_tx_t *tx) -{ - dmu_write_impl(os, object, offset, size, buf, tx, 0); -} - #ifdef _KERNEL int dmu_read_uio(objset_t *os, uint64_t object, uio_t *uio, uint64_t size) @@ -1299,7 +1292,6 @@ dmu_fini(void) #if defined(_KERNEL) && defined(HAVE_SPL) EXPORT_SYMBOL(dmu_bonus_hold); EXPORT_SYMBOL(dmu_free_range); -EXPORT_SYMBOL(dmu_read_impl); EXPORT_SYMBOL(dmu_read); EXPORT_SYMBOL(dmu_write_impl); EXPORT_SYMBOL(dmu_write); diff --git a/module/zfs/include/sys/dmu.h b/module/zfs/include/sys/dmu.h index d85d602546..d4dc194611 100644 --- a/module/zfs/include/sys/dmu.h +++ b/module/zfs/include/sys/dmu.h @@ -156,10 +156,8 @@ void zfs_znode_byteswap(void *buf, size_t size); * The maximum number of bytes that can be accessed as part of one * operation, including metadata. */ -#define DMU_MAX_ACCESS (10<<20) /* 10MB */ -#define DMU_MAX_DELETEBLKCNT (20480) /* ~5MB of indirect blocks */ -#define DMU_WRITE_ZEROCOPY 0x0001 -#define DMU_READ_ZEROCOPY 0x0002 +#define DMU_MAX_ACCESS (10<<20) /* 10MB */ +#define DMU_MAX_DELETEBLKCNT (20480) /* ~5MB of indirect blocks */ #define DMU_USERUSED_OBJECT (-1ULL) #define DMU_GROUPUSED_OBJECT (-2ULL) @@ -481,6 +479,8 @@ int dmu_free_object(objset_t *os, uint64_t object); */ #define DMU_READ_PREFETCH 0 /* prefetch */ #define DMU_READ_NO_PREFETCH 1 /* don't prefetch */ +#define DMU_READ_ZEROCOPY 2 /* zerocopy on read (test) */ +#define DMU_WRITE_ZEROCOPY 4 /* zerocopy on write (test) */ int dmu_read(objset_t *os, uint64_t object, uint64_t offset, uint64_t size, void *buf, uint32_t flags); void dmu_write(objset_t *os, uint64_t object, uint64_t offset, uint64_t size, From 621679fec6c74233f366b91c07e35bb71590e08c Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Mon, 6 Jul 2009 16:51:59 -0700 Subject: [PATCH 2/2] Update to use dmu_read() instead of dmu_read_impl() now that a 'flags' argument is available. This flags argument was added to allow a clean API for disabling prefetch, so I'll update zpios to use it in preference to the module option hack used before. --- cmd/zpios/zpios_main.c | 7 ++++++- module/zpios/include/zpios-ctl.h | 17 +++++++++-------- module/zpios/zpios.c | 5 ++++- scripts/zpios-survey.sh | 7 +++---- 4 files changed, 22 insertions(+), 14 deletions(-) diff --git a/cmd/zpios/zpios_main.c b/cmd/zpios/zpios_main.c index 0505ad5db4..662a7b8ecc 100644 --- a/cmd/zpios/zpios_main.c +++ b/cmd/zpios/zpios_main.c @@ -45,7 +45,7 @@ #include "zpios.h" static const char short_opt[] = "t:l:h:e:n:i:j:k:o:m:q:r:c:a:b:g:s:A:B:C:" - "L:p:xP:R:G:I:N:T:VzOHv?"; + "L:p:xP:R:G:I:N:T:VzOfHv?"; static const struct option long_opt[] = { {"threadcount", required_argument, 0, 't' }, {"threadcount_low", required_argument, 0, 'l' }, @@ -79,6 +79,7 @@ static const struct option long_opt[] = { {"verify", no_argument, 0, 'V' }, {"zerocopy", no_argument, 0, 'z' }, {"nowait", no_argument, 0, 'O' }, + {"noprefetch", no_argument, 0, 'f' }, {"human-readable", no_argument, 0, 'H' }, {"verbose", no_argument, 0, 'v' }, {"help", no_argument, 0, '?' }, @@ -127,6 +128,7 @@ usage(void) " --verify -V\n" " --zerocopy -z\n" " --nowait -O\n" + " --noprefetch -f\n" " --human-readable -H\n" " --verbose -v =increase verbosity\n" " --help -? =this help\n\n"); @@ -283,6 +285,9 @@ args_init(int argc, char **argv) case 'O': /* --nowait */ args->flags |= DMU_WRITE_NOWAIT; break; + case 'f': /* --noprefetch */ + args->flags |= DMU_READ_NOPF; + break; case 'H': /* --human-readable */ args->human_readable = 1; break; diff --git a/module/zpios/include/zpios-ctl.h b/module/zpios/include/zpios-ctl.h index abe4b814bf..25a04bba01 100644 --- a/module/zpios/include/zpios-ctl.h +++ b/module/zpios/include/zpios-ctl.h @@ -46,14 +46,15 @@ #define DMU_IO 0x01 -#define DMU_WRITE 0x01 -#define DMU_READ 0x02 -#define DMU_VERIFY 0x04 -#define DMU_REMOVE 0x08 -#define DMU_FPP 0x10 -#define DMU_WRITE_ZC 0x20 /* Incompatible with DMU_VERIFY */ -#define DMU_READ_ZC 0x40 /* Incompatible with DMU_VERIFY */ -#define DMU_WRITE_NOWAIT 0x80 +#define DMU_WRITE 0x0001 +#define DMU_READ 0x0002 +#define DMU_VERIFY 0x0004 +#define DMU_REMOVE 0x0008 +#define DMU_FPP 0x0010 +#define DMU_WRITE_ZC 0x0020 /* Incompatible w/DMU_VERIFY */ +#define DMU_READ_ZC 0x0040 /* Incompatible w/DMU_VERIFY */ +#define DMU_WRITE_NOWAIT 0x0080 +#define DMU_READ_NOPF 0x0100 #define ZPIOS_NAME_SIZE 16 #define ZPIOS_PATH_SIZE 128 diff --git a/module/zpios/zpios.c b/module/zpios/zpios.c index fb508d7bbf..bf811c67ae 100644 --- a/module/zpios/zpios.c +++ b/module/zpios/zpios.c @@ -469,7 +469,10 @@ zpios_dmu_read(run_args_t *run_args, objset_t *os, uint64_t object, if (run_args->flags & DMU_READ_ZC) flags |= DMU_READ_ZEROCOPY; - return dmu_read_impl(os, object, offset, size, buf, flags); + if (run_args->flags & DMU_READ_NOPF) + flags |= DMU_READ_NO_PREFETCH; + + return dmu_read(os, object, offset, size, buf, flags); } static int diff --git a/scripts/zpios-survey.sh b/scripts/zpios-survey.sh index 2a3a33033e..6c5e1935b3 100755 --- a/scripts/zpios-survey.sh +++ b/scripts/zpios-survey.sh @@ -50,16 +50,16 @@ zpios_survey_base() { # Disable ZFS's prefetching. For some reason still not clear to me # current prefetching policy is quite bad for a random workload. -# Allowint the algorithm to detect a random workload and not do +# Allowing the algorithm to detect a random workload and not do # anything may be the way to address this issue. zpios_survey_prefetch() { TEST_NAME="${ZPOOL_CONFIG}+${ZPIOS_TEST}+prefetch" print_header ${TEST_NAME} ./zfs.sh ${VERBOSE_FLAG} \ - zfs="zfs_prefetch_disable=1" | \ tee -a ${ZPIOS_SURVEY_LOG} ./zpios.sh ${VERBOSE_FLAG} -c ${ZPOOL_CONFIG} -t ${ZPIOS_TEST} | \ + -o "--noprefetch" | \ tee -a ${ZPIOS_SURVEY_LOG} ./zfs.sh -u ${VERBOSE_FLAG} | \ tee -a ${ZPIOS_SURVEY_LOG} @@ -144,12 +144,11 @@ zpios_survey_all() { print_header ${TEST_NAME} ./zfs.sh ${VERBOSE_FLAG} \ - zfs="zfs_prefetch_disable=1" \ zfs="zfs_vdev_max_pending=1024" \ zfs="zio_bulk_flags=0x100" | \ tee -a ${ZPIOS_SURVEY_LOG} ./zpios.sh ${VERBOSE_FLAG} -c ${ZPOOL_CONFIG} -t ${ZPIOS_TEST} \ - -o "--zerocopy" \ + -o "--noprefetch --zerocopy" \ -s "set checksum=off" | \ tee -a ${ZPIOS_SURVEY_LOG} ./zfs.sh -u ${VERBOSE_FLAG} | \