mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	block: allow passing a NULL bdev to bio_alloc_clone/bio_init_clone
Device mapper wants to allocate a bio before knowing the device it gets send to, so add explicit support for that. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Mike Snitzer <snitzer@kernel.org> Link: https://lore.kernel.org/r/20220504142950.567582-3-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
		
							parent
							
								
									513616843d
								
							
						
					
					
						commit
						7ecc56c62b
					
				
					 1 changed files with 6 additions and 4 deletions
				
			
		
							
								
								
									
										10
									
								
								block/bio.c
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								block/bio.c
									
									
									
									
									
								
							| 
						 | 
				
			
			@ -761,13 +761,15 @@ static int __bio_clone(struct bio *bio, struct bio *bio_src, gfp_t gfp)
 | 
			
		|||
	bio_set_flag(bio, BIO_CLONED);
 | 
			
		||||
	if (bio_flagged(bio_src, BIO_THROTTLED))
 | 
			
		||||
		bio_set_flag(bio, BIO_THROTTLED);
 | 
			
		||||
	if (bio->bi_bdev == bio_src->bi_bdev &&
 | 
			
		||||
	    bio_flagged(bio_src, BIO_REMAPPED))
 | 
			
		||||
		bio_set_flag(bio, BIO_REMAPPED);
 | 
			
		||||
	bio->bi_ioprio = bio_src->bi_ioprio;
 | 
			
		||||
	bio->bi_iter = bio_src->bi_iter;
 | 
			
		||||
 | 
			
		||||
	bio_clone_blkg_association(bio, bio_src);
 | 
			
		||||
	if (bio->bi_bdev) {
 | 
			
		||||
		if (bio->bi_bdev == bio_src->bi_bdev &&
 | 
			
		||||
		    bio_flagged(bio_src, BIO_REMAPPED))
 | 
			
		||||
			bio_set_flag(bio, BIO_REMAPPED);
 | 
			
		||||
		bio_clone_blkg_association(bio, bio_src);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (bio_crypt_clone(bio, bio_src, gfp) < 0)
 | 
			
		||||
		return -ENOMEM;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue