From: Zach Brown Date: Fri, 14 Jun 2013 20:54:19 +0000 (-0500) Subject: bio: add bvec_length(), like iov_length() X-Git-Tag: next-20130919~60^2~17 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=10b345c214c5d151c55dc0665456de7c3ace5fb5;p=karo-tx-linux.git bio: add bvec_length(), like iov_length() Signed-off-by: Zach Brown Signed-off-by: Dave Kleikamp Tested-by: Sedat Dilek --- diff --git a/include/linux/bio.h b/include/linux/bio.h index ec48bac5b039..4fd525342596 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -307,6 +307,14 @@ extern struct bio_vec *bvec_alloc(gfp_t, int, unsigned long *, mempool_t *); extern void bvec_free(mempool_t *, struct bio_vec *, unsigned int); extern unsigned int bvec_nr_vecs(unsigned short idx); +static inline ssize_t bvec_length(const struct bio_vec *bvec, unsigned long nr) +{ + ssize_t bytes = 0; + while (nr--) + bytes += (bvec++)->bv_len; + return bytes; +} + #ifdef CONFIG_BLK_CGROUP int bio_associate_current(struct bio *bio); void bio_disassociate_task(struct bio *bio);