Skip to content

Commit

Permalink
btrfs: make sure we stay inside the bvec during __btrfs_lookup_bio_sums
Browse files Browse the repository at this point in the history
Commit c40a3d3 (Btrfs: Compute and look up csums based on
sectorsized blocks) changes around how we walk the bios while looking up
crcs.  There's an inner loop that is jumping to the next bvec based on
sectors and before it derefs the next bvec, it needs to make sure we're
still in the bio.

In this case, the outer loop would have decided to stop moving forward
too, and the bvec deref is never actually used for anything.  But
CONFIG_DEBUG_PAGEALLOC catches it because we're outside our bio.

Signed-off-by: Chris Mason <clm@fb.com>
Reviewed-by: David Sterba <dsterba@suse.com>
  • Loading branch information
Chris Mason committed Mar 21, 2016
1 parent bb7ab3b commit 389f239
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions fs/btrfs/file-item.c
Original file line number Diff line number Diff line change
Expand Up @@ -292,12 +292,22 @@ static int __btrfs_lookup_bio_sums(struct btrfs_root *root,
page_bytes_left -= root->sectorsize;
if (!page_bytes_left) {
bio_index++;
/*
* make sure we're still inside the
* bio before we update page_bytes_left
*/
if (bio_index >= bio->bi_vcnt) {
WARN_ON_ONCE(count);
goto done;
}
bvec++;
page_bytes_left = bvec->bv_len;
}

}
}

done:
btrfs_free_path(path);
return 0;
}
Expand Down

0 comments on commit 389f239

Please sign in to comment.