libata sg chaining support fix
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
This commit is contained in:
parent
f1346372f9
commit
0874ee76bc
|
@ -4952,16 +4952,18 @@ static void __atapi_pio_bytes(struct ata_queued_cmd *qc, unsigned int bytes)
|
||||||
{
|
{
|
||||||
int do_write = (qc->tf.flags & ATA_TFLAG_WRITE);
|
int do_write = (qc->tf.flags & ATA_TFLAG_WRITE);
|
||||||
struct scatterlist *sg = qc->__sg;
|
struct scatterlist *sg = qc->__sg;
|
||||||
|
struct scatterlist *lsg = sg_last(qc->__sg, qc->n_elem);
|
||||||
struct ata_port *ap = qc->ap;
|
struct ata_port *ap = qc->ap;
|
||||||
struct page *page;
|
struct page *page;
|
||||||
unsigned char *buf;
|
unsigned char *buf;
|
||||||
unsigned int offset, count;
|
unsigned int offset, count;
|
||||||
|
int no_more_sg = 0;
|
||||||
|
|
||||||
if (qc->curbytes + bytes >= qc->nbytes)
|
if (qc->curbytes + bytes >= qc->nbytes)
|
||||||
ap->hsm_task_state = HSM_ST_LAST;
|
ap->hsm_task_state = HSM_ST_LAST;
|
||||||
|
|
||||||
next_sg:
|
next_sg:
|
||||||
if (unlikely(qc->cursg == sg_last(qc->__sg, qc->n_elem))) {
|
if (unlikely(no_more_sg)) {
|
||||||
/*
|
/*
|
||||||
* The end of qc->sg is reached and the device expects
|
* The end of qc->sg is reached and the device expects
|
||||||
* more data to transfer. In order not to overrun qc->sg
|
* more data to transfer. In order not to overrun qc->sg
|
||||||
|
@ -5023,6 +5025,9 @@ next_sg:
|
||||||
qc->cursg_ofs += count;
|
qc->cursg_ofs += count;
|
||||||
|
|
||||||
if (qc->cursg_ofs == sg->length) {
|
if (qc->cursg_ofs == sg->length) {
|
||||||
|
if (qc->cursg == lsg)
|
||||||
|
no_more_sg = 1;
|
||||||
|
|
||||||
qc->cursg = sg_next(qc->cursg);
|
qc->cursg = sg_next(qc->cursg);
|
||||||
qc->cursg_ofs = 0;
|
qc->cursg_ofs = 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue