lkml.org 
[lkml]   [2007]   [May]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 7/13] i386 sg: add support for chaining scatterlists
On Thu, May 10 2007, Benny Halevy wrote:
> Jens Axboe wrote:
> > +#define sg_is_chain(sg) ((unsigned long) (sg)->page & 0x01)
> > +#define sg_chain_ptr(sg) \
> > + ((struct scatterlist *) ((unsigned long) (sg)->page & ~0x01))
> > +
> > +/*
> > + * We overload the meaning of ->page for sg chaining. If the LSB is
> > + * set, the page member contains a pointer to the next sgtable.
> > + */
> > +static inline struct scatterlist *sg_next(struct scatterlist *sg)
> > +{
> > + if (sg_is_chain(sg))
> > + return sg_chain_ptr(sg);
> > +
> > + return sg + 1;
> > +}
>
> Jens, should sg_next ever return the sg containing the chain link?
> If sg points at the entry right before the link entry, don't we
> want to skip it?
>
> E.g.:
>
> static inline struct scatterlist *sg_next(struct scatterlist *sg)
> {
> struct scatterlist *next;
>
> /* just in case, shouldn't really ever be here */
> if (sg_is_chain(sg))
> return sg_chain_ptr(sg);
>
> next = sg + 1;
>
> if (sg_is_chain(next))
> return sg_chain_ptr(next);
>
> return next;
> }

You are right, I got that mixed up, I changed the setup to overloading
->page right before posting it. So:

static inline struct scatterlist *sg_next(struct scatterlist *sg)
{
sg++;

if (unlikely(sg_is_chain(sg)))
sg = sg_chain_ptr(sg);

return sg;
}

--
Jens Axboe

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2007-05-10 13:27    [W:0.123 / U:0.516 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site