From: Ming Lei <tom.leiming@gmail.com>
To: Jens Axboe <axboe@kernel.dk>, linux-kernel@vger.kernel.org
Cc: Christoph Hellwig <hch@infradead.org>,
Andrew Morton <akpm@linux-foundation.org>,
Alexander Viro <viro@zeniv.linux.org.uk>,
Ming Lei <tom.leiming@gmail.com>
Subject: [PATCH 2/2] iov_iter: use bvec iterator to implement iterate_bvec()
Date: Sat, 10 Oct 2015 23:20:26 +0800 [thread overview]
Message-ID: <1444490426-16522-3-git-send-email-tom.leiming@gmail.com> (raw)
In-Reply-To: <1444490426-16522-1-git-send-email-tom.leiming@gmail.com>
bvec has provided one iterator already, so not necessary
to invent a new wheel for this job.
Signed-off-by: Ming Lei <tom.leiming@gmail.com>
---
lib/iov_iter.c | 27 +++++++++------------------
1 file changed, 9 insertions(+), 18 deletions(-)
diff --git a/lib/iov_iter.c b/lib/iov_iter.c
index 75232ad..e5cfc5c 100644
--- a/lib/iov_iter.c
+++ b/lib/iov_iter.c
@@ -3,6 +3,7 @@
#include <linux/pagemap.h>
#include <linux/slab.h>
#include <linux/vmalloc.h>
+#include <linux/bio.h>
#include <net/checksum.h>
#define iterate_iovec(i, n, __v, __p, skip, STEP) { \
@@ -57,28 +58,18 @@
}
#define iterate_bvec(i, n, __v, __p, skip, STEP) { \
- size_t wanted = n; \
+ struct bvec_iter __bi, __start; \
+ __start.bi_size = n; \
+ __start.bi_bvec_done = skip; \
+ __start.bi_idx = 0; \
__p = i->bvec; \
- __v.bv_len = min_t(size_t, n, __p->bv_len - skip); \
- if (likely(__v.bv_len)) { \
- __v.bv_page = __p->bv_page; \
- __v.bv_offset = __p->bv_offset + skip; \
+ for_each_bvec(__v, __p, __bi, __start) { \
(void)(STEP); \
- skip += __v.bv_len; \
- n -= __v.bv_len; \
} \
- while (unlikely(n)) { \
- __p++; \
- __v.bv_len = min_t(size_t, n, __p->bv_len); \
- if (unlikely(!__v.bv_len)) \
- continue; \
- __v.bv_page = __p->bv_page; \
- __v.bv_offset = __p->bv_offset; \
- (void)(STEP); \
+ if (!__bi.bi_idx) \
+ skip += __v.bv_len; \
+ else \
skip = __v.bv_len; \
- n -= __v.bv_len; \
- } \
- n = wanted; \
}
#define iterate_all_kinds(i, n, v, I, B, K) { \
--
1.9.1
next prev parent reply other threads:[~2015-10-10 15:20 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-10 15:20 [PATCH 0/2] " Ming Lei
2015-10-10 15:20 ` [PATCH 1/2] block: mark 1st parameter of bvec_iter_advance as const Ming Lei
2015-10-10 15:20 ` Ming Lei [this message]
2015-10-10 15:33 ` [PATCH 2/2] iov_iter: use bvec iterator to implement iterate_bvec() kbuild test robot
2015-10-10 15:48 ` Ming Lei
2015-10-10 15:34 ` kbuild test robot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1444490426-16522-3-git-send-email-tom.leiming@gmail.com \
--to=tom.leiming@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=axboe@kernel.dk \
--cc=hch@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®