@@ -1159,6 +1159,7 @@ static void raid10_read_request(struct mddev *mddev, struct bio *bio,
1159
1159
int slot = r10_bio -> read_slot ;
1160
1160
struct md_rdev * err_rdev = NULL ;
1161
1161
gfp_t gfp = GFP_NOIO ;
1162
+ int error ;
1162
1163
1163
1164
if (slot >= 0 && r10_bio -> devs [slot ].rdev ) {
1164
1165
/*
@@ -1206,6 +1207,10 @@ static void raid10_read_request(struct mddev *mddev, struct bio *bio,
1206
1207
if (max_sectors < bio_sectors (bio )) {
1207
1208
struct bio * split = bio_split (bio , max_sectors ,
1208
1209
gfp , & conf -> bio_split );
1210
+ if (IS_ERR (split )) {
1211
+ error = PTR_ERR (split );
1212
+ goto err_handle ;
1213
+ }
1209
1214
bio_chain (split , bio );
1210
1215
allow_barrier (conf );
1211
1216
submit_bio_noacct (bio );
@@ -1236,6 +1241,11 @@ static void raid10_read_request(struct mddev *mddev, struct bio *bio,
1236
1241
mddev_trace_remap (mddev , read_bio , r10_bio -> sector );
1237
1242
submit_bio_noacct (read_bio );
1238
1243
return ;
1244
+ err_handle :
1245
+ atomic_dec (& rdev -> nr_pending );
1246
+ bio -> bi_status = errno_to_blk_status (error );
1247
+ set_bit (R10BIO_Uptodate , & r10_bio -> state );
1248
+ raid_end_bio_io (r10_bio );
1239
1249
}
1240
1250
1241
1251
static void raid10_write_one_disk (struct mddev * mddev , struct r10bio * r10_bio ,
@@ -1343,9 +1353,10 @@ static void raid10_write_request(struct mddev *mddev, struct bio *bio,
1343
1353
struct r10bio * r10_bio )
1344
1354
{
1345
1355
struct r10conf * conf = mddev -> private ;
1346
- int i ;
1356
+ int i , k ;
1347
1357
sector_t sectors ;
1348
1358
int max_sectors ;
1359
+ int error ;
1349
1360
1350
1361
if ((mddev_is_clustered (mddev ) &&
1351
1362
md_cluster_ops -> area_resyncing (mddev , WRITE ,
@@ -1478,6 +1489,10 @@ static void raid10_write_request(struct mddev *mddev, struct bio *bio,
1478
1489
if (r10_bio -> sectors < bio_sectors (bio )) {
1479
1490
struct bio * split = bio_split (bio , r10_bio -> sectors ,
1480
1491
GFP_NOIO , & conf -> bio_split );
1492
+ if (IS_ERR (split )) {
1493
+ error = PTR_ERR (split );
1494
+ goto err_handle ;
1495
+ }
1481
1496
bio_chain (split , bio );
1482
1497
allow_barrier (conf );
1483
1498
submit_bio_noacct (bio );
@@ -1499,6 +1514,26 @@ static void raid10_write_request(struct mddev *mddev, struct bio *bio,
1499
1514
raid10_write_one_disk (mddev , r10_bio , bio , true, i );
1500
1515
}
1501
1516
one_write_done (r10_bio );
1517
+ return ;
1518
+ err_handle :
1519
+ for (k = 0 ; k < i ; k ++ ) {
1520
+ int d = r10_bio -> devs [k ].devnum ;
1521
+ struct md_rdev * rdev = conf -> mirrors [d ].rdev ;
1522
+ struct md_rdev * rrdev = conf -> mirrors [d ].replacement ;
1523
+
1524
+ if (r10_bio -> devs [k ].bio ) {
1525
+ rdev_dec_pending (rdev , mddev );
1526
+ r10_bio -> devs [k ].bio = NULL ;
1527
+ }
1528
+ if (r10_bio -> devs [k ].repl_bio ) {
1529
+ rdev_dec_pending (rrdev , mddev );
1530
+ r10_bio -> devs [k ].repl_bio = NULL ;
1531
+ }
1532
+ }
1533
+
1534
+ bio -> bi_status = errno_to_blk_status (error );
1535
+ set_bit (R10BIO_Uptodate , & r10_bio -> state );
1536
+ raid_end_bio_io (r10_bio );
1502
1537
}
1503
1538
1504
1539
static void __make_request (struct mddev * mddev , struct bio * bio , int sectors )
@@ -1640,6 +1675,11 @@ static int raid10_handle_discard(struct mddev *mddev, struct bio *bio)
1640
1675
if (remainder ) {
1641
1676
split_size = stripe_size - remainder ;
1642
1677
split = bio_split (bio , split_size , GFP_NOIO , & conf -> bio_split );
1678
+ if (IS_ERR (split )) {
1679
+ bio -> bi_status = errno_to_blk_status (PTR_ERR (split ));
1680
+ bio_endio (bio );
1681
+ return 0 ;
1682
+ }
1643
1683
bio_chain (split , bio );
1644
1684
allow_barrier (conf );
1645
1685
/* Resend the fist split part */
@@ -1650,6 +1690,11 @@ static int raid10_handle_discard(struct mddev *mddev, struct bio *bio)
1650
1690
if (remainder ) {
1651
1691
split_size = bio_sectors (bio ) - remainder ;
1652
1692
split = bio_split (bio , split_size , GFP_NOIO , & conf -> bio_split );
1693
+ if (IS_ERR (split )) {
1694
+ bio -> bi_status = errno_to_blk_status (PTR_ERR (split ));
1695
+ bio_endio (bio );
1696
+ return 0 ;
1697
+ }
1653
1698
bio_chain (split , bio );
1654
1699
allow_barrier (conf );
1655
1700
/* Resend the second split part */
0 commit comments