Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

libata: convert eh to command iterators

Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Tejun Heo <tj@kernel.org>

authored by

Jens Axboe and committed by
Tejun Heo
258c4e5c 6362f0a2

+16 -25
+16 -25
drivers/ata/libata-eh.c
··· 614 614 list_for_each_entry_safe(scmd, tmp, eh_work_q, eh_entry) { 615 615 struct ata_queued_cmd *qc; 616 616 617 - for (i = 0; i < ATA_MAX_QUEUE; i++) { 618 - qc = __ata_qc_from_tag(ap, i); 617 + ata_qc_for_each_raw(ap, qc, i) { 619 618 if (qc->flags & ATA_QCFLAG_ACTIVE && 620 619 qc->scsicmd == scmd) 621 620 break; ··· 817 818 818 819 static int ata_eh_nr_in_flight(struct ata_port *ap) 819 820 { 821 + struct ata_queued_cmd *qc; 820 822 unsigned int tag; 821 823 int nr = 0; 822 824 823 825 /* count only non-internal commands */ 824 - for (tag = 0; tag < ATA_MAX_QUEUE; tag++) { 825 - if (ata_tag_internal(tag)) 826 - continue; 827 - if (ata_qc_from_tag(ap, tag)) 826 + ata_qc_for_each(ap, qc, tag) { 827 + if (qc) 828 828 nr++; 829 829 } 830 830 ··· 845 847 goto out_unlock; 846 848 847 849 if (cnt == ap->fastdrain_cnt) { 850 + struct ata_queued_cmd *qc; 848 851 unsigned int tag; 849 852 850 853 /* No progress during the last interval, tag all 851 854 * in-flight qcs as timed out and freeze the port. 852 855 */ 853 - for (tag = 0; tag < ATA_MAX_QUEUE; tag++) { 854 - struct ata_queued_cmd *qc = ata_qc_from_tag(ap, tag); 856 + ata_qc_for_each(ap, qc, tag) { 855 857 if (qc) 856 858 qc->err_mask |= AC_ERR_TIMEOUT; 857 859 } ··· 997 999 998 1000 static int ata_do_link_abort(struct ata_port *ap, struct ata_link *link) 999 1001 { 1002 + struct ata_queued_cmd *qc; 1000 1003 int tag, nr_aborted = 0; 1001 1004 1002 1005 WARN_ON(!ap->ops->error_handler); ··· 1006 1007 ata_eh_set_pending(ap, 0); 1007 1008 1008 1009 /* include internal tag in iteration */ 1009 - for (tag = 0; tag <= ATA_MAX_QUEUE; tag++) { 1010 - struct ata_queued_cmd *qc = ata_qc_from_tag(ap, tag); 1011 - 1010 + ata_qc_for_each_with_internal(ap, qc, tag) { 1012 1011 if (qc && (!link || qc->dev->link == link)) { 1013 1012 qc->flags |= ATA_QCFLAG_FAILED; 1014 1013 ata_qc_complete(qc); ··· 1709 1712 return; 1710 1713 1711 1714 /* has LLDD analyzed already? */ 1712 - for (tag = 0; tag < ATA_MAX_QUEUE; tag++) { 1713 - qc = __ata_qc_from_tag(ap, tag); 1714 - 1715 + ata_qc_for_each_raw(ap, qc, tag) { 1715 1716 if (!(qc->flags & ATA_QCFLAG_FAILED)) 1716 1717 continue; 1717 1718 ··· 2131 2136 { 2132 2137 struct ata_port *ap = link->ap; 2133 2138 struct ata_eh_context *ehc = &link->eh_context; 2139 + struct ata_queued_cmd *qc; 2134 2140 struct ata_device *dev; 2135 2141 unsigned int all_err_mask = 0, eflags = 0; 2136 2142 int tag, nr_failed = 0, nr_quiet = 0; ··· 2164 2168 2165 2169 all_err_mask |= ehc->i.err_mask; 2166 2170 2167 - for (tag = 0; tag < ATA_MAX_QUEUE; tag++) { 2168 - struct ata_queued_cmd *qc = __ata_qc_from_tag(ap, tag); 2169 - 2171 + ata_qc_for_each_raw(ap, qc, tag) { 2170 2172 if (!(qc->flags & ATA_QCFLAG_FAILED) || 2171 2173 ata_dev_phys_link(qc->dev) != link) 2172 2174 continue; ··· 2430 2436 { 2431 2437 struct ata_port *ap = link->ap; 2432 2438 struct ata_eh_context *ehc = &link->eh_context; 2439 + struct ata_queued_cmd *qc; 2433 2440 const char *frozen, *desc; 2434 2441 char tries_buf[6] = ""; 2435 2442 int tag, nr_failed = 0; ··· 2442 2447 if (ehc->i.desc[0] != '\0') 2443 2448 desc = ehc->i.desc; 2444 2449 2445 - for (tag = 0; tag < ATA_MAX_QUEUE; tag++) { 2446 - struct ata_queued_cmd *qc = __ata_qc_from_tag(ap, tag); 2447 - 2450 + ata_qc_for_each_raw(ap, qc, tag) { 2448 2451 if (!(qc->flags & ATA_QCFLAG_FAILED) || 2449 2452 ata_dev_phys_link(qc->dev) != link || 2450 2453 ((qc->flags & ATA_QCFLAG_QUIET) && ··· 2504 2511 ehc->i.serror & SERR_DEV_XCHG ? "DevExch " : ""); 2505 2512 #endif 2506 2513 2507 - for (tag = 0; tag < ATA_MAX_QUEUE; tag++) { 2508 - struct ata_queued_cmd *qc = __ata_qc_from_tag(ap, tag); 2514 + ata_qc_for_each_raw(ap, qc, tag) { 2509 2515 struct ata_taskfile *cmd = &qc->tf, *res = &qc->result_tf; 2510 2516 char data_buf[20] = ""; 2511 2517 char cdb_buf[70] = ""; ··· 3984 3992 */ 3985 3993 void ata_eh_finish(struct ata_port *ap) 3986 3994 { 3995 + struct ata_queued_cmd *qc; 3987 3996 int tag; 3988 3997 3989 3998 /* retry or finish qcs */ 3990 - for (tag = 0; tag < ATA_MAX_QUEUE; tag++) { 3991 - struct ata_queued_cmd *qc = __ata_qc_from_tag(ap, tag); 3992 - 3999 + ata_qc_for_each_raw(ap, qc, tag) { 3993 4000 if (!(qc->flags & ATA_QCFLAG_FAILED)) 3994 4001 continue; 3995 4002