History

block: move blk_rq_err_bytes to scsi

blk_rq_err_bytes is only used by the scsi midlayer, so move it there.

Christoph Hellwig committed 4 years ago

Commit 79478bf1 parent d58071a3 files · +41 −45Browse files

Unified · Split

3 files
  1. block/blk-core.c +0 −41
  2. drivers/scsi/scsi_lib.c +41 −1
  3. include/linux/blk-mq.h +0 −3
block/blk-core.c+0−41
@@ -1176,47 +1176,6 @@ blk_status_t blk_insert_cloned_request(struct request_queue *q, struct request * · 1175 unmodified lines
1176}1176}
1177EXPORT_SYMBOL_GPL(blk_insert_cloned_request);1177EXPORT_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 */
1192unsigned 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}
1218EXPORT_SYMBOL_GPL(blk_rq_err_bytes);
1219
1220static void update_io_ticks(struct block_device *part, unsigned long now,1179static void update_io_ticks(struct block_device *part, unsigned long now,
1221 bool end)1180 bool end)
1222{1181{
drivers/scsi/scsi_lib.c+41−1
@@ -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 */
633static 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/* Helper for scsi_io_completion() when "reprep" action required. */660/* Helper for scsi_io_completion() when "reprep" action required. */
621static void scsi_io_completion_reprep(struct scsi_cmnd *cmd,661static void scsi_io_completion_reprep(struct scsi_cmnd *cmd,
622 struct request_queue *q)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 scsi_print_command(cmd);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 return;838 return;
799 fallthrough;839 fallthrough;
800 case ACTION_REPREP:840 case ACTION_REPREP:
include/linux/blk-mq.h+0−3
@@ -947,7 +947,6 @@ struct req_iterator { · 946 unmodified lines
947 * blk_rq_pos() : the current sector947 * blk_rq_pos() : the current sector
948 * blk_rq_bytes() : bytes left in the entire request948 * blk_rq_bytes() : bytes left in the entire request
949 * blk_rq_cur_bytes() : bytes left in the current segment949 * blk_rq_cur_bytes() : bytes left in the current segment
950 * blk_rq_err_bytes() : bytes left till the next error boundary
951 * blk_rq_sectors() : sectors left in the entire request950 * blk_rq_sectors() : sectors left in the entire request
952 * blk_rq_cur_sectors() : sectors left in the current segment951 * blk_rq_cur_sectors() : sectors left in the current segment
953 * blk_rq_stats_sectors() : sectors of the entire request used for stats952 * 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 return bio_iovec(rq->bio).bv_len;970 return bio_iovec(rq->bio).bv_len;
972}971}
973 972
974unsigned int blk_rq_err_bytes(const struct request *rq);
975
976static inline unsigned int blk_rq_sectors(const struct request *rq)973static inline unsigned int blk_rq_sectors(const struct request *rq)
977{974{
978 return blk_rq_bytes(rq) >> SECTOR_SHIFT;975 return blk_rq_bytes(rq) >> SECTOR_SHIFT;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t