Commit 8896a08d authored by Qu Wenruo's avatar Qu Wenruo Committed by David Sterba
Browse files

btrfs: replace fs_info and private_data with inode in btrfs_wq_submit_bio



All callers of btrfs_wq_submit_bio() pass struct inode as @private_data,
so there is no need for it to be (void *), replace it with "struct inode
*inode".

While we can extract fs_info from struct inode, also remove the @fs_info
parameter.

Since we're here, also replace all the (void *private_data) into (struct
inode *inode).

Reviewed-by: default avatarGoldwyn Rodrigues <rgoldwyn@suse.com>
Signed-off-by: default avatarQu Wenruo <wqu@suse.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 3f6bb4ae
Loading
Loading
Loading
Loading
+11 −11
Original line number Original line Diff line number Diff line
@@ -109,7 +109,7 @@ static void btrfs_free_csum_hash(struct btrfs_fs_info *fs_info)
 * just before they are sent down the IO stack.
 * just before they are sent down the IO stack.
 */
 */
struct async_submit_bio {
struct async_submit_bio {
	void *private_data;
	struct inode *inode;
	struct bio *bio;
	struct bio *bio;
	extent_submit_bio_start_t *submit_bio_start;
	extent_submit_bio_start_t *submit_bio_start;
	int mirror_num;
	int mirror_num;
@@ -696,8 +696,7 @@ static void run_one_async_start(struct btrfs_work *work)
	blk_status_t ret;
	blk_status_t ret;


	async = container_of(work, struct  async_submit_bio, work);
	async = container_of(work, struct  async_submit_bio, work);
	ret = async->submit_bio_start(async->private_data, async->bio,
	ret = async->submit_bio_start(async->inode, async->bio, async->bio_offset);
				      async->bio_offset);
	if (ret)
	if (ret)
		async->status = ret;
		async->status = ret;
}
}
@@ -717,7 +716,7 @@ static void run_one_async_done(struct btrfs_work *work)
	blk_status_t ret;
	blk_status_t ret;


	async = container_of(work, struct  async_submit_bio, work);
	async = container_of(work, struct  async_submit_bio, work);
	inode = async->private_data;
	inode = async->inode;


	/* If an error occurred we just want to clean up the bio and move on */
	/* If an error occurred we just want to clean up the bio and move on */
	if (async->status) {
	if (async->status) {
@@ -747,18 +746,19 @@ static void run_one_async_free(struct btrfs_work *work)
	kfree(async);
	kfree(async);
}
}


blk_status_t btrfs_wq_submit_bio(struct btrfs_fs_info *fs_info, struct bio *bio,
blk_status_t btrfs_wq_submit_bio(struct inode *inode, struct bio *bio,
				 int mirror_num, unsigned long bio_flags,
				 int mirror_num, unsigned long bio_flags,
				 u64 bio_offset, void *private_data,
				 u64 bio_offset,
				 extent_submit_bio_start_t *submit_bio_start)
				 extent_submit_bio_start_t *submit_bio_start)
{
{
	struct btrfs_fs_info *fs_info = BTRFS_I(inode)->root->fs_info;
	struct async_submit_bio *async;
	struct async_submit_bio *async;


	async = kmalloc(sizeof(*async), GFP_NOFS);
	async = kmalloc(sizeof(*async), GFP_NOFS);
	if (!async)
	if (!async)
		return BLK_STS_RESOURCE;
		return BLK_STS_RESOURCE;


	async->private_data = private_data;
	async->inode = inode;
	async->bio = bio;
	async->bio = bio;
	async->mirror_num = mirror_num;
	async->mirror_num = mirror_num;
	async->submit_bio_start = submit_bio_start;
	async->submit_bio_start = submit_bio_start;
@@ -795,7 +795,7 @@ static blk_status_t btree_csum_one_bio(struct bio *bio)
	return errno_to_blk_status(ret);
	return errno_to_blk_status(ret);
}
}


static blk_status_t btree_submit_bio_start(void *private_data, struct bio *bio,
static blk_status_t btree_submit_bio_start(struct inode *inode, struct bio *bio,
					   u64 bio_offset)
					   u64 bio_offset)
{
{
	/*
	/*
@@ -842,8 +842,8 @@ blk_status_t btrfs_submit_metadata_bio(struct inode *inode, struct bio *bio,
		 * kthread helpers are used to submit writes so that
		 * kthread helpers are used to submit writes so that
		 * checksumming can happen in parallel across all CPUs
		 * checksumming can happen in parallel across all CPUs
		 */
		 */
		ret = btrfs_wq_submit_bio(fs_info, bio, mirror_num, 0,
		ret = btrfs_wq_submit_bio(inode, bio, mirror_num, 0,
					  0, inode, btree_submit_bio_start);
					  0, btree_submit_bio_start);
	}
	}


	if (ret)
	if (ret)
+4 −4
Original line number Original line Diff line number Diff line
@@ -112,9 +112,9 @@ int btrfs_read_buffer(struct extent_buffer *buf, u64 parent_transid, int level,
		      struct btrfs_key *first_key);
		      struct btrfs_key *first_key);
blk_status_t btrfs_bio_wq_end_io(struct btrfs_fs_info *info, struct bio *bio,
blk_status_t btrfs_bio_wq_end_io(struct btrfs_fs_info *info, struct bio *bio,
			enum btrfs_wq_endio_type metadata);
			enum btrfs_wq_endio_type metadata);
blk_status_t btrfs_wq_submit_bio(struct btrfs_fs_info *fs_info, struct bio *bio,
blk_status_t btrfs_wq_submit_bio(struct inode *inode, struct bio *bio,
				 int mirror_num, unsigned long bio_flags,
				 int mirror_num, unsigned long bio_flags,
			u64 bio_offset, void *private_data,
				 u64 bio_offset,
				 extent_submit_bio_start_t *submit_bio_start);
				 extent_submit_bio_start_t *submit_bio_start);
blk_status_t btrfs_submit_bio_done(void *private_data, struct bio *bio,
blk_status_t btrfs_submit_bio_done(void *private_data, struct bio *bio,
			  int mirror_num);
			  int mirror_num);
+1 −1
Original line number Original line Diff line number Diff line
@@ -71,7 +71,7 @@ typedef blk_status_t (submit_bio_hook_t)(struct inode *inode, struct bio *bio,
					 int mirror_num,
					 int mirror_num,
					 unsigned long bio_flags);
					 unsigned long bio_flags);


typedef blk_status_t (extent_submit_bio_start_t)(void *private_data,
typedef blk_status_t (extent_submit_bio_start_t)(struct inode *inode,
		struct bio *bio, u64 bio_offset);
		struct bio *bio, u64 bio_offset);


#define INLINE_EXTENT_BUFFER_PAGES 16
#define INLINE_EXTENT_BUFFER_PAGES 16
+8 −12
Original line number Original line Diff line number Diff line
@@ -2194,11 +2194,9 @@ int btrfs_bio_fits_in_stripe(struct page *page, size_t size, struct bio *bio,
 * At IO completion time the cums attached on the ordered extent record
 * At IO completion time the cums attached on the ordered extent record
 * are inserted into the btree
 * are inserted into the btree
 */
 */
static blk_status_t btrfs_submit_bio_start(void *private_data, struct bio *bio,
static blk_status_t btrfs_submit_bio_start(struct inode *inode, struct bio *bio,
					   u64 bio_offset)
					   u64 bio_offset)
{
{
	struct inode *inode = private_data;

	return btrfs_csum_one_bio(BTRFS_I(inode), bio, 0, 0);
	return btrfs_csum_one_bio(BTRFS_I(inode), bio, 0, 0);
}
}


@@ -2263,8 +2261,8 @@ blk_status_t btrfs_submit_data_bio(struct inode *inode, struct bio *bio,
		if (root->root_key.objectid == BTRFS_DATA_RELOC_TREE_OBJECTID)
		if (root->root_key.objectid == BTRFS_DATA_RELOC_TREE_OBJECTID)
			goto mapit;
			goto mapit;
		/* we're doing a write, do the async checksumming */
		/* we're doing a write, do the async checksumming */
		ret = btrfs_wq_submit_bio(fs_info, bio, mirror_num, bio_flags,
		ret = btrfs_wq_submit_bio(inode, bio, mirror_num, bio_flags,
					  0, inode, btrfs_submit_bio_start);
					  0, btrfs_submit_bio_start);
		goto out;
		goto out;
	} else if (!skip_sum) {
	} else if (!skip_sum) {
		ret = btrfs_csum_one_bio(BTRFS_I(inode), bio, 0, 0);
		ret = btrfs_csum_one_bio(BTRFS_I(inode), bio, 0, 0);
@@ -7747,11 +7745,9 @@ static void __endio_write_update_ordered(struct btrfs_inode *inode,
	}
	}
}
}


static blk_status_t btrfs_submit_bio_start_direct_io(void *private_data,
static blk_status_t btrfs_submit_bio_start_direct_io(struct inode *inode,
						     struct bio *bio, u64 offset)
						     struct bio *bio, u64 offset)
{
{
	struct inode *inode = private_data;

	return btrfs_csum_one_bio(BTRFS_I(inode), bio, offset, 1);
	return btrfs_csum_one_bio(BTRFS_I(inode), bio, offset, 1);
}
}


@@ -7802,8 +7798,8 @@ static inline blk_status_t btrfs_submit_dio_bio(struct bio *bio,
		goto map;
		goto map;


	if (write && async_submit) {
	if (write && async_submit) {
		ret = btrfs_wq_submit_bio(fs_info, bio, 0, 0,
		ret = btrfs_wq_submit_bio(inode, bio, 0, 0,
					  file_offset, inode,
					  file_offset,
					  btrfs_submit_bio_start_direct_io);
					  btrfs_submit_bio_start_direct_io);
		goto err;
		goto err;
	} else if (write) {
	} else if (write) {