if (test_bit(WriteErrorSeen, &rdev->flags)) { ... if (is_bad && first_bad <= r1_bio->sector) { bad_sectors -= (r1_bio->sector - first_bad); if (bad_sectors < max_sectors) max_sectors = bad_sectors; rdev_dec_pending(rdev, mddev); continue; } ... } When the condition "is_bad && first_bad <= r1_bio->sector" is true, this rdev device will be skipped and will no participate in io, so I think the following code snippet is unnecessary: bad_sectors -= (r1_bio->sector - first_bad); if (bad_sectors < max_sectors) max_sectors = bad_sectors; So I am confused why we need to update max_sectors in this case?