btrfs: cleanup duplicate bio allocating functions
extent_bio_alloc() and compressed_bio_alloc() are similar, cleanup similar source code. Signed-off-by: Miao Xie <miaox@cn.fujitsu.com> Signed-off-by: Chris Mason <chris.mason@oracle.com>
This commit is contained in:
parent
0c56fa9662
commit
88f794ede7
@ -91,23 +91,10 @@ static inline int compressed_bio_size(struct btrfs_root *root,
|
|||||||
static struct bio *compressed_bio_alloc(struct block_device *bdev,
|
static struct bio *compressed_bio_alloc(struct block_device *bdev,
|
||||||
u64 first_byte, gfp_t gfp_flags)
|
u64 first_byte, gfp_t gfp_flags)
|
||||||
{
|
{
|
||||||
struct bio *bio;
|
|
||||||
int nr_vecs;
|
int nr_vecs;
|
||||||
|
|
||||||
nr_vecs = bio_get_nr_vecs(bdev);
|
nr_vecs = bio_get_nr_vecs(bdev);
|
||||||
bio = bio_alloc(gfp_flags, nr_vecs);
|
return btrfs_bio_alloc(bdev, first_byte >> 9, nr_vecs, gfp_flags);
|
||||||
|
|
||||||
if (bio == NULL && (current->flags & PF_MEMALLOC)) {
|
|
||||||
while (!bio && (nr_vecs /= 2))
|
|
||||||
bio = bio_alloc(gfp_flags, nr_vecs);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bio) {
|
|
||||||
bio->bi_size = 0;
|
|
||||||
bio->bi_bdev = bdev;
|
|
||||||
bio->bi_sector = first_byte >> 9;
|
|
||||||
}
|
|
||||||
return bio;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int check_compressed_csum(struct inode *inode,
|
static int check_compressed_csum(struct inode *inode,
|
||||||
|
@ -1828,9 +1828,9 @@ static void end_bio_extent_preparewrite(struct bio *bio, int err)
|
|||||||
bio_put(bio);
|
bio_put(bio);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct bio *
|
struct bio *
|
||||||
extent_bio_alloc(struct block_device *bdev, u64 first_sector, int nr_vecs,
|
btrfs_bio_alloc(struct block_device *bdev, u64 first_sector, int nr_vecs,
|
||||||
gfp_t gfp_flags)
|
gfp_t gfp_flags)
|
||||||
{
|
{
|
||||||
struct bio *bio;
|
struct bio *bio;
|
||||||
|
|
||||||
@ -1919,7 +1919,7 @@ static int submit_extent_page(int rw, struct extent_io_tree *tree,
|
|||||||
else
|
else
|
||||||
nr = bio_get_nr_vecs(bdev);
|
nr = bio_get_nr_vecs(bdev);
|
||||||
|
|
||||||
bio = extent_bio_alloc(bdev, sector, nr, GFP_NOFS | __GFP_HIGH);
|
bio = btrfs_bio_alloc(bdev, sector, nr, GFP_NOFS | __GFP_HIGH);
|
||||||
|
|
||||||
bio_add_page(bio, page, page_size, offset);
|
bio_add_page(bio, page, page_size, offset);
|
||||||
bio->bi_end_io = end_io_func;
|
bio->bi_end_io = end_io_func;
|
||||||
|
@ -310,4 +310,7 @@ int extent_clear_unlock_delalloc(struct inode *inode,
|
|||||||
struct extent_io_tree *tree,
|
struct extent_io_tree *tree,
|
||||||
u64 start, u64 end, struct page *locked_page,
|
u64 start, u64 end, struct page *locked_page,
|
||||||
unsigned long op);
|
unsigned long op);
|
||||||
|
struct bio *
|
||||||
|
btrfs_bio_alloc(struct block_device *bdev, u64 first_sector, int nr_vecs,
|
||||||
|
gfp_t gfp_flags);
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user