@@ -388,15 +388,39 @@ int f2fs_target_device_index(struct f2fs_sb_info *sbi, block_t blkaddr)
388388 return 0 ;
389389}
390390
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+
391409static struct bio * __bio_alloc (struct f2fs_io_info * fio , int npages )
392410{
393411 struct f2fs_sb_info * sbi = fio -> sbi ;
394412 struct block_device * bdev ;
395413 sector_t sector ;
396414 struct bio * bio ;
397415
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+
398421 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 );
400424 bio -> bi_iter .bi_sector = sector ;
401425 if (is_read_io (fio -> op )) {
402426 bio -> bi_end_io = f2fs_read_end_io ;
@@ -501,44 +525,13 @@ void f2fs_submit_bio(struct f2fs_sb_info *sbi,
501525 __submit_bio (sbi , bio , type );
502526}
503527
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-
532528static void __submit_merged_bio (struct f2fs_bio_info * io )
533529{
534530 struct f2fs_io_info * fio = & io -> fio ;
535531
536532 if (!io -> bio )
537533 return ;
538534
539- __attach_io_flag (fio );
540- bio_set_op_attrs (io -> bio , fio -> op , fio -> op_flags );
541-
542535 if (is_read_io (fio -> op ))
543536 trace_f2fs_prepare_read_bio (io -> sbi -> sb , fio -> type , io -> bio );
544537 else
@@ -596,10 +589,9 @@ static void __f2fs_submit_merged_write(struct f2fs_sb_info *sbi,
596589 /* change META to META_FLUSH in the checkpoint procedure */
597590 if (type >= META_FLUSH ) {
598591 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 ;
601593 if (!test_opt (sbi , NOBARRIER ))
602- io -> fio . op_flags |= REQ_PREFLUSH | REQ_FUA ;
594+ io -> bio -> bi_opf |= REQ_PREFLUSH | REQ_FUA ;
603595 }
604596 __submit_merged_bio (io );
605597 up_write (& io -> io_rwsem );
@@ -680,9 +672,6 @@ int f2fs_submit_page_bio(struct f2fs_io_info *fio)
680672 if (fio -> io_wbc && !is_read_io (fio -> op ))
681673 wbc_account_cgroup_owner (fio -> io_wbc , page , PAGE_SIZE );
682674
683- __attach_io_flag (fio );
684- bio_set_op_attrs (bio , fio -> op , fio -> op_flags );
685-
686675 inc_page_count (fio -> sbi , is_read_io (fio -> op ) ?
687676 __read_io_type (page ): WB_DATA_TYPE (fio -> page ));
688677
@@ -876,10 +865,8 @@ int f2fs_merge_page_bio(struct f2fs_io_info *fio)
876865alloc_new :
877866 if (!bio ) {
878867 bio = __bio_alloc (fio , BIO_MAX_VECS );
879- __attach_io_flag (fio );
880868 f2fs_set_bio_crypt_ctx (bio , fio -> page -> mapping -> host ,
881869 fio -> page -> index , fio , GFP_NOIO );
882- bio_set_op_attrs (bio , fio -> op , fio -> op_flags );
883870
884871 add_bio_entry (fio -> sbi , bio , page , fio -> temp );
885872 } else {
@@ -988,7 +975,8 @@ static struct bio *f2fs_grab_read_bio(struct inode *inode, block_t blkaddr,
988975 sector_t sector ;
989976 struct block_device * bdev = f2fs_target_device (sbi , blkaddr , & sector );
990977
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 ,
992980 for_write ? GFP_NOIO : GFP_KERNEL , & f2fs_bioset );
993981 if (!bio )
994982 return ERR_PTR (- ENOMEM );
0 commit comments