Skip to contentSkip to conversation

bio: make use of bvec_nr_vecs

PATCH Applied Denis ChengRq 2 participants 3 messages Jul 25, 2008 – Aug 4, 2008 VFS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bio: make use of bvec_nr_vecs

Since introduced in 7ba1ba12eee, it should be made use of.

---
Additionally, I think it maybe better if inlined in <linux/bio.h>

 fs/bio.c |    9 +++------
 1 files changed, 3 insertions(+), 6 deletions(-)
fs/bio.c +3 -6
index 88322b0..7ed91d3 100644
@@ -77,11 +77,8 @@ struct bio_vec *bvec_alloc_bs(gfp_t gfp_mask, int nr, unsigned long *idx, struct
 	 */
 
 	bvl = mempool_alloc(bs->bvec_pools[*idx], gfp_mask);
-	if (bvl) {
-		struct biovec_slab *bp = bvec_slabs + *idx;
-
-		memset(bvl, 0, bp->nr_vecs * sizeof(struct bio_vec));
-	}
+	if (bvl)
+		memset(bvl, 0, bvec_nr_vecs(*idx) * sizeof(struct bio_vec));
 
 	return bvl;
 }
@@ -149,7 +146,7 @@ struct bio *bio_alloc_bioset(gfp_t gfp_mask, int nr_iovecs, struct bio_set *bs)
 				goto out;
 			}
 			bio->bi_flags |= idx << BIO_POOL_OFFSET;
-			bio->bi_max_vecs = bvec_slabs[idx].nr_vecs;
+			bio->bi_max_vecs = bvec_nr_vecs(idx);
 		}
 		bio->bi_io_vec = bvl;
 	}
Signature · 1 line
1.5.6.3
author
#1 lore raw

fs/bio.c struct bio_vec *bvec_alloc_bs(gfp_t gfp_mask, int nr, unsigned long *idx, struct · line 81

Quoted 8 lines · Denis ChengRq
       bvl = mempool_alloc(bs->bvec_pools[*idx], gfp_mask);
fs/bio.c +2 -5
-       if (bvl) {
-               struct biovec_slab *bp = bvec_slabs + *idx;
-
-               memset(bvl, 0, bp->nr_vecs * sizeof(struct bio_vec));
-       }
+       if (bvl)
+               memset(bvl, 0, bvec_nr_vecs(*idx) * sizeof(struct bio_vec));

and if we have a mempool_zalloc, this can be more simplified,

there was no mempool_zalloc yet, should we create it inlined with __GFP_ZERO, for this and further use?