diff options
author | Kent Overstreet <koverstreet@google.com> | 2013-02-06 15:23:11 -0500 |
---|---|---|
committer | Kent Overstreet <koverstreet@google.com> | 2013-03-23 17:26:28 -0400 |
commit | d74c6d514fe314b8bdab58b487b25992291577ec (patch) | |
tree | 2e04cd492235dc7982bae1ba7ef83f276800c319 /include/linux/bio.h | |
parent | 6bc454d150047fcfbf53346412e64cdf3bf61a79 (diff) |
block: Add bio_for_each_segment_all()
__bio_for_each_segment() iterates bvecs from the specified index
instead of bio->bv_idx. Currently, the only usage is to walk all the
bvecs after the bio has been advanced by specifying 0 index.
For immutable bvecs, we need to split these apart;
bio_for_each_segment() is going to have a different implementation.
This will also help document the intent of code that's using it -
bio_for_each_segment_all() is only legal to use for code that owns the
bio.
Signed-off-by: Kent Overstreet <koverstreet@google.com>
CC: Jens Axboe <axboe@kernel.dk>
CC: Neil Brown <neilb@suse.de>
CC: Boaz Harrosh <bharrosh@panasas.com>
Diffstat (limited to 'include/linux/bio.h')
-rw-r--r-- | include/linux/bio.h | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/include/linux/bio.h b/include/linux/bio.h index 90d36c65cb70..be2efa09f9bf 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h | |||
@@ -137,16 +137,27 @@ static inline int bio_has_allocated_vec(struct bio *bio) | |||
137 | #define bio_io_error(bio) bio_endio((bio), -EIO) | 137 | #define bio_io_error(bio) bio_endio((bio), -EIO) |
138 | 138 | ||
139 | /* | 139 | /* |
140 | * drivers should not use the __ version unless they _really_ want to | 140 | * drivers should not use the __ version unless they _really_ know what |
141 | * run through the entire bio and not just pending pieces | 141 | * they're doing |
142 | */ | 142 | */ |
143 | #define __bio_for_each_segment(bvl, bio, i, start_idx) \ | 143 | #define __bio_for_each_segment(bvl, bio, i, start_idx) \ |
144 | for (bvl = bio_iovec_idx((bio), (start_idx)), i = (start_idx); \ | 144 | for (bvl = bio_iovec_idx((bio), (start_idx)), i = (start_idx); \ |
145 | i < (bio)->bi_vcnt; \ | 145 | i < (bio)->bi_vcnt; \ |
146 | bvl++, i++) | 146 | bvl++, i++) |
147 | 147 | ||
148 | /* | ||
149 | * drivers should _never_ use the all version - the bio may have been split | ||
150 | * before it got to the driver and the driver won't own all of it | ||
151 | */ | ||
152 | #define bio_for_each_segment_all(bvl, bio, i) \ | ||
153 | for (i = 0; \ | ||
154 | bvl = bio_iovec_idx((bio), (i)), i < (bio)->bi_vcnt; \ | ||
155 | i++) | ||
156 | |||
148 | #define bio_for_each_segment(bvl, bio, i) \ | 157 | #define bio_for_each_segment(bvl, bio, i) \ |
149 | __bio_for_each_segment(bvl, bio, i, (bio)->bi_idx) | 158 | for (i = (bio)->bi_idx; \ |
159 | bvl = bio_iovec_idx((bio), (i)), i < (bio)->bi_vcnt; \ | ||
160 | i++) | ||
150 | 161 | ||
151 | /* | 162 | /* |
152 | * get a reference to a bio, so it won't disappear. the intended use is | 163 | * get a reference to a bio, so it won't disappear. the intended use is |