lkml.org 
[lkml]   [2007]   [Aug]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 019 of 35] Convert bio_for_each_segment to fill in a fresh bio_vec
Hi,

On Tue, Jul 31, 2007 at 12:17:27PM +1000, NeilBrown wrote:
> i.e. instread of providing a pointer to each bio_vec, it provides
> a copy of each bio_vec.
>
> This allows a future patch to cause bio_for_each_segment to
> provide bio_vecs that are not in the bi_io_vec list, thus allowing
> for offsets and length restrictions.
>
> We consequently remove the only call for bio_kmap_atomic,
> and so remove that function as well.
> Also remove bio_kmap_irq. No-one uses it, and bvec_kmap_irq
> is a much more usable interface.

I think this patch can be split into two but it's no big deal.

> +struct bio_iterator {
> + int i;
> +};
> #define bio_for_each_segment(bvl, bio, i) \
> - for (bvl = bio_iovec_idx((bio), 0), i = 0; \
> - i < (bio)->bi_vcnt; \
> - bvl++, i++)
> + for (i.i = 0, bvl = *bio_iovec_idx((bio), i.i); \
> + i.i < (bio)->bi_vcnt; \
> + i.i++, bvl = *bio_iovec_idx((bio), i.i))

How about something like...

struct bio_iterator {
int i;
struct bio_vec tmp_bvec;
/* might put bio here too? */
};
#define bio_for_each_segment(bvl, bio, i) \
for (bvl = bio_iter_init(&i, bio); i.i < (bio)->bi_vcnt; \
bvl = bio_iter_next(&i, bio))

[static inline] struct bio_vec *bio_iter_init(struct bio_iterator *i,
struct bio *bio)
{
i->i = 0;
if (no further restrictions)
return bio_iovec_idx(bio, 0);
else {
i->tmp_bvec = *bio_iovec_idx(bio, 0);
apply restriction;
return &i->tmp_bvec;
}
}
[static inline] struct bio_vec *bio_iter_next(struct bio_iterator *i,
struct bio *bio)
{
i->i++;
if (no further restriction)
return bio_iovec_idx(bio, i->i);
else {
i->tmp_bvec = *bio_iovec_idx(bio, i->i);
apply restriction;
return &i->tmp_bvec;
}
}
--
tejun
-
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-08-01 18:25    [from the cache]
©2003-2014 Jasper Spaans. Advertise on this site