[lkml]   [2007]   [Oct]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
SubjectRe: [bug] ata subsystem related crash with latest -git
On Wed, Oct 17 2007, Jens Axboe wrote:
> On Wed, Oct 17 2007, Linus Torvalds wrote:
> >
> >
> > On Wed, 17 Oct 2007, Ingo Molnar wrote:
> > >
> > > nope, this did not help. First bootup went fine, second bootup crashed
> > > again (see below), without hitting the BUG_ON().
> >
> > I think you'll always hit it if you have a scatter-gather list that is
> > exactly filled up.
> >
> > Why? Because those things do "sg_next()" on the last entry, and as
> > mentioned, that ends up actually accessing one past the end - even if the
> > end result is not actually ever *used* (because we just effectively
> > incremented it to past the last entry when the code was done with the SG
> > list).

Well, hang on - where does it end up doing sg_next() on the LAST sg
entry? I'd argue that this is a bug, like it was in ll_rw_blk.c. I still
agree that I should make the interface more robust, I just don't see
where libata ends up doing the sg_next() on the last entry.

I'm assuming that Ingo is using the previous patches, so that
blk_rq_map_sg() is using this construct:

if (!sg)
sg = sglist;
sg = sg_next(sg);

and the memset() in scsi_alloc_sgtable(), which I'm pretty sure he is.
I'm assuming we're not hitting pio paths, so there are no manual
sg_next() calls. Ingo, if you care, can you test this one as well?

No rush, as mentioned I'll be back tomorrow morning...

diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index bbaa545..0246b61 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -4664,7 +4664,7 @@ static int ata_sg_setup(struct ata_queued_cmd *qc)
struct ata_port *ap = qc->ap;
struct scatterlist *sg = qc->__sg;
- struct scatterlist *lsg = sg_last(qc->__sg, qc->n_elem);
+ struct scatterlist *lsg = &qc->__sg[qc->n_elem - 1];
int n_elem, pre_n_elem, dir, trim_sg = 0;

VPRINTK("ENTER, ata%u\n", ap->print_id);
Jens Axboe

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2007-10-17 21:53    [W:0.188 / U:9.408 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site