Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
79903250
Commit
79903250
authored
Dec 02, 2021
by
Max Kellermann
Committed by
Max Kellermann
Dec 03, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
io/uring/Queue: add method RequireSubmitEntry()
Fixes assertion failure when the submit queue is empty.
parent
c8f174ac
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
4 deletions
+30
-4
Queue.cxx
src/io/uring/Queue.cxx
+19
-0
Queue.hxx
src/io/uring/Queue.hxx
+8
-0
ReadOperation.cxx
src/io/uring/ReadOperation.cxx
+3
-4
No files found.
src/io/uring/Queue.cxx
View file @
79903250
...
...
@@ -34,6 +34,8 @@
#include "CancellableOperation.hxx"
#include "util/DeleteDisposer.hxx"
#include <stdexcept>
namespace
Uring
{
Queue
::
Queue
(
unsigned
entries
,
unsigned
flags
)
...
...
@@ -46,6 +48,23 @@ Queue::~Queue() noexcept
operations
.
clear_and_dispose
(
DeleteDisposer
{});
}
struct
io_uring_sqe
&
Queue
::
RequireSubmitEntry
()
{
auto
*
sqe
=
GetSubmitEntry
();
if
(
sqe
==
nullptr
)
{
/* the submit queue is full; submit it to the kernel
and try again */
Submit
();
sqe
=
GetSubmitEntry
();
if
(
sqe
==
nullptr
)
throw
std
::
runtime_error
{
"io_uring_get_sqe() failed"
};
}
return
*
sqe
;
}
void
Queue
::
AddPending
(
struct
io_uring_sqe
&
sqe
,
Operation
&
operation
)
noexcept
...
...
src/io/uring/Queue.hxx
View file @
79903250
...
...
@@ -63,6 +63,14 @@ public:
return
ring
.
GetSubmitEntry
();
}
/**
* Like GetSubmitEntry(), but call Submit() if the submit
* queue is full.
*
* May throw exceptions if Submit() fails.
*/
struct
io_uring_sqe
&
RequireSubmitEntry
();
bool
HasPending
()
const
noexcept
{
return
!
operations
.
empty
();
}
...
...
src/io/uring/ReadOperation.cxx
View file @
79903250
...
...
@@ -45,14 +45,13 @@ ReadOperation::Start(Queue &queue, FileDescriptor fd, off_t offset,
buffer
=
std
::
make_unique
<
std
::
byte
[]
>
(
size
);
auto
*
s
=
queue
.
GetSubmitEntry
();
assert
(
s
!=
nullptr
);
// TODO: what if the submit queue is full?
auto
&
s
=
queue
.
RequireSubmitEntry
();
iov
.
iov_base
=
buffer
.
get
();
iov
.
iov_len
=
size
;
io_uring_prep_readv
(
s
,
fd
.
Get
(),
&
iov
,
1
,
offset
);
queue
.
Push
(
*
s
,
*
this
);
io_uring_prep_readv
(
&
s
,
fd
.
Get
(),
&
iov
,
1
,
offset
);
queue
.
Push
(
s
,
*
this
);
}
void
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment