Message ID | 20180609123014.8861-12-ming.lei@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Given that we have a single, dubious user of bio_pages_all I'd rather see it as an opencoded bio_for_each_ loop in the caller.
On Wed, Jun 13, 2018 at 07:44:12AM -0700, Christoph Hellwig wrote: > Given that we have a single, dubious user of bio_pages_all I'd rather > see it as an opencoded bio_for_each_ loop in the caller. Yeah, that is fine since there is only one user in btrfs. Thanks, Ming
On Thu, Jun 14, 2018 at 09:23:54AM +0800, Ming Lei wrote: > On Wed, Jun 13, 2018 at 07:44:12AM -0700, Christoph Hellwig wrote: > > Given that we have a single, dubious user of bio_pages_all I'd rather > > see it as an opencoded bio_for_each_ loop in the caller. > > Yeah, that is fine since there is only one user in btrfs. And I suspect it really is checking for the wrong thing. I don't fully understand that code, but as far as I can tell it really needs to know if there is more than a file system block of data in the bio, and btrfs conflats pages with blocks. But I'd need btrfs folks to confirm this.
diff --git a/include/linux/bio.h b/include/linux/bio.h index e9f74c73bbe6..c17b8f80d650 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -339,8 +339,14 @@ static inline void bio_get_last_bvec(struct bio *bio, struct bio_vec *bv) static inline unsigned bio_pages_all(struct bio *bio) { + unsigned i; + struct bio_vec *bv; + WARN_ON_ONCE(bio_flagged(bio, BIO_CLONED)); - return bio->bi_vcnt; + + bio_for_each_segment_all(bv, bio, i) + ; + return i; } static inline struct bio_vec *bio_first_bvec_all(struct bio *bio)
As multipage bvec will be enabled soon, bio->bi_vcnt isn't same with page count in the bio any more, so use bio_for_each_segment_all() to compute the number because we will keep bio_for_each_segment_all() to iterate each page. Signed-off-by: Ming Lei <ming.lei@redhat.com> --- include/linux/bio.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)