From 2fe36b0bfb80a4955f6ff42b2448f432223f6011 Mon Sep 17 00:00:00 2001 From: David Quigley Date: Wed, 1 Feb 2017 10:34:22 -0700 Subject: Use fletcher_4 routines natively with `abd_iterate_func()` This patch adds the necessary infrastructure for ABD to make use of the vectorized fletcher 4 routines. - export ABD compatible interface from fletcher_4 - add ABD fletcher_4 tests for data and metadata ABD types. Reviewed-by: Brian Behlendorf Original-patch-by: Gvozden Neskovic Signed-off-by: David Quigley Closes #5589 --- cmd/ztest/ztest.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'cmd') diff --git a/cmd/ztest/ztest.c b/cmd/ztest/ztest.c index d1c6a783a..0ef834403 100644 --- a/cmd/ztest/ztest.c +++ b/cmd/ztest/ztest.c @@ -5680,6 +5680,7 @@ ztest_fletcher(ztest_ds_t *zd, uint64_t id) while (gethrtime() <= end) { int run_count = 100; void *buf; + struct abd *abd_data, *abd_meta; uint32_t size; int *ptr; int i; @@ -5687,11 +5688,17 @@ ztest_fletcher(ztest_ds_t *zd, uint64_t id) zio_cksum_t zc_ref_byteswap; size = ztest_random_blocksize(); + buf = umem_alloc(size, UMEM_NOFAIL); + abd_data = abd_alloc(size, B_FALSE); + abd_meta = abd_alloc(size, B_TRUE); for (i = 0, ptr = buf; i < size / sizeof (*ptr); i++, ptr++) *ptr = ztest_random(UINT_MAX); + abd_copy_from_buf_off(abd_data, buf, 0, size); + abd_copy_from_buf_off(abd_meta, buf, 0, size); + VERIFY0(fletcher_4_impl_set("scalar")); fletcher_4_native(buf, size, NULL, &zc_ref); fletcher_4_byteswap(buf, size, NULL, &zc_ref_byteswap); @@ -5707,9 +5714,30 @@ ztest_fletcher(ztest_ds_t *zd, uint64_t id) VERIFY0(bcmp(&zc, &zc_ref, sizeof (zc))); VERIFY0(bcmp(&zc_byteswap, &zc_ref_byteswap, sizeof (zc_byteswap))); + + /* Test ABD - data */ + abd_fletcher_4_byteswap(abd_data, size, NULL, + &zc_byteswap); + abd_fletcher_4_native(abd_data, size, NULL, &zc); + + VERIFY0(bcmp(&zc, &zc_ref, sizeof (zc))); + VERIFY0(bcmp(&zc_byteswap, &zc_ref_byteswap, + sizeof (zc_byteswap))); + + /* Test ABD - metadata */ + abd_fletcher_4_byteswap(abd_meta, size, NULL, + &zc_byteswap); + abd_fletcher_4_native(abd_meta, size, NULL, &zc); + + VERIFY0(bcmp(&zc, &zc_ref, sizeof (zc))); + VERIFY0(bcmp(&zc_byteswap, &zc_ref_byteswap, + sizeof (zc_byteswap))); + } umem_free(buf, size); + abd_free(abd_data); + abd_free(abd_meta); } } -- cgit v1.2.3