bdev: more ZERO_BUFFER_SIZE to bdev_internal.h

The bdevio test app has some test cases verifying
that write zeroes commands are handled correctly,
but using knowledge of the ZERO_BUFFER_SIZE that
the bdev library uses for splitting larger write
zeroes commands.  Instead of hardcoding that 1MB
value in bdevio.c, have bdevio.c use ZERO_BUFFER_SIZE
directly instead.  But this requires moving
ZERO_BUFFER_SIZE into bdev_internal.h and having
bdevio.c include that file.

We do this instead of putting ZERO_BUFFER_SIZE in
the public API because we don't want users to
make any kind of dependencies on this value.

While here, also rename the tests that are using this
value, so that the test names don't include any reference
to the specific size of this bdev-internal zero buffer
size.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: Ia29d92a706cb1f86b4c29374dc2a9beccf679208
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/12383
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com>
Reviewed-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
This commit is contained in:
Jim Harris 2022-04-25 17:13:18 +00:00 committed by Tomasz Zawadzki
parent 9bff828f99
commit 0064713871
4 changed files with 15 additions and 13 deletions

View File

@ -67,7 +67,6 @@ int __itt_init_ittlib(const char *, __itt_group_id);
#define BUF_SMALL_POOL_SIZE 8191
#define BUF_LARGE_POOL_SIZE 1023
#define NOMEM_THRESHOLD_COUNT 8
#define ZERO_BUFFER_SIZE 0x100000
#define SPDK_BDEV_QOS_TIMESLICE_IN_USEC 1000
#define SPDK_BDEV_QOS_MIN_IO_PER_TIMESLICE 1

View File

@ -36,6 +36,8 @@
#include "spdk/bdev.h"
#define ZERO_BUFFER_SIZE 0x100000
struct spdk_bdev;
struct spdk_bdev_io;
struct spdk_bdev_channel;

View File

@ -38,6 +38,7 @@ include $(SPDK_ROOT_DIR)/mk/spdk.modules.mk
APP = bdevio
C_SRCS := bdevio.c
CFLAGS += -I$(SPDK_ROOT_DIR)/lib/bdev
SPDK_LIB_LIST = $(ALL_MODULES_LIST) event event_bdev

View File

@ -44,6 +44,7 @@
#include "spdk/util.h"
#include "spdk/string.h"
#include "bdev_internal.h"
#include "CUnit/Basic.h"
#define BUFFER_IOVS 1024
@ -564,15 +565,14 @@ blockdev_write_zeroes_read_4k(void)
* This i/o will not have to split at the bdev layer.
*/
static void
blockdev_write_zeroes_read_1m(void)
blockdev_write_zeroes_read_no_split(void)
{
uint32_t data_length;
uint64_t offset;
int pattern;
int expected_rc;
/* Data size = 1M */
data_length = 1048576;
data_length = ZERO_BUFFER_SIZE; /* from bdev_internal.h */
offset = 0;
pattern = 0xA3;
/* Params are valid, hence the expected return value
@ -587,15 +587,14 @@ blockdev_write_zeroes_read_1m(void)
* write-zeroes is not supported by the bdev.
*/
static void
blockdev_write_zeroes_read_3m(void)
blockdev_write_zeroes_read_split(void)
{
uint32_t data_length;
uint64_t offset;
int pattern;
int expected_rc;
/* Data size = 3M */
data_length = 3145728;
data_length = 3 * ZERO_BUFFER_SIZE; /* from bdev_internal.h */
offset = 0;
pattern = 0xA3;
/* Params are valid, hence the expected return value
@ -612,15 +611,14 @@ blockdev_write_zeroes_read_3m(void)
* the bdev layer zero buffer size.
*/
static void
blockdev_write_zeroes_read_3m_500k(void)
blockdev_write_zeroes_read_split_partial(void)
{
uint32_t data_length;
uint64_t offset;
int pattern;
int expected_rc;
/* Data size = 3.5M */
data_length = 3670016;
data_length = ZERO_BUFFER_SIZE * 7 / 2;
offset = 0;
pattern = 0xA3;
/* Params are valid, hence the expected return value
@ -1175,9 +1173,11 @@ __setup_ut_on_single_target(struct io_target *target)
if (
CU_add_test(suite, "blockdev write read 4k", blockdev_write_read_4k) == NULL
|| CU_add_test(suite, "blockdev write zeroes read 4k", blockdev_write_zeroes_read_4k) == NULL
|| CU_add_test(suite, "blockdev write zeroes read 1m", blockdev_write_zeroes_read_1m) == NULL
|| CU_add_test(suite, "blockdev write zeroes read 3m", blockdev_write_zeroes_read_3m) == NULL
|| CU_add_test(suite, "blockdev write zeroes read 3.5m", blockdev_write_zeroes_read_3m_500k) == NULL
|| CU_add_test(suite, "blockdev write zeroes read no split",
blockdev_write_zeroes_read_no_split) == NULL
|| CU_add_test(suite, "blockdev write zeroes read split", blockdev_write_zeroes_read_split) == NULL
|| CU_add_test(suite, "blockdev write zeroes read split partial",
blockdev_write_zeroes_read_split_partial) == NULL
|| CU_add_test(suite, "blockdev reset",
blockdev_test_reset) == NULL
|| CU_add_test(suite, "blockdev write read 512 bytes",