Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 88f794ed authored by Miao Xie's avatar Miao Xie Committed by Chris Mason
Browse files

btrfs: cleanup duplicate bio allocating functions



extent_bio_alloc() and compressed_bio_alloc() are similar, cleanup
similar source code.

Signed-off-by: default avatarMiao Xie <miaox@cn.fujitsu.com>
Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
parent 0c56fa96
Loading
Loading
Loading
Loading
+1 −14
Original line number Diff line number Diff line
@@ -91,23 +91,10 @@ static inline int compressed_bio_size(struct btrfs_root *root,
static struct bio *compressed_bio_alloc(struct block_device *bdev,
					u64 first_byte, gfp_t gfp_flags)
{
	struct bio *bio;
	int nr_vecs;

	nr_vecs = bio_get_nr_vecs(bdev);
	bio = bio_alloc(gfp_flags, nr_vecs);

	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;
	return btrfs_bio_alloc(bdev, first_byte >> 9, nr_vecs, gfp_flags);
}

static int check_compressed_csum(struct inode *inode,
+4 −4
Original line number Diff line number Diff line
@@ -1828,8 +1828,8 @@ static void end_bio_extent_preparewrite(struct bio *bio, int err)
	bio_put(bio);
}

static struct bio *
extent_bio_alloc(struct block_device *bdev, u64 first_sector, int nr_vecs,
struct bio *
btrfs_bio_alloc(struct block_device *bdev, u64 first_sector, int nr_vecs,
		gfp_t gfp_flags)
{
	struct bio *bio;
@@ -1919,7 +1919,7 @@ static int submit_extent_page(int rw, struct extent_io_tree *tree,
	else
		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->bi_end_io = end_io_func;
+3 −0
Original line number Diff line number Diff line
@@ -310,4 +310,7 @@ int extent_clear_unlock_delalloc(struct inode *inode,
				struct extent_io_tree *tree,
				u64 start, u64 end, struct page *locked_page,
				unsigned long op);
struct bio *
btrfs_bio_alloc(struct block_device *bdev, u64 first_sector, int nr_vecs,
		gfp_t gfp_flags);
#endif