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:
Ziye Yang 2019-12-21 01:38:02 +08:00 committed by Tomasz Zawadzki
parent 3022d2f83b
commit cebc20d9be
2 changed files with 55 additions and 5 deletions

View 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 */

View File

@ -47,8 +47,7 @@
#include "spdk/string.h"
#include "spdk_internal/log.h"
#include <liburing.h>
#include "spdk_internal/uring.h"
struct bdev_uring_io_channel {
struct bdev_uring_group_channel *group_ch;
@ -250,15 +249,15 @@ bdev_uring_group_poll(void *arg)
ret = 0;
if (to_submit > 0) {
/* 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);
group_ch->io_pending = 0;
group_ch->io_inflight += to_submit;
} else if (to_complete > 0) {
/* If there are I/O in flight but none to submit, we need to
* call io_uring_enter ourselves. */
ret = io_uring_enter(group_ch->uring.ring_fd, 0, 0,
IORING_ENTER_GETEVENTS, NULL);
ret = spdk_io_uring_enter(group_ch->uring.ring_fd, 0, 0,
IORING_ENTER_GETEVENTS);
}
if (ret < 0) {