@@ -354,7 +354,7 @@ static void f2fs_write_end_io(struct bio *bio)
354
354
}
355
355
356
356
struct block_device * f2fs_target_device (struct f2fs_sb_info * sbi ,
357
- block_t blk_addr , struct bio * bio )
357
+ block_t blk_addr , sector_t * sector )
358
358
{
359
359
struct block_device * bdev = sbi -> sb -> s_bdev ;
360
360
int i ;
@@ -369,10 +369,9 @@ struct block_device *f2fs_target_device(struct f2fs_sb_info *sbi,
369
369
}
370
370
}
371
371
}
372
- if (bio ) {
373
- bio_set_dev (bio , bdev );
374
- bio -> bi_iter .bi_sector = SECTOR_FROM_BLOCK (blk_addr );
375
- }
372
+
373
+ if (sector )
374
+ * sector = SECTOR_FROM_BLOCK (blk_addr );
376
375
return bdev ;
377
376
}
378
377
@@ -392,11 +391,13 @@ int f2fs_target_device_index(struct f2fs_sb_info *sbi, block_t blkaddr)
392
391
static struct bio * __bio_alloc (struct f2fs_io_info * fio , int npages )
393
392
{
394
393
struct f2fs_sb_info * sbi = fio -> sbi ;
394
+ struct block_device * bdev ;
395
+ sector_t sector ;
395
396
struct bio * bio ;
396
397
397
- bio = bio_alloc_bioset ( NULL , npages , 0 , GFP_NOIO , & f2fs_bioset );
398
-
399
- f2fs_target_device ( sbi , fio -> new_blkaddr , bio ) ;
398
+ bdev = f2fs_target_device ( sbi , fio -> new_blkaddr , & sector );
399
+ bio = bio_alloc_bioset ( bdev , npages , 0 , GFP_NOIO , & f2fs_bioset );
400
+ bio -> bi_iter . bi_sector = sector ;
400
401
if (is_read_io (fio -> op )) {
401
402
bio -> bi_end_io = f2fs_read_end_io ;
402
403
bio -> bi_private = NULL ;
@@ -984,15 +985,15 @@ static struct bio *f2fs_grab_read_bio(struct inode *inode, block_t blkaddr,
984
985
struct bio * bio ;
985
986
struct bio_post_read_ctx * ctx = NULL ;
986
987
unsigned int post_read_steps = 0 ;
988
+ sector_t sector ;
989
+ struct block_device * bdev = f2fs_target_device (sbi , blkaddr , & sector );
987
990
988
- bio = bio_alloc_bioset (NULL , bio_max_segs (nr_pages ), REQ_OP_READ ,
991
+ bio = bio_alloc_bioset (bdev , bio_max_segs (nr_pages ), REQ_OP_READ ,
989
992
for_write ? GFP_NOIO : GFP_KERNEL , & f2fs_bioset );
990
993
if (!bio )
991
994
return ERR_PTR (- ENOMEM );
992
-
995
+ bio -> bi_iter . bi_sector = sector ;
993
996
f2fs_set_bio_crypt_ctx (bio , inode , first_idx , NULL , GFP_NOFS );
994
-
995
- f2fs_target_device (sbi , blkaddr , bio );
996
997
bio -> bi_end_io = f2fs_read_end_io ;
997
998
998
999
if (fscrypt_inode_uses_fs_layer_crypto (inode ))
0 commit comments