Skip to contentSkip to conversation

Use io_ring_register_ring_fd() to skip fd operations

PATCH Superseded Sam Li 2 participants 3 messages Apr 18, 2022 Block layer

v1 of 6 Superseded Latest is v6 →

lore
Share & tools
lore

Sam Li

author
#0 lore raw

PATCH 2/2 Use io_ring_register_ring_fd() to skip fd operations

fix code style issue.

---
 block/io_uring.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
block/io_uring.c +7 -2
index 2942967126..57745ecfa1 100644
@@ -436,10 +436,15 @@ LuringState *luring_init(Error **errp)
 
     ioq_init(&s->io_q);
     if (io_uring_register_ring_fd(&s->ring) < 0) {
-        error_setg_errno(errp, errno, "failed to register linux io_uring ring file descriptor");
+        /*
+         * If the function fails, it will fallback to the non-optimized io_uring
+         * operations.
+         */
+        error_setg_errno(errp, errno,
+                         "failed to register linux io_uring ring file descriptor");
     }
-    return s;
 
+    return s;
 }
 
 void luring_cleanup(LuringState *s)
Signature · 1 line
2.35.1
#1 lore raw
Quoted 1 line · Sam Li

fix code style issue.

This patch must be squashed into the previous one.

Quoted 11 lines
---
 block/io_uring.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
block/io_uring.c +0 -0
index 2942967126..57745ecfa1 100644

block/io_uring.c LuringState *luring_init(Error **errp) · line 442

Quoted 8 lines
block/io_uring.c +4 -1
@@ -436,10 +436,15 @@ LuringState *luring_init(Error **errp)
 
     ioq_init(&s->io_q);
     if (io_uring_register_ring_fd(&s->ring) < 0) {
-        error_setg_errno(errp, errno, "failed to register linux io_uring ring file descriptor");
+        /*
+         * If the function fails, it will fallback to the non-optimized io_uring
+         * operations.
+         */

The comment wording is a little odd: given that the comment is inside the "if", meaning that we are in the case "the function failed", saying "if the function fails..." is strange. You could simply state something like:

	/*
	 * Only warn about this error: we will fall back to the non-optimized
	 * io_uring operations.
	 */
Quoted 9 lines
block/io_uring.c +3 -1
+        error_setg_errno(errp, errno,
+                         "failed to register linux io_uring ring file descriptor");
     }
-    return s;
 
+    return s;
 }
 
 void luring_cleanup(LuringState *s)
Signature · 2 lines
Damien Le Moal
Western Digital Research
author
#2 lore raw

Thanks for noticing the problem. I've done that.

Sam

Quoted 54 lines · Damien Le Moal <[email protected]> 于2022年4月19日周二 06:24写道:
Quoted 1 line · Sam Li

fix code style issue.

This patch must be squashed into the previous one.

Quoted 11 lines
---
 block/io_uring.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
block/io_uring.c +0 -0
index 2942967126..57745ecfa1 100644

block/io_uring.c LuringState *luring_init(Error **errp) · line 439

Quoted 4 lines
block/io_uring.c +0 -1
@@ -436,10 +436,15 @@ LuringState *luring_init(Error **errp)
 
     ioq_init(&s->io_q);
     if (io_uring_register_ring_fd(&s->ring) < 0) {
-        error_setg_errno(errp, errno, "failed to register linux

io_uring ring file descriptor");

block/io_uring.c LuringState *luring_init(Error **errp) · line 440

Quoted 2 lines
block/io_uring.c +2 -0
+        /*
+         * If the function fails, it will fallback to the non-optimized

io_uring

block/io_uring.c LuringState *luring_init(Error **errp) · line 442

Quoted 2 lines
block/io_uring.c +2 -0
+         * operations.
+         */

The comment wording is a little odd: given that the comment is inside the "if",
meaning that we are in the case "the function failed", saying "if the function
fails..." is strange. You could simply state something like:

/*
* Only warn about this error: we will fall back to the
non-optimized
* io_uring operations.
*/

block/io_uring.c LuringState *luring_init(Error **errp) · line 444

Quoted 2 lines
block/io_uring.c +2 -0
+        error_setg_errno(errp, errno,
+                         "failed to register linux io_uring ring file

descriptor");

block/io_uring.c LuringState *luring_init(Error **errp) · line 450

Quoted 7 lines
block/io_uring.c +1 -1
     }
-    return s;
 
+    return s;
 }
 
 void luring_cleanup(LuringState *s)

--
Damien Le Moal
Western Digital Research