uring: Add a uring.h file.
Purpose: The liburing library has recently changed the liburing.h, io_uring_enter is removed in liburing.h, so proposed this patch to fix this issue. And after applying this patch, it could work for both old and new liburing library. Change-Id: Ifdfe74038f626d36ae8cf1fb01efc297814f094a Signed-off-by: Ziye Yang <ziye.yang@intel.com> Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/478576 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Community-CI: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
This commit is contained in:
parent
3022d2f83b
commit
cebc20d9be
51
include/spdk_internal/uring.h
Normal file
51
include/spdk_internal/uring.h
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
/*-
|
||||||
|
* BSD LICENSE
|
||||||
|
*
|
||||||
|
* Copyright (c) Intel Corporation.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
* * Neither the name of Intel Corporation nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived
|
||||||
|
* from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SPDK_INTERNAL_URING_H
|
||||||
|
#define SPDK_INTERNAL_URING_H
|
||||||
|
|
||||||
|
#include <liburing.h>
|
||||||
|
|
||||||
|
#ifndef __NR_sys_io_uring_enter
|
||||||
|
#define __NR_sys_io_uring_enter 426
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static int
|
||||||
|
spdk_io_uring_enter(int ring_fd, unsigned int to_submit,
|
||||||
|
unsigned int min_complete, unsigned int flags)
|
||||||
|
{
|
||||||
|
return syscall(__NR_sys_io_uring_enter, ring_fd, to_submit,
|
||||||
|
min_complete, flags, NULL, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* SPDK_INTERNAL_URING_H */
|
@ -47,8 +47,7 @@
|
|||||||
#include "spdk/string.h"
|
#include "spdk/string.h"
|
||||||
|
|
||||||
#include "spdk_internal/log.h"
|
#include "spdk_internal/log.h"
|
||||||
|
#include "spdk_internal/uring.h"
|
||||||
#include <liburing.h>
|
|
||||||
|
|
||||||
struct bdev_uring_io_channel {
|
struct bdev_uring_io_channel {
|
||||||
struct bdev_uring_group_channel *group_ch;
|
struct bdev_uring_group_channel *group_ch;
|
||||||
@ -250,15 +249,15 @@ bdev_uring_group_poll(void *arg)
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
if (to_submit > 0) {
|
if (to_submit > 0) {
|
||||||
/* If there are I/O to submit, use io_uring_submit here.
|
/* If there are I/O to submit, use io_uring_submit here.
|
||||||
* It will automatically call io_uring_enter appropriately. */
|
* It will automatically call spdk_io_uring_enter appropriately. */
|
||||||
ret = io_uring_submit(&group_ch->uring);
|
ret = io_uring_submit(&group_ch->uring);
|
||||||
group_ch->io_pending = 0;
|
group_ch->io_pending = 0;
|
||||||
group_ch->io_inflight += to_submit;
|
group_ch->io_inflight += to_submit;
|
||||||
} else if (to_complete > 0) {
|
} else if (to_complete > 0) {
|
||||||
/* If there are I/O in flight but none to submit, we need to
|
/* If there are I/O in flight but none to submit, we need to
|
||||||
* call io_uring_enter ourselves. */
|
* call io_uring_enter ourselves. */
|
||||||
ret = io_uring_enter(group_ch->uring.ring_fd, 0, 0,
|
ret = spdk_io_uring_enter(group_ch->uring.ring_fd, 0, 0,
|
||||||
IORING_ENTER_GETEVENTS, NULL);
|
IORING_ENTER_GETEVENTS);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user