Skip to content

Commit

Permalink
dm crypt: use bio_add_page()
Browse files Browse the repository at this point in the history
Use bio_add_page(), the standard interface for adding a page to a bio,
rather than open-coding the same.

It should be noted that the 'clone' bio that is allocated using
bio_alloc_bioset(), in crypt_alloc_buffer(), does _not_ set the
bio's BIO_CLONED flag.  As such, bio_add_page()'s early return for true
bio clones (those with BIO_CLONED set) isn't applicable.

Reviewed-by: Christoph Hellwig <[email protected]>
Signed-off-by: Ming Lei <[email protected]>
Signed-off-by: Mike Snitzer <[email protected]>
  • Loading branch information
ming1 authored and snitm committed Nov 21, 2016
1 parent cacc7b0 commit 0dae7fe
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions drivers/md/dm-crypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -994,7 +994,6 @@ static struct bio *crypt_alloc_buffer(struct dm_crypt_io *io, unsigned size)
gfp_t gfp_mask = GFP_NOWAIT | __GFP_HIGHMEM;
unsigned i, len, remaining_size;
struct page *page;
struct bio_vec *bvec;

retry:
if (unlikely(gfp_mask & __GFP_DIRECT_RECLAIM))
Expand All @@ -1019,12 +1018,7 @@ static struct bio *crypt_alloc_buffer(struct dm_crypt_io *io, unsigned size)

len = (remaining_size > PAGE_SIZE) ? PAGE_SIZE : remaining_size;

bvec = &clone->bi_io_vec[clone->bi_vcnt++];
bvec->bv_page = page;
bvec->bv_len = len;
bvec->bv_offset = 0;

clone->bi_iter.bi_size += len;
bio_add_page(clone, page, len, 0);

remaining_size -= len;
}
Expand Down

0 comments on commit 0dae7fe

Please sign in to comment.