@@ -189,7 +189,7 @@ void __user *io_buffer_select(struct io_kiocb *req, size_t *len,
189
189
190
190
bl = io_buffer_get_list (ctx , req -> buf_index );
191
191
if (likely (bl )) {
192
- if (bl -> is_buf_ring )
192
+ if (bl -> flags & IOBL_BUF_RING )
193
193
ret = io_ring_buffer_select (req , len , bl , issue_flags );
194
194
else
195
195
ret = io_provided_buffer_select (req , len , bl );
@@ -287,7 +287,7 @@ int io_buffers_select(struct io_kiocb *req, struct buf_sel_arg *arg,
287
287
if (unlikely (!bl ))
288
288
goto out_unlock ;
289
289
290
- if (bl -> is_buf_ring ) {
290
+ if (bl -> flags & IOBL_BUF_RING ) {
291
291
ret = io_ring_buffers_peek (req , arg , bl );
292
292
/*
293
293
* Don't recycle these buffers if we need to go through poll.
@@ -320,7 +320,7 @@ int io_buffers_peek(struct io_kiocb *req, struct buf_sel_arg *arg)
320
320
if (unlikely (!bl ))
321
321
return - ENOENT ;
322
322
323
- if (bl -> is_buf_ring ) {
323
+ if (bl -> flags & IOBL_BUF_RING ) {
324
324
ret = io_ring_buffers_peek (req , arg , bl );
325
325
if (ret > 0 )
326
326
req -> flags |= REQ_F_BUFFERS_COMMIT ;
@@ -340,22 +340,22 @@ static int __io_remove_buffers(struct io_ring_ctx *ctx,
340
340
if (!nbufs )
341
341
return 0 ;
342
342
343
- if (bl -> is_buf_ring ) {
343
+ if (bl -> flags & IOBL_BUF_RING ) {
344
344
i = bl -> buf_ring -> tail - bl -> head ;
345
345
if (bl -> buf_nr_pages ) {
346
346
int j ;
347
347
348
- if (!bl -> is_mmap ) {
348
+ if (!( bl -> flags & IOBL_MMAP ) ) {
349
349
for (j = 0 ; j < bl -> buf_nr_pages ; j ++ )
350
350
unpin_user_page (bl -> buf_pages [j ]);
351
351
}
352
352
io_pages_unmap (bl -> buf_ring , & bl -> buf_pages ,
353
- & bl -> buf_nr_pages , bl -> is_mmap );
354
- bl -> is_mmap = 0 ;
353
+ & bl -> buf_nr_pages , bl -> flags & IOBL_MMAP );
354
+ bl -> flags &= ~ IOBL_MMAP ;
355
355
}
356
356
/* make sure it's seen as empty */
357
357
INIT_LIST_HEAD (& bl -> buf_list );
358
- bl -> is_buf_ring = 0 ;
358
+ bl -> flags &= ~ IOBL_BUF_RING ;
359
359
return i ;
360
360
}
361
361
@@ -442,7 +442,7 @@ int io_remove_buffers(struct io_kiocb *req, unsigned int issue_flags)
442
442
if (bl ) {
443
443
ret = - EINVAL ;
444
444
/* can't use provide/remove buffers command on mapped buffers */
445
- if (!bl -> is_buf_ring )
445
+ if (!( bl -> flags & IOBL_BUF_RING ) )
446
446
ret = __io_remove_buffers (ctx , bl , p -> nbufs );
447
447
}
448
448
io_ring_submit_unlock (ctx , issue_flags );
@@ -589,7 +589,7 @@ int io_provide_buffers(struct io_kiocb *req, unsigned int issue_flags)
589
589
}
590
590
}
591
591
/* can't add buffers via this command for a mapped buffer ring */
592
- if (bl -> is_buf_ring ) {
592
+ if (bl -> flags & IOBL_BUF_RING ) {
593
593
ret = - EINVAL ;
594
594
goto err ;
595
595
}
@@ -641,8 +641,8 @@ static int io_pin_pbuf_ring(struct io_uring_buf_reg *reg,
641
641
bl -> buf_pages = pages ;
642
642
bl -> buf_nr_pages = nr_pages ;
643
643
bl -> buf_ring = br ;
644
- bl -> is_buf_ring = 1 ;
645
- bl -> is_mmap = 0 ;
644
+ bl -> flags |= IOBL_BUF_RING ;
645
+ bl -> flags &= ~ IOBL_MMAP ;
646
646
return 0 ;
647
647
error_unpin :
648
648
unpin_user_pages (pages , nr_pages );
@@ -665,8 +665,7 @@ static int io_alloc_pbuf_ring(struct io_ring_ctx *ctx,
665
665
return - ENOMEM ;
666
666
}
667
667
668
- bl -> is_buf_ring = 1 ;
669
- bl -> is_mmap = 1 ;
668
+ bl -> flags |= (IOBL_BUF_RING | IOBL_MMAP );
670
669
return 0 ;
671
670
}
672
671
@@ -705,7 +704,7 @@ int io_register_pbuf_ring(struct io_ring_ctx *ctx, void __user *arg)
705
704
bl = io_buffer_get_list (ctx , reg .bgid );
706
705
if (bl ) {
707
706
/* if mapped buffer ring OR classic exists, don't allow */
708
- if (bl -> is_buf_ring || !list_empty (& bl -> buf_list ))
707
+ if (bl -> flags & IOBL_BUF_RING || !list_empty (& bl -> buf_list ))
709
708
return - EEXIST ;
710
709
} else {
711
710
free_bl = bl = kzalloc (sizeof (* bl ), GFP_KERNEL );
@@ -747,7 +746,7 @@ int io_unregister_pbuf_ring(struct io_ring_ctx *ctx, void __user *arg)
747
746
bl = io_buffer_get_list (ctx , reg .bgid );
748
747
if (!bl )
749
748
return - ENOENT ;
750
- if (!bl -> is_buf_ring )
749
+ if (!( bl -> flags & IOBL_BUF_RING ) )
751
750
return - EINVAL ;
752
751
753
752
xa_erase (& ctx -> io_bl_xa , bl -> bgid );
@@ -771,7 +770,7 @@ int io_register_pbuf_status(struct io_ring_ctx *ctx, void __user *arg)
771
770
bl = io_buffer_get_list (ctx , buf_status .buf_group );
772
771
if (!bl )
773
772
return - ENOENT ;
774
- if (!bl -> is_buf_ring )
773
+ if (!( bl -> flags & IOBL_BUF_RING ) )
775
774
return - EINVAL ;
776
775
777
776
buf_status .head = bl -> head ;
@@ -802,7 +801,7 @@ struct io_buffer_list *io_pbuf_get_bl(struct io_ring_ctx *ctx,
802
801
bl = xa_load (& ctx -> io_bl_xa , bgid );
803
802
/* must be a mmap'able buffer ring and have pages */
804
803
ret = false;
805
- if (bl && bl -> is_mmap )
804
+ if (bl && bl -> flags & IOBL_MMAP )
806
805
ret = atomic_inc_not_zero (& bl -> refs );
807
806
rcu_read_unlock ();
808
807
0 commit comments