@@ -84,7 +84,8 @@ struct clone_info {
84
84
struct dm_io * io ;
85
85
sector_t sector ;
86
86
unsigned sector_count ;
87
- bool submit_as_polled ;
87
+ bool is_abnormal_io :1 ;
88
+ bool submit_as_polled :1 ;
88
89
};
89
90
90
91
#define DM_TARGET_IO_BIO_OFFSET (offsetof(struct dm_target_io, clone))
@@ -1491,21 +1492,24 @@ static void __send_changing_extent_only(struct clone_info *ci, struct dm_target
1491
1492
1492
1493
static bool is_abnormal_io (struct bio * bio )
1493
1494
{
1494
- bool r = false ;
1495
+ unsigned int op = bio_op ( bio ) ;
1495
1496
1496
- switch (bio_op (bio )) {
1497
- case REQ_OP_DISCARD :
1498
- case REQ_OP_SECURE_ERASE :
1499
- case REQ_OP_WRITE_ZEROES :
1500
- r = true;
1501
- break ;
1497
+ if (op != REQ_OP_READ && op != REQ_OP_WRITE && op != REQ_OP_FLUSH ) {
1498
+ switch (op ) {
1499
+ case REQ_OP_DISCARD :
1500
+ case REQ_OP_SECURE_ERASE :
1501
+ case REQ_OP_WRITE_ZEROES :
1502
+ return true;
1503
+ default :
1504
+ break ;
1505
+ }
1502
1506
}
1503
1507
1504
- return r ;
1508
+ return false ;
1505
1509
}
1506
1510
1507
- static bool __process_abnormal_io (struct clone_info * ci , struct dm_target * ti ,
1508
- blk_status_t * status )
1511
+ static blk_status_t __process_abnormal_io (struct clone_info * ci ,
1512
+ struct dm_target * ti )
1509
1513
{
1510
1514
unsigned num_bios = 0 ;
1511
1515
@@ -1519,8 +1523,6 @@ static bool __process_abnormal_io(struct clone_info *ci, struct dm_target *ti,
1519
1523
case REQ_OP_WRITE_ZEROES :
1520
1524
num_bios = ti -> num_write_zeroes_bios ;
1521
1525
break ;
1522
- default :
1523
- return false;
1524
1526
}
1525
1527
1526
1528
/*
@@ -1530,12 +1532,10 @@ static bool __process_abnormal_io(struct clone_info *ci, struct dm_target *ti,
1530
1532
* check was performed.
1531
1533
*/
1532
1534
if (unlikely (!num_bios ))
1533
- * status = BLK_STS_NOTSUPP ;
1534
- else {
1535
- __send_changing_extent_only (ci , ti , num_bios );
1536
- * status = BLK_STS_OK ;
1537
- }
1538
- return true;
1535
+ return BLK_STS_NOTSUPP ;
1536
+
1537
+ __send_changing_extent_only (ci , ti , num_bios );
1538
+ return BLK_STS_OK ;
1539
1539
}
1540
1540
1541
1541
/*
@@ -1588,11 +1588,12 @@ static blk_status_t __split_and_process_bio(struct clone_info *ci)
1588
1588
struct bio * clone ;
1589
1589
struct dm_target * ti ;
1590
1590
unsigned len ;
1591
- blk_status_t error = BLK_STS_IOERR ;
1592
1591
1593
1592
ti = dm_table_find_target (ci -> map , ci -> sector );
1594
- if (unlikely (!ti || __process_abnormal_io (ci , ti , & error )))
1595
- return error ;
1593
+ if (unlikely (!ti ))
1594
+ return BLK_STS_IOERR ;
1595
+ else if (unlikely (ci -> is_abnormal_io ))
1596
+ return __process_abnormal_io (ci , ti );
1596
1597
1597
1598
/*
1598
1599
* Only support bio polling for normal IO, and the target io is
@@ -1612,11 +1613,12 @@ static blk_status_t __split_and_process_bio(struct clone_info *ci)
1612
1613
}
1613
1614
1614
1615
static void init_clone_info (struct clone_info * ci , struct mapped_device * md ,
1615
- struct dm_table * map , struct bio * bio )
1616
+ struct dm_table * map , struct bio * bio , bool is_abnormal )
1616
1617
{
1617
1618
ci -> map = map ;
1618
1619
ci -> io = alloc_io (md , bio );
1619
1620
ci -> bio = bio ;
1621
+ ci -> is_abnormal_io = is_abnormal ;
1620
1622
ci -> submit_as_polled = false;
1621
1623
ci -> sector = bio -> bi_iter .bi_sector ;
1622
1624
ci -> sector_count = bio_sectors (bio );
@@ -1636,8 +1638,18 @@ static void dm_split_and_process_bio(struct mapped_device *md,
1636
1638
struct clone_info ci ;
1637
1639
struct dm_io * io ;
1638
1640
blk_status_t error = BLK_STS_OK ;
1641
+ bool is_abnormal ;
1639
1642
1640
- init_clone_info (& ci , md , map , bio );
1643
+ is_abnormal = is_abnormal_io (bio );
1644
+ if (unlikely (is_abnormal )) {
1645
+ /*
1646
+ * Use blk_queue_split() for abnormal IO (e.g. discard, etc)
1647
+ * otherwise associated queue_limits won't be imposed.
1648
+ */
1649
+ blk_queue_split (& bio );
1650
+ }
1651
+
1652
+ init_clone_info (& ci , md , map , bio , is_abnormal );
1641
1653
io = ci .io ;
1642
1654
1643
1655
if (bio -> bi_opf & REQ_PREFLUSH ) {
@@ -1697,13 +1709,6 @@ static void dm_submit_bio(struct bio *bio)
1697
1709
goto out ;
1698
1710
}
1699
1711
1700
- /*
1701
- * Use blk_queue_split() for abnormal IO (e.g. discard, writesame, etc)
1702
- * otherwise associated queue_limits won't be imposed.
1703
- */
1704
- if (unlikely (is_abnormal_io (bio )))
1705
- blk_queue_split (& bio );
1706
-
1707
1712
dm_split_and_process_bio (md , map , bio );
1708
1713
out :
1709
1714
dm_put_live_table_bio (md , srcu_idx , bio );
0 commit comments