On Thu, Oct 11 2007, Tejun Heo wrote:This is the old ata_sg_is_last: static inline int ata_sg_is_last(struct scatterlist *sg, struct ata_queued_cmd *qc) { if (sg == &qc->pad_sgent) return 1; if (qc->pad_len) return 0; if (((sg - qc->__sg) + 1) == qc->n_elem) return 1; return 0; } and the new one: static inline int ata_sg_is_last(struct scatterlist *sg, struct ata_queued_cmd *qc) { if (sg == &qc->pad_sgent) return 1; if (qc->pad_len) return 0; if (qc->n_iter == qc->n_elem) return 1; return 0; } ->n_iter is how ata_qc_next_sg() walks over the sglist, I don't understand your reference to why depending on that during iteration would be bad? So we could add a test for sg_last() there, but that would turn sg table iteration into an O(N^2) operation for those drivers that use ata_sg_is_last() with chained sg tables. I'd much rather just get rid of ata_sg_is_last(), it's only used to mark end-of-table entries for hardware. That logic can be performed cheaper. Torsten, your analysis does look correct. Does it work with this simple patch? diff --git a/include/linux/libata.h b/include/linux/libata.h index 2784163..0152bf4 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h @@ -947,7 +947,7 @@ ata_sg_is_last(struct scatterlist *sg, struct ata_queued_cmd *qc) return 1; if (qc->pad_len) return 0; - if (qc->n_iter == qc->n_elem) + if ((qc->n_iter + 1) == qc->n_elem) return 1; return 0; } -- Jens Axboe -
| Greg Kroah-Hartman | [PATCH 001/196] Chinese: Add the known_regression URI to the HOWTO |
| Tarkan Erimer | Re: Dual-Licensing Linux Kernel with GPL V2 and GPL V3 |
| Amit K. Arora | [RFC] Heads up on sys_fallocate() |
| Bart Van Assche | Integration of SCST in the mainstream Linux kernel |
git: | |
| David Miller | [GIT]: Networking |
| Gerrit Renker | [PATCH 27/37] dccp: Integration of dynamic feature activation - part 2 (server side) |
| David Miller | Re: [PATCH] pkt_sched: Destroy gen estimators under rtnl_lock(). |
| Frans Pop | svc: failed to register lockdv1 RPC service (errno 97). |
