mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	io_uring: defer alloc_hint update to io_file_bitmap_set()
io_file_bitmap_get() returns a free bitmap slot, but if it isn't used later, such as io_queue_rsrc_removal() returns error, in this case, we should not update alloc_hint at all, which still should be considered as a valid candidate for next io_file_bitmap_get() calls. To fix this issue, only update alloc_hint in io_file_bitmap_set(). Signed-off-by: Xiaoguang Wang <xiaoguang.wang@linux.alibaba.com> Link: https://lore.kernel.org/r/20220528015109.48039-1-xiaoguang.wang@linux.alibaba.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
		
							parent
							
								
									8c71fe7502
								
							
						
					
					
						commit
						4278a0deb1
					
				
					 1 changed files with 3 additions and 8 deletions
				
			
		| 
						 | 
					@ -5419,15 +5419,11 @@ static int io_file_bitmap_get(struct io_ring_ctx *ctx)
 | 
				
			||||||
	unsigned long nr = ctx->nr_user_files;
 | 
						unsigned long nr = ctx->nr_user_files;
 | 
				
			||||||
	int ret;
 | 
						int ret;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (table->alloc_hint >= nr)
 | 
					 | 
				
			||||||
		table->alloc_hint = 0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	do {
 | 
						do {
 | 
				
			||||||
		ret = find_next_zero_bit(table->bitmap, nr, table->alloc_hint);
 | 
							ret = find_next_zero_bit(table->bitmap, nr, table->alloc_hint);
 | 
				
			||||||
		if (ret != nr) {
 | 
							if (ret != nr)
 | 
				
			||||||
			table->alloc_hint = ret + 1;
 | 
					 | 
				
			||||||
			return ret;
 | 
								return ret;
 | 
				
			||||||
		}
 | 
					
 | 
				
			||||||
		if (!table->alloc_hint)
 | 
							if (!table->alloc_hint)
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -9682,8 +9678,7 @@ static inline void io_file_bitmap_set(struct io_file_table *table, int bit)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	WARN_ON_ONCE(test_bit(bit, table->bitmap));
 | 
						WARN_ON_ONCE(test_bit(bit, table->bitmap));
 | 
				
			||||||
	__set_bit(bit, table->bitmap);
 | 
						__set_bit(bit, table->bitmap);
 | 
				
			||||||
	if (bit == table->alloc_hint)
 | 
						table->alloc_hint = bit + 1;
 | 
				
			||||||
		table->alloc_hint++;
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static inline void io_file_bitmap_clear(struct io_file_table *table, int bit)
 | 
					static inline void io_file_bitmap_clear(struct io_file_table *table, int bit)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue