blk_rq_err_bytes is only used by the scsi midlayer, so move it there.
Unified · Split
| @@ -1176,47 +1176,6 @@ blk_status_t blk_insert_cloned_request(struct request_queue *q, struct request * · 1175 unmodified lines | ||
| 1176 | 1176 | } |
| 1177 | 1177 | EXPORT_SYMBOL_GPL(blk_insert_cloned_request); |
| 1178 | 1178 | |
| 1179 | −/** | |
| 1180 | − * blk_rq_err_bytes - determine number of bytes till the next failure boundary | |
| 1181 | − * @rq: request to examine | |
| 1182 | − * | |
| 1183 | − * Description: | |
| 1184 | − * A request could be merge of IOs which require different failure | |
| 1185 | − * handling. This function determines the number of bytes which | |
| 1186 | − * can be failed from the beginning of the request without | |
| 1187 | − * crossing into area which need to be retried further. | |
| 1188 | − * | |
| 1189 | − * Return: | |
| 1190 | − * The number of bytes to fail. | |
| 1191 | − */ | |
| 1192 | −unsigned int blk_rq_err_bytes(const struct request *rq) | |
| 1193 | −{ | |
| 1194 | − unsigned int ff = rq->cmd_flags & REQ_FAILFAST_MASK; | |
| 1195 | − unsigned int bytes = 0; | |
| 1196 | − struct bio *bio; | |
| 1197 | − | |
| 1198 | − if (!(rq->rq_flags & RQF_MIXED_MERGE)) | |
| 1199 | − return blk_rq_bytes(rq); | |
| 1200 | − | |
| 1201 | − /* | |
| 1202 | − * Currently the only 'mixing' which can happen is between | |
| 1203 | − * different fastfail types. We can safely fail portions | |
| 1204 | − * which have all the failfast bits that the first one has - | |
| 1205 | − * the ones which are at least as eager to fail as the first | |
| 1206 | − * one. | |
| 1207 | − */ | |
| 1208 | − for (bio = rq->bio; bio; bio = bio->bi_next) { | |
| 1209 | − if ((bio->bi_opf & ff) != ff) | |
| 1210 | − break; | |
| 1211 | − bytes += bio->bi_iter.bi_size; | |
| 1212 | − } | |
| 1213 | − | |
| 1214 | − /* this could lead to infinite loop */ | |
| 1215 | − BUG_ON(blk_rq_bytes(rq) && !bytes); | |
| 1216 | − return bytes; | |
| 1217 | −} | |
| 1218 | −EXPORT_SYMBOL_GPL(blk_rq_err_bytes); | |
| 1219 | − | |
| 1220 | 1179 | static void update_io_ticks(struct block_device *part, unsigned long now, |
| 1221 | 1180 | bool end) |
| 1222 | 1181 | { |
| @@ -617,6 +617,46 @@ static blk_status_t scsi_result_to_blk_status(struct scsi_cmnd *cmd, int result) · 616 unmodified lines | ||
| 617 | 617 | } |
| 618 | 618 | } |
| 619 | 619 | |
| 620 | +/** | |
| 621 | + * scsi_rq_err_bytes - determine number of bytes till the next failure boundary | |
| 622 | + * @rq: request to examine | |
| 623 | + * | |
| 624 | + * Description: | |
| 625 | + * A request could be merge of IOs which require different failure | |
| 626 | + * handling. This function determines the number of bytes which | |
| 627 | + * can be failed from the beginning of the request without | |
| 628 | + * crossing into area which need to be retried further. | |
| 629 | + * | |
| 630 | + * Return: | |
| 631 | + * The number of bytes to fail. | |
| 632 | + */ | |
| 633 | +static unsigned int scsi_rq_err_bytes(const struct request *rq) | |
| 634 | +{ | |
| 635 | + unsigned int ff = rq->cmd_flags & REQ_FAILFAST_MASK; | |
| 636 | + unsigned int bytes = 0; | |
| 637 | + struct bio *bio; | |
| 638 | + | |
| 639 | + if (!(rq->rq_flags & RQF_MIXED_MERGE)) | |
| 640 | + return blk_rq_bytes(rq); | |
| 641 | + | |
| 642 | + /* | |
| 643 | + * Currently the only 'mixing' which can happen is between | |
| 644 | + * different fastfail types. We can safely fail portions | |
| 645 | + * which have all the failfast bits that the first one has - | |
| 646 | + * the ones which are at least as eager to fail as the first | |
| 647 | + * one. | |
| 648 | + */ | |
| 649 | + for (bio = rq->bio; bio; bio = bio->bi_next) { | |
| 650 | + if ((bio->bi_opf & ff) != ff) | |
| 651 | + break; | |
| 652 | + bytes += bio->bi_iter.bi_size; | |
| 653 | + } | |
| 654 | + | |
| 655 | + /* this could lead to infinite loop */ | |
| 656 | + BUG_ON(blk_rq_bytes(rq) && !bytes); | |
| 657 | + return bytes; | |
| 658 | +} | |
| 659 | + | |
| 620 | 660 | /* Helper for scsi_io_completion() when "reprep" action required. */ |
| 621 | 661 | static void scsi_io_completion_reprep(struct scsi_cmnd *cmd, |
| 622 | 662 | struct request_queue *q) |
| @@ -794,7 +834,7 @@ static void scsi_io_completion_action(struct scsi_cmnd *cmd, int result) · 171 unmodified lines | ||
| 794 | 834 | scsi_print_command(cmd); |
| 795 | 835 | } |
| 796 | 836 | } |
| 797 | − if (!scsi_end_request(req, blk_stat, blk_rq_err_bytes(req))) | |
| 837 | + if (!scsi_end_request(req, blk_stat, scsi_rq_err_bytes(req))) | |
| 798 | 838 | return; |
| 799 | 839 | fallthrough; |
| 800 | 840 | case ACTION_REPREP: |
| @@ -947,7 +947,6 @@ struct req_iterator { · 946 unmodified lines | ||
| 947 | 947 | * blk_rq_pos() : the current sector |
| 948 | 948 | * blk_rq_bytes() : bytes left in the entire request |
| 949 | 949 | * blk_rq_cur_bytes() : bytes left in the current segment |
| 950 | − * blk_rq_err_bytes() : bytes left till the next error boundary | |
| 951 | 950 | * blk_rq_sectors() : sectors left in the entire request |
| 952 | 951 | * blk_rq_cur_sectors() : sectors left in the current segment |
| 953 | 952 | * blk_rq_stats_sectors() : sectors of the entire request used for stats |
| @@ -971,8 +970,6 @@ static inline int blk_rq_cur_bytes(const struct request *rq) · 17 unmodified lines | ||
| 971 | 970 | return bio_iovec(rq->bio).bv_len; |
| 972 | 971 | } |
| 973 | 972 | |
| 974 | −unsigned int blk_rq_err_bytes(const struct request *rq); | |
| 975 | − | |
| 976 | 973 | static inline unsigned int blk_rq_sectors(const struct request *rq) |
| 977 | 974 | { |
| 978 | 975 | return blk_rq_bytes(rq) >> SECTOR_SHIFT; |