@@ -388,15 +388,39 @@ int f2fs_target_device_index(struct f2fs_sb_info *sbi, block_t blkaddr)
388
388
return 0 ;
389
389
}
390
390
391
+ static void __attach_io_flag (struct f2fs_io_info * fio , unsigned int io_flag )
392
+ {
393
+ unsigned int temp_mask = (1 << NR_TEMP_TYPE ) - 1 ;
394
+ unsigned int fua_flag = io_flag & temp_mask ;
395
+ unsigned int meta_flag = (io_flag >> NR_TEMP_TYPE ) & temp_mask ;
396
+
397
+ /*
398
+ * data/node io flag bits per temp:
399
+ * REQ_META | REQ_FUA |
400
+ * 5 | 4 | 3 | 2 | 1 | 0 |
401
+ * Cold | Warm | Hot | Cold | Warm | Hot |
402
+ */
403
+ if ((1 << fio -> temp ) & meta_flag )
404
+ fio -> op_flags |= REQ_META ;
405
+ if ((1 << fio -> temp ) & fua_flag )
406
+ fio -> op_flags |= REQ_FUA ;
407
+ }
408
+
391
409
static struct bio * __bio_alloc (struct f2fs_io_info * fio , int npages )
392
410
{
393
411
struct f2fs_sb_info * sbi = fio -> sbi ;
394
412
struct block_device * bdev ;
395
413
sector_t sector ;
396
414
struct bio * bio ;
397
415
416
+ if (fio -> type == DATA )
417
+ __attach_io_flag (fio , sbi -> data_io_flag );
418
+ else if (fio -> type == NODE )
419
+ __attach_io_flag (fio , sbi -> node_io_flag );
420
+
398
421
bdev = f2fs_target_device (sbi , fio -> new_blkaddr , & sector );
399
- bio = bio_alloc_bioset (bdev , npages , 0 , GFP_NOIO , & f2fs_bioset );
422
+ bio = bio_alloc_bioset (bdev , npages , fio -> op | fio -> op_flags , GFP_NOIO ,
423
+ & f2fs_bioset );
400
424
bio -> bi_iter .bi_sector = sector ;
401
425
if (is_read_io (fio -> op )) {
402
426
bio -> bi_end_io = f2fs_read_end_io ;
@@ -501,44 +525,13 @@ void f2fs_submit_bio(struct f2fs_sb_info *sbi,
501
525
__submit_bio (sbi , bio , type );
502
526
}
503
527
504
- static void __attach_io_flag (struct f2fs_io_info * fio )
505
- {
506
- struct f2fs_sb_info * sbi = fio -> sbi ;
507
- unsigned int temp_mask = (1 << NR_TEMP_TYPE ) - 1 ;
508
- unsigned int io_flag , fua_flag , meta_flag ;
509
-
510
- if (fio -> type == DATA )
511
- io_flag = sbi -> data_io_flag ;
512
- else if (fio -> type == NODE )
513
- io_flag = sbi -> node_io_flag ;
514
- else
515
- return ;
516
-
517
- fua_flag = io_flag & temp_mask ;
518
- meta_flag = (io_flag >> NR_TEMP_TYPE ) & temp_mask ;
519
-
520
- /*
521
- * data/node io flag bits per temp:
522
- * REQ_META | REQ_FUA |
523
- * 5 | 4 | 3 | 2 | 1 | 0 |
524
- * Cold | Warm | Hot | Cold | Warm | Hot |
525
- */
526
- if ((1 << fio -> temp ) & meta_flag )
527
- fio -> op_flags |= REQ_META ;
528
- if ((1 << fio -> temp ) & fua_flag )
529
- fio -> op_flags |= REQ_FUA ;
530
- }
531
-
532
528
static void __submit_merged_bio (struct f2fs_bio_info * io )
533
529
{
534
530
struct f2fs_io_info * fio = & io -> fio ;
535
531
536
532
if (!io -> bio )
537
533
return ;
538
534
539
- __attach_io_flag (fio );
540
- bio_set_op_attrs (io -> bio , fio -> op , fio -> op_flags );
541
-
542
535
if (is_read_io (fio -> op ))
543
536
trace_f2fs_prepare_read_bio (io -> sbi -> sb , fio -> type , io -> bio );
544
537
else
@@ -596,10 +589,9 @@ static void __f2fs_submit_merged_write(struct f2fs_sb_info *sbi,
596
589
/* change META to META_FLUSH in the checkpoint procedure */
597
590
if (type >= META_FLUSH ) {
598
591
io -> fio .type = META_FLUSH ;
599
- io -> fio .op = REQ_OP_WRITE ;
600
- io -> fio .op_flags = REQ_META | REQ_PRIO | REQ_SYNC ;
592
+ io -> bio -> bi_opf |= REQ_META | REQ_PRIO | REQ_SYNC ;
601
593
if (!test_opt (sbi , NOBARRIER ))
602
- io -> fio . op_flags |= REQ_PREFLUSH | REQ_FUA ;
594
+ io -> bio -> bi_opf |= REQ_PREFLUSH | REQ_FUA ;
603
595
}
604
596
__submit_merged_bio (io );
605
597
up_write (& io -> io_rwsem );
@@ -680,9 +672,6 @@ int f2fs_submit_page_bio(struct f2fs_io_info *fio)
680
672
if (fio -> io_wbc && !is_read_io (fio -> op ))
681
673
wbc_account_cgroup_owner (fio -> io_wbc , page , PAGE_SIZE );
682
674
683
- __attach_io_flag (fio );
684
- bio_set_op_attrs (bio , fio -> op , fio -> op_flags );
685
-
686
675
inc_page_count (fio -> sbi , is_read_io (fio -> op ) ?
687
676
__read_io_type (page ): WB_DATA_TYPE (fio -> page ));
688
677
@@ -876,10 +865,8 @@ int f2fs_merge_page_bio(struct f2fs_io_info *fio)
876
865
alloc_new :
877
866
if (!bio ) {
878
867
bio = __bio_alloc (fio , BIO_MAX_VECS );
879
- __attach_io_flag (fio );
880
868
f2fs_set_bio_crypt_ctx (bio , fio -> page -> mapping -> host ,
881
869
fio -> page -> index , fio , GFP_NOIO );
882
- bio_set_op_attrs (bio , fio -> op , fio -> op_flags );
883
870
884
871
add_bio_entry (fio -> sbi , bio , page , fio -> temp );
885
872
} else {
@@ -988,7 +975,8 @@ static struct bio *f2fs_grab_read_bio(struct inode *inode, block_t blkaddr,
988
975
sector_t sector ;
989
976
struct block_device * bdev = f2fs_target_device (sbi , blkaddr , & sector );
990
977
991
- bio = bio_alloc_bioset (bdev , bio_max_segs (nr_pages ), REQ_OP_READ ,
978
+ bio = bio_alloc_bioset (bdev , bio_max_segs (nr_pages ),
979
+ REQ_OP_READ | op_flag ,
992
980
for_write ? GFP_NOIO : GFP_KERNEL , & f2fs_bioset );
993
981
if (!bio )
994
982
return ERR_PTR (- ENOMEM );
0 commit comments