@@ -487,51 +487,50 @@ u64 dm_start_time_ns_from_clone(struct bio *bio)
487
487
}
488
488
EXPORT_SYMBOL_GPL (dm_start_time_ns_from_clone );
489
489
490
- static bool bio_is_flush_with_data (struct bio * bio )
490
+ static inline bool bio_is_flush_with_data (struct bio * bio )
491
491
{
492
492
return ((bio -> bi_opf & REQ_PREFLUSH ) && bio -> bi_iter .bi_size );
493
493
}
494
494
495
- static void dm_io_acct (struct dm_io * io , bool end )
495
+ static inline unsigned int dm_io_sectors (struct dm_io * io , struct bio * bio )
496
496
{
497
- struct dm_stats_aux * stats_aux = & io -> stats_aux ;
498
- unsigned long start_time = io -> start_time ;
499
- struct mapped_device * md = io -> md ;
500
- struct bio * bio = io -> orig_bio ;
501
- unsigned int sectors ;
502
-
503
497
/*
504
498
* If REQ_PREFLUSH set, don't account payload, it will be
505
499
* submitted (and accounted) after this flush completes.
506
500
*/
507
501
if (bio_is_flush_with_data (bio ))
508
- sectors = 0 ;
509
- else if (likely (!(dm_io_flagged (io , DM_IO_WAS_SPLIT ))))
510
- sectors = bio_sectors (bio );
511
- else
512
- sectors = io -> sectors ;
502
+ return 0 ;
503
+ if (unlikely (dm_io_flagged (io , DM_IO_WAS_SPLIT )))
504
+ return io -> sectors ;
505
+ return bio_sectors (bio );
506
+ }
507
+
508
+ static void dm_io_acct (struct dm_io * io , bool end )
509
+ {
510
+ struct bio * bio = io -> orig_bio ;
513
511
514
512
if (dm_io_flagged (io , DM_IO_BLK_STAT )) {
515
513
if (!end )
516
514
bdev_start_io_acct (bio -> bi_bdev , bio_op (bio ),
517
- start_time );
515
+ io -> start_time );
518
516
else
519
517
bdev_end_io_acct (bio -> bi_bdev , bio_op (bio ),
520
- sectors , start_time );
518
+ dm_io_sectors (io , bio ),
519
+ io -> start_time );
521
520
}
522
521
523
522
if (static_branch_unlikely (& stats_enabled ) &&
524
- unlikely (dm_stats_used (& md -> stats ))) {
523
+ unlikely (dm_stats_used (& io -> md -> stats ))) {
525
524
sector_t sector ;
526
525
527
- if (likely (!dm_io_flagged (io , DM_IO_WAS_SPLIT )))
528
- sector = bio -> bi_iter .bi_sector ;
529
- else
526
+ if (unlikely (dm_io_flagged (io , DM_IO_WAS_SPLIT )))
530
527
sector = bio_end_sector (bio ) - io -> sector_offset ;
528
+ else
529
+ sector = bio -> bi_iter .bi_sector ;
531
530
532
- dm_stats_account_io (& md -> stats , bio_data_dir (bio ),
533
- sector , sectors ,
534
- end , start_time , stats_aux );
531
+ dm_stats_account_io (& io -> md -> stats , bio_data_dir (bio ),
532
+ sector , dm_io_sectors ( io , bio ) ,
533
+ end , io -> start_time , & io -> stats_aux );
535
534
}
536
535
}
537
536
0 commit comments