diff --git a/include/spdk_internal/sock.h b/include/spdk_internal/sock.h index c3effdd7d..d88d6bd03 100644 --- a/include/spdk_internal/sock.h +++ b/include/spdk_internal/sock.h @@ -48,6 +48,7 @@ extern "C" { #define MAX_EVENTS_PER_POLL 32 #define DEFAULT_SOCK_PRIORITY 0 +#define MIN_SOCK_PIPE_SIZE 1024 struct spdk_sock { struct spdk_net_impl *net_impl; diff --git a/module/sock/posix/posix.c b/module/sock/posix/posix.c index c82aa0af3..7057cbfc7 100644 --- a/module/sock/posix/posix.c +++ b/module/sock/posix/posix.c @@ -212,6 +212,9 @@ posix_sock_alloc_pipe(struct spdk_posix_sock *sock, int sz) sock->recv_pipe = NULL; sock->recv_buf = NULL; return 0; + } else if (sz < MIN_SOCK_PIPE_SIZE) { + SPDK_ERRLOG("The size of the pipe must be larger than %d\n", MIN_SOCK_PIPE_SIZE); + return -1; } /* Round up to next 64 byte multiple */ @@ -924,7 +927,7 @@ posix_sock_readv(struct spdk_sock *_sock, struct iovec *iov, int iovcnt) if (spdk_pipe_reader_bytes_available(sock->recv_pipe) == 0) { /* If the user is receiving a sufficiently large amount of data, * receive directly to their buffers. */ - if (len >= 1024) { + if (len >= MIN_SOCK_PIPE_SIZE) { return readv(sock->fd, iov, iovcnt); } diff --git a/module/sock/uring/uring.c b/module/sock/uring/uring.c index 2abdb20c9..b186420c8 100644 --- a/module/sock/uring/uring.c +++ b/module/sock/uring/uring.c @@ -232,6 +232,9 @@ uring_sock_alloc_pipe(struct spdk_uring_sock *sock, int sz) sock->recv_pipe = NULL; sock->recv_buf = NULL; return 0; + } else if (sz < MIN_SOCK_PIPE_SIZE) { + SPDK_ERRLOG("The size of the pipe must be larger than %d\n", MIN_SOCK_PIPE_SIZE); + return -1; } /* Round up to next 64 byte multiple */ @@ -660,7 +663,7 @@ uring_sock_readv(struct spdk_sock *_sock, struct iovec *iov, int iovcnt) if (spdk_pipe_reader_bytes_available(sock->recv_pipe) == 0) { /* If the user is receiving a sufficiently large amount of data, * receive directly to their buffers. */ - if (len >= 1024) { + if (len >= MIN_SOCK_PIPE_SIZE) { return readv(sock->fd, iov, iovcnt); }