Skip to content

Commit

Permalink
block: fix bugs in bio-integrity mempool usage
Browse files Browse the repository at this point in the history
Fix two bugs in the bio integrity code:

 use_bip_pool() always returns 0 because it checks against the wrong limit,
 causing the mempool to be used only when regular allocation fails.

 When the mempool is used as a fallback we don't free the data properly.

Signed-Off-By: Chuck Ebbert <[email protected]>
Acked-by: Martin K. Petersen <[email protected]>

Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
Chuck Ebbert authored and Jens Axboe committed Jan 30, 2010
1 parent 1d61658 commit 9e9432c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion fs/bio-integrity.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ static inline unsigned int vecs_to_idx(unsigned int nr)

static inline int use_bip_pool(unsigned int idx)
{
if (idx == BIOVEC_NR_POOLS)
if (idx == BIOVEC_MAX_IDX)
return 1;

return 0;
Expand Down Expand Up @@ -95,6 +95,7 @@ struct bio_integrity_payload *bio_integrity_alloc_bioset(struct bio *bio,

/* Use mempool if lower order alloc failed or max vecs were requested */
if (bip == NULL) {
idx = BIOVEC_MAX_IDX; /* so we free the payload properly later */
bip = mempool_alloc(bs->bio_integrity_pool, gfp_mask);

if (unlikely(bip == NULL)) {
Expand Down

0 comments on commit 9e9432c

Please sign in to comment.