Commit bf02c082bf7a464518d45b9c178b8aa83f74dd5d

Authored by Andreas Mohr
Committed by Linus Torvalds
1 parent 49a6cbe1cd

[PATCH] fs/bio.c: tweaks

- Calculate a variable in bvec_alloc_bs() only once needed, not earlier
  (bio.o down from 18408 to 18376 Bytes, 32 Bytes saved, probably due to
  data locality improvements).

- Init variable idx to silence a gcc warning which already existed in the
  unmodified original base file (bvec_alloc_bs() handles idx correctly, so
  there's no need for the warning):

	fs/bio.c: In function `bio_alloc_bioset':
	fs/bio.c:169: warning: `idx' may be used uninitialized in this function

Signed-off-by: Andreas Mohr <andi@lisas.de>
Acked-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

Showing 1 changed file with 5 additions and 4 deletions Side-by-side Diff

... ... @@ -79,7 +79,6 @@
79 79 static inline struct bio_vec *bvec_alloc_bs(gfp_t gfp_mask, int nr, unsigned long *idx, struct bio_set *bs)
80 80 {
81 81 struct bio_vec *bvl;
82   - struct biovec_slab *bp;
83 82  
84 83 /*
85 84 * see comment near bvec_array define!
86 85  
87 86  
... ... @@ -98,10 +97,12 @@
98 97 * idx now points to the pool we want to allocate from
99 98 */
100 99  
101   - bp = bvec_slabs + *idx;
102 100 bvl = mempool_alloc(bs->bvec_pools[*idx], gfp_mask);
103   - if (bvl)
  101 + if (bvl) {
  102 + struct biovec_slab *bp = bvec_slabs + *idx;
  103 +
104 104 memset(bvl, 0, bp->nr_vecs * sizeof(struct bio_vec));
  105 + }
105 106  
106 107 return bvl;
107 108 }
... ... @@ -166,7 +167,7 @@
166 167  
167 168 bio_init(bio);
168 169 if (likely(nr_iovecs)) {
169   - unsigned long idx;
  170 + unsigned long idx = 0; /* shut up gcc */
170 171  
171 172 bvl = bvec_alloc_bs(gfp_mask, nr_iovecs, &idx, bs);
172 173 if (unlikely(!bvl)) {