[2/6] btrfs: Change submit_bio_hook to taking an inode directly
diff mbox series

Message ID 20190410142443.6470-3-nborisov@suse.com
State New
Headers show
Series
  • Simplifications around submit_bio_hook
Related show

Commit Message

Nikolay Borisov April 10, 2019, 2:24 p.m. UTC
The only possible 'private_data' that is passed to this function is
actually an inode. Make that explicit by changing the signature of the
call back. No functional changes.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
 fs/btrfs/disk-io.c   | 5 ++---
 fs/btrfs/extent_io.h | 2 +-
 fs/btrfs/inode.c     | 3 +--
 3 files changed, 4 insertions(+), 6 deletions(-)

Comments

Johannes Thumshirn April 11, 2019, 11:18 a.m. UTC | #1
On 10/04/2019 16:24, Nikolay Borisov wrote:
> The only possible 'private_data' that is passed to this function is
> actually an inode. Make that explicit by changing the signature of the
> call back. No functional changes.

Can't we change struct extent_io_tree::private_data and
extent_io_tree_init(..., void *private_data) to be an inode as well?

If I didn't overlook something we always pass in an inode or NULL.
Nikolay Borisov April 11, 2019, 11:23 a.m. UTC | #2
On 11.04.19 г. 14:18 ч., Johannes Thumshirn wrote:
> On 10/04/2019 16:24, Nikolay Borisov wrote:
>> The only possible 'private_data' that is passed to this function is
>> actually an inode. Make that explicit by changing the signature of the
>> call back. No functional changes.
> 
> Can't we change struct extent_io_tree::private_data and
> extent_io_tree_init(..., void *private_data) to be an inode as well?
> 
> If I didn't overlook something we always pass in an inode or NULL.

You are right, latest refactoring I did made it so. I can send patches
atop this series.

David, how do you like to organise this? Resend the series with 2 more
patches in it or shall I send them as separate once this lands?

>

Patch
diff mbox series

diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 31bdedfb7490..b05adaf2bb80 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -885,11 +885,10 @@  static int check_async_write(struct btrfs_inode *bi)
 	return 1;
 }
 
-static blk_status_t btree_submit_bio_hook(void *private_data, struct bio *bio,
+static blk_status_t btree_submit_bio_hook(struct inode *inode, struct bio *bio,
 					  int mirror_num, unsigned long bio_flags,
 					  u64 bio_offset)
 {
-	struct inode *inode = private_data;
 	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
 	int async = check_async_write(BTRFS_I(inode));
 	blk_status_t ret;
@@ -915,7 +914,7 @@  static blk_status_t btree_submit_bio_hook(void *private_data, struct bio *bio,
 		 * checksumming can happen in parallel across all CPUs
 		 */
 		ret = btrfs_wq_submit_bio(fs_info, bio, mirror_num, 0,
-					  bio_offset, private_data,
+					  bio_offset, inode,
 					  btree_submit_bio_start);
 	}
 
diff --git a/fs/btrfs/extent_io.h b/fs/btrfs/extent_io.h
index 79bd20cf4226..abafb48947ef 100644
--- a/fs/btrfs/extent_io.h
+++ b/fs/btrfs/extent_io.h
@@ -104,7 +104,7 @@  struct extent_io_ops {
 	 * The following callbacks must be always defined, the function
 	 * pointer will be called unconditionally.
 	 */
-	blk_status_t (*submit_bio_hook)(void *private_data, struct bio *bio,
+	blk_status_t (*submit_bio_hook)(struct inode *inode, struct bio *bio,
 					int mirror_num, unsigned long bio_flags,
 					u64 bio_offset);
 	int (*readpage_end_io_hook)(struct btrfs_io_bio *io_bio, u64 phy_offset,
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 4e2f9f66bf59..07cf7050c99f 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -1953,11 +1953,10 @@  static blk_status_t btrfs_submit_bio_start(void *private_data, struct bio *bio,
  *
  *    c-3) otherwise:			async submit
  */
-static blk_status_t btrfs_submit_bio_hook(void *private_data, struct bio *bio,
+static blk_status_t btrfs_submit_bio_hook(struct inode *inode, struct bio *bio,
 				 int mirror_num, unsigned long bio_flags,
 				 u64 bio_offset)
 {
-	struct inode *inode = private_data;
 	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
 	struct btrfs_root *root = BTRFS_I(inode)->root;
 	enum btrfs_wq_endio_type metadata = BTRFS_WQ_ENDIO_DATA;