@@ -48,7 +48,6 @@ static int io_buffer_add_list(struct io_ring_ctx *ctx,
48
48
* always under the ->uring_lock, but lookups from mmap do.
49
49
*/
50
50
bl -> bgid = bgid ;
51
- atomic_set (& bl -> refs , 1 );
52
51
guard (mutex )(& ctx -> mmap_lock );
53
52
return xa_err (xa_store (& ctx -> io_bl_xa , bgid , bl , GFP_KERNEL ));
54
53
}
@@ -385,12 +384,10 @@ static int __io_remove_buffers(struct io_ring_ctx *ctx,
385
384
return i ;
386
385
}
387
386
388
- void io_put_bl (struct io_ring_ctx * ctx , struct io_buffer_list * bl )
387
+ static void io_put_bl (struct io_ring_ctx * ctx , struct io_buffer_list * bl )
389
388
{
390
- if (atomic_dec_and_test (& bl -> refs )) {
391
- __io_remove_buffers (ctx , bl , -1U );
392
- kfree (bl );
393
- }
389
+ __io_remove_buffers (ctx , bl , -1U );
390
+ kfree (bl );
394
391
}
395
392
396
393
void io_destroy_buffers (struct io_ring_ctx * ctx )
@@ -804,10 +801,8 @@ struct io_buffer_list *io_pbuf_get_bl(struct io_ring_ctx *ctx,
804
801
805
802
bl = xa_load (& ctx -> io_bl_xa , bgid );
806
803
/* must be a mmap'able buffer ring and have pages */
807
- if (bl && bl -> flags & IOBL_MMAP ) {
808
- if (atomic_inc_not_zero (& bl -> refs ))
809
- return bl ;
810
- }
804
+ if (bl && bl -> flags & IOBL_MMAP )
805
+ return bl ;
811
806
812
807
return ERR_PTR (- EINVAL );
813
808
}
@@ -817,7 +812,7 @@ int io_pbuf_mmap(struct file *file, struct vm_area_struct *vma)
817
812
struct io_ring_ctx * ctx = file -> private_data ;
818
813
loff_t pgoff = vma -> vm_pgoff << PAGE_SHIFT ;
819
814
struct io_buffer_list * bl ;
820
- int bgid , ret ;
815
+ int bgid ;
821
816
822
817
lockdep_assert_held (& ctx -> mmap_lock );
823
818
@@ -826,7 +821,5 @@ int io_pbuf_mmap(struct file *file, struct vm_area_struct *vma)
826
821
if (IS_ERR (bl ))
827
822
return PTR_ERR (bl );
828
823
829
- ret = io_uring_mmap_pages (ctx , vma , bl -> buf_pages , bl -> buf_nr_pages );
830
- io_put_bl (ctx , bl );
831
- return ret ;
824
+ return io_uring_mmap_pages (ctx , vma , bl -> buf_pages , bl -> buf_nr_pages );
832
825
}
0 commit comments