mirror of
				https://github.com/torvalds/linux.git
				synced 2025-10-31 08:38:45 +02:00 
			
		
		
		
	io_uring/rw: Allocate async data through helper
This abstract away the cache details. Signed-off-by: Gabriel Krisman Bertazi <krisman@suse.de> Link: https://lore.kernel.org/r/20241216204615.759089-8-krisman@suse.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
		
							parent
							
								
									f49a85371d
								
							
						
					
					
						commit
						d7f11616ed
					
				
					 1 changed files with 16 additions and 20 deletions
				
			
		|  | @ -208,33 +208,29 @@ static void io_req_rw_cleanup(struct io_kiocb *req, unsigned int issue_flags) | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | static void io_rw_async_data_init(void *obj) | ||||||
|  | { | ||||||
|  | 	struct io_async_rw *rw = (struct io_async_rw *)obj; | ||||||
|  | 
 | ||||||
|  | 	rw->free_iovec = 0; | ||||||
|  | 	rw->bytes_done = 0; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| static int io_rw_alloc_async(struct io_kiocb *req) | static int io_rw_alloc_async(struct io_kiocb *req) | ||||||
| { | { | ||||||
| 	struct io_ring_ctx *ctx = req->ctx; | 	struct io_ring_ctx *ctx = req->ctx; | ||||||
| 	struct io_async_rw *rw; | 	struct io_async_rw *rw; | ||||||
| 
 | 
 | ||||||
| 	rw = io_alloc_cache_get(&ctx->rw_cache); | 	rw = io_uring_alloc_async_data(&ctx->rw_cache, req, io_rw_async_data_init); | ||||||
| 	if (rw) { | 	if (!rw) | ||||||
| 		if (rw->free_iovec) { | 		return -ENOMEM; | ||||||
| 			kasan_mempool_unpoison_object(rw->free_iovec, | 	if (rw->free_iovec) { | ||||||
| 				rw->free_iov_nr * sizeof(struct iovec)); | 		kasan_mempool_unpoison_object(rw->free_iovec, | ||||||
| 			req->flags |= REQ_F_NEED_CLEANUP; | 					      rw->free_iov_nr * sizeof(struct iovec)); | ||||||
| 		} | 		req->flags |= REQ_F_NEED_CLEANUP; | ||||||
| 		req->flags |= REQ_F_ASYNC_DATA; |  | ||||||
| 		req->async_data = rw; |  | ||||||
| 		goto done; |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	if (!io_alloc_async_data(req)) { |  | ||||||
| 		rw = req->async_data; |  | ||||||
| 		rw->free_iovec = NULL; |  | ||||||
| 		rw->free_iov_nr = 0; |  | ||||||
| done: |  | ||||||
| 		rw->bytes_done = 0; | 		rw->bytes_done = 0; | ||||||
| 		return 0; |  | ||||||
| 	} | 	} | ||||||
| 
 | 	return 0; | ||||||
| 	return -ENOMEM; |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static int io_prep_rw_setup(struct io_kiocb *req, int ddir, bool do_import) | static int io_prep_rw_setup(struct io_kiocb *req, int ddir, bool do_import) | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue
	
	 Gabriel Krisman Bertazi
						Gabriel Krisman Bertazi