Io uring: Difference between revisions

Line 81: Line 81:
<tt>resv</tt> must be zeroed out. In the absence of flags, the uring uses interrupt-driven I/O. Calling <tt>close(2)</tt> on the returned descriptor frees all resources associated with the uring.
<tt>resv</tt> must be zeroed out. In the absence of flags, the uring uses interrupt-driven I/O. Calling <tt>close(2)</tt> on the returned descriptor frees all resources associated with the uring.


<tt>io_uring_setup(2)</tt> is wrapped by liburing's <tt>io_uring_queue_init(3)</tt> and <tt>io_uring_queue_init_params(3)</tt>. When using these wrappers, <tt>io_uring_queue_exit(3)</tt> should be used to clean up. These wrappers operate on a <tt>struct io_uring</tt>:
<tt>io_uring_setup(2)</tt> is wrapped by liburing's <tt>io_uring_queue_init(3)</tt> and <tt>io_uring_queue_init_params(3)</tt>. When using these wrappers, <tt>io_uring_queue_exit(3)</tt> should be used to clean up.


<syntaxhighlight lang="c">
<syntaxhighlight lang="c">
struct io_uring {                                                                                                                  
int io_uring_queue_init(unsigned entries, struct io_uring *ring, unsigned flags);
   struct io_uring_sq sq;                                                                                                          
int io_uring_queue_init_params(unsigned entries, struct io_uring *ring, struct io_uring_params *params);
   struct io_uring_cq cq;                                                                                                          
void io_uring_queue_exit(struct io_uring *ring);
   unsigned flags;                                                                                                                  
</syntaxhighlight>
   int ring_fd;                                                                                                                    
 
   unsigned features;                                                                                                              
These wrappers operate on a <tt>struct io_uring</tt>:
   int enter_ring_fd;                                                                                                              
 
   __u8 int_flags;                                                                                                                  
<syntaxhighlight lang="c">
   __u8 pad[3];                                                                                                                    
struct io_uring {
   unsigned pad2;                                                                                                                  
   struct io_uring_sq sq;
   struct io_uring_cq cq;
   unsigned flags;
   int ring_fd;
   unsigned features;
   int enter_ring_fd;
   __u8 int_flags;
   __u8 pad[3];
   unsigned pad2;
};
};