mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 02:30:34 +02:00 
			
		
		
		
	block: refactor __bio_iov_bvec_add_pages
Return early on error, and add an unlikely annotation for that case. Reviewed-by: Ming Lei <ming.lei@redhat.com> Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Bart Van Assche <bvanassche@acm.org> Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de> Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
		
							parent
							
								
									8a96a0e408
								
							
						
					
					
						commit
						a10584c3cd
					
				
					 1 changed files with 9 additions and 10 deletions
				
			
		| 
						 | 
					@ -873,7 +873,9 @@ static int __bio_iov_bvec_add_pages(struct bio *bio, struct iov_iter *iter)
 | 
				
			||||||
	len = min_t(size_t, bv->bv_len - iter->iov_offset, iter->count);
 | 
						len = min_t(size_t, bv->bv_len - iter->iov_offset, iter->count);
 | 
				
			||||||
	size = bio_add_page(bio, bv->bv_page, len,
 | 
						size = bio_add_page(bio, bv->bv_page, len,
 | 
				
			||||||
				bv->bv_offset + iter->iov_offset);
 | 
									bv->bv_offset + iter->iov_offset);
 | 
				
			||||||
	if (size == len) {
 | 
						if (unlikely(size != len))
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!bio_flagged(bio, BIO_NO_PAGE_REF)) {
 | 
						if (!bio_flagged(bio, BIO_NO_PAGE_REF)) {
 | 
				
			||||||
		struct page *page;
 | 
							struct page *page;
 | 
				
			||||||
		int i;
 | 
							int i;
 | 
				
			||||||
| 
						 | 
					@ -884,9 +886,6 @@ static int __bio_iov_bvec_add_pages(struct bio *bio, struct iov_iter *iter)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	iov_iter_advance(iter, size);
 | 
						iov_iter_advance(iter, size);
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return -EINVAL;
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define PAGE_PTRS_PER_BVEC     (sizeof(struct bio_vec) / sizeof(struct page *))
 | 
					#define PAGE_PTRS_PER_BVEC     (sizeof(struct bio_vec) / sizeof(struct page *))
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue