Commit 26546437 authored by Ben Walker's avatar Ben Walker Committed by Konrad Sztyber
Browse files

util: spdk_ioviter is now variable size



The size of the structure needed can be quickly calculated using
SPDK_IOVITER_SIZE. This size can be used to allocate on the stack or the
heap. All current uses allocate on the stack.

For backward compatibility, struct spdk_ioviter has a default size of
two and can be directly placed onto the stack without calling
SPDK_IOVITER_SIZE.

Change-Id: I19858f1241d44575ebba5bacae9c560fc9dc56c7
Signed-off-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/18066


Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Reviewed-by: default avatarArtur Paszkiewicz <artur.paszkiewicz@intel.com>
parent caca70e6
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -105,7 +105,9 @@ spdk_divide_round_up(uint64_t num, uint64_t divisor)
}

/**
 * A 2-way iovec iterator. Can be allocated on the stack.
 * An N-way iovec iterator. Calculate the size, given N, using
 * SPDK_IOVITER_SIZE. For backward compatibility, the structure
 * has a default size of 2 iovecs.
 */
struct spdk_ioviter {
	uint32_t	count;
@@ -119,6 +121,9 @@ struct spdk_ioviter {
	} iters[2];
};

/* count must be greater than or equal to 2 */
#define SPDK_IOVITER_SIZE(count) (sizeof(struct spdk_single_ioviter) * (count - 2) + sizeof(struct spdk_ioviter))

/**
 * Initialize and move to the first common segment of the two given
 * iovecs. See spdk_ioviter_next().