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
11761176 }
11771177 EXPORT_SYMBOL_GPL(blk_insert_cloned_request);
11781178
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−
12201179 static void update_io_ticks(struct block_device *part, unsigned long now,
12211180 bool end)
12221181 {
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
617617 }
618618 }
619619
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+
620660 /* Helper for scsi_io_completion() when "reprep" action required. */
621661 static void scsi_io_completion_reprep(struct scsi_cmnd *cmd,
622662 struct request_queue *q)
@@ -794,7 +834,7 @@ static void scsi_io_completion_action(struct scsi_cmnd *cmd, int result) · 171 unmodified lines
794834 scsi_print_command(cmd);
795835 }
796836 }
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)))
798838 return;
799839 fallthrough;
800840 case ACTION_REPREP:
include/linux/blk-mq.h+0−3
@@ -947,7 +947,6 @@ struct req_iterator { · 946 unmodified lines
947947 * blk_rq_pos() : the current sector
948948 * blk_rq_bytes() : bytes left in the entire request
949949 * blk_rq_cur_bytes() : bytes left in the current segment
950− * blk_rq_err_bytes() : bytes left till the next error boundary
951950 * blk_rq_sectors() : sectors left in the entire request
952951 * blk_rq_cur_sectors() : sectors left in the current segment
953952 * 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
971970 return bio_iovec(rq->bio).bv_len;
972971 }
973972
974−unsigned int blk_rq_err_bytes(const struct request *rq);
975−
976973 static inline unsigned int blk_rq_sectors(const struct request *rq)
977974 {
978975 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