linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/40] Parameter and type changes to btrfs_inode
@ 2022-11-01 20:11 David Sterba
  2022-11-01 20:11 ` [PATCH 01/40] btrfs: change how repair action is passed to btrfs_repair_one_sector David Sterba
                   ` (40 more replies)
  0 siblings, 41 replies; 46+ messages in thread
From: David Sterba @ 2022-11-01 20:11 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

Many patches but also quite short, switching struct inode to struct
btrfs_node for structures and related functions in the io path, removing
some indirect function calls and typedefs.

David Sterba (40):
  btrfs: change how repair action is passed to btrfs_repair_one_sector
  btrfs: drop parameter compression_type from
    btrfs_submit_dio_repair_bio
  btrfs: change how submit bio callback is passed to btrfs_wq_submit_bio
  btrfs: simplify btree_submit_bio_start and btrfs_submit_bio_start
    parameters
  btrfs: switch async_submit_bio::inode to btrfs_inode
  btrfs: pass btrfs_inode to btrfs_submit_bio_start
  btrfs: pass btrfs_inode to btrfs_submit_bio_start_direct_io
  btrfs: pass btrfs_inode to btrfs_wq_submit_bio
  btrfs: pass btrfs_inode to btrfs_submit_metadata_bio
  btrfs: pass btrfs_inode to btrfs_submit_data_write_bio
  btrfs: pass btrfs_inode to btrfs_submit_data_read_bio
  btrfs: pass btrfs_inode to btrfs_submit_dio_repair_bio
  btrfs: pass btrfs_inode to submit_one_bio
  btrfs: pass btrfs_inode to btrfs_repair_one_sector
  btrfs: switch btrfs_dio_private::inode to btrfs_inode
  btrfs: pass btrfs_inode to btrfs_submit_dio_bio
  btrfs: pass btrfs_inode to btrfs_truncate
  btrfs: pass btrfs_inode to btrfs_inode_lock
  btrfs: pass btrfs_inode to btrfs_inode_unlock
  btrfs: pass btrfs_inode to btrfs_dirty_inode
  btrfs: pass btrfs_inode to btrfs_add_delalloc_inodes
  btrfs: switch btrfs_writepage_fixup::inode to btrfs_inode
  btrfs: pass btrfs_inode to btrfs_check_data_csum
  btrfs: pass btrfs_inode to __unlink_start_trans
  btrfs: pass btrfs_inode to btrfs_delete_subvolume
  btrfs: drop private_data parameter from extent_io_tree_init
  btrfs: switch extent_io_tree::private_data to btrfs_inode and rename
  btrfs: pass btrfs_inode to btrfs_merge_delalloc_extent
  btrfs: pass btrfs_inode to btrfs_set_delalloc_extent
  btrfs: pass btrfs_inode to btrfs_split_delalloc_extent
  btrfs: pass btrfs_inode to btrfs_clear_delalloc_extent
  btrfs: pass btrfs_inode to btrfs_unlink_subvol
  btrfs: pass btrfs_inode to btrfs_inode_by_name
  btrfs: pass btrfs_inode to fixup_tree_root_location
  btrfs: pass btrfs_inode to inode_tree_add
  btrfs: pass btrfs_inode to btrfs_inherit_iflags
  btrfs: switch async_chunk::inode to btrfs_inode
  btrfs: use btrfs_inode inside compress_file_range
  btrfs: use btrfs_inode inside btrfs_verify_data_csum
  btrfs: pass btrfs_inode to btrfs_add_delayed_iput

 fs/btrfs/btrfs_inode.h           |  29 +-
 fs/btrfs/compression.c           |   6 +-
 fs/btrfs/defrag.c                |  12 +-
 fs/btrfs/delayed-inode.c         |   4 +-
 fs/btrfs/disk-io.c               |  52 ++--
 fs/btrfs/disk-io.h               |  15 +-
 fs/btrfs/extent-io-tree.c        |  35 ++-
 fs/btrfs/extent-io-tree.h        |   6 +-
 fs/btrfs/extent_io.c             |  35 +--
 fs/btrfs/extent_io.h             |  11 +-
 fs/btrfs/file.c                  |  48 ++--
 fs/btrfs/free-space-cache.c      |   4 +-
 fs/btrfs/inode.c                 | 445 +++++++++++++++----------------
 fs/btrfs/ioctl.c                 |  10 +-
 fs/btrfs/ordered-data.c          |   2 +-
 fs/btrfs/reflink.c               |   4 +-
 fs/btrfs/relocation.c            |  11 +-
 fs/btrfs/tests/btrfs-tests.c     |   2 +-
 fs/btrfs/tests/extent-io-tests.c |   4 +-
 fs/btrfs/transaction.c           |   4 +-
 fs/btrfs/tree-log.c              |  24 +-
 fs/btrfs/volumes.c               |   3 +-
 include/trace/events/btrfs.h     |  27 +-
 23 files changed, 393 insertions(+), 400 deletions(-)

-- 
2.37.3


^ permalink raw reply	[flat|nested] 46+ messages in thread

* [PATCH 01/40] btrfs: change how repair action is passed to btrfs_repair_one_sector
  2022-11-01 20:11 [PATCH 00/40] Parameter and type changes to btrfs_inode David Sterba
@ 2022-11-01 20:11 ` David Sterba
  2022-11-01 20:11 ` [PATCH 02/40] btrfs: drop parameter compression_type from btrfs_submit_dio_repair_bio David Sterba
                   ` (39 subsequent siblings)
  40 siblings, 0 replies; 46+ messages in thread
From: David Sterba @ 2022-11-01 20:11 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

There's a function pointer passed to btrfs_repair_one_sector that will
submit the right bio for repair. However there are only two callbacks,
for buffered and for direct IO. This can be simplified to a bool-based
switch and call either function, indirect calls in this case is an
unnecessary abstraction. This allows to remove the submit_bio_hook_t
typedef.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/btrfs_inode.h |  3 +++
 fs/btrfs/compression.c |  2 +-
 fs/btrfs/extent_io.c   | 14 +++++++++-----
 fs/btrfs/extent_io.h   |  6 +-----
 fs/btrfs/inode.c       |  9 ++++-----
 5 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/fs/btrfs/btrfs_inode.h b/fs/btrfs/btrfs_inode.h
index d21c30bf7053..fa0c72cabd8f 100644
--- a/fs/btrfs/btrfs_inode.h
+++ b/fs/btrfs/btrfs_inode.h
@@ -414,6 +414,9 @@ static inline void btrfs_inode_split_flags(u64 inode_item_flags,
 void btrfs_submit_data_write_bio(struct inode *inode, struct bio *bio, int mirror_num);
 void btrfs_submit_data_read_bio(struct inode *inode, struct bio *bio,
 			int mirror_num, enum btrfs_compression_type compress_type);
+void btrfs_submit_dio_repair_bio(struct inode *inode, struct bio *bio,
+				 int mirror_num,
+				 enum btrfs_compression_type compress_type);
 int btrfs_check_sector_csum(struct btrfs_fs_info *fs_info, struct page *page,
 			    u32 pgoff, u8 *csum, const u8 * const csum_expected);
 int btrfs_check_data_csum(struct inode *inode, struct btrfs_bio *bbio,
diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c
index 52df6c06cc91..e84764ef250b 100644
--- a/fs/btrfs/compression.c
+++ b/fs/btrfs/compression.c
@@ -196,7 +196,7 @@ static void end_compressed_bio_read(struct btrfs_bio *bbio)
 			refcount_inc(&cb->pending_ios);
 			ret = btrfs_repair_one_sector(inode, bbio, offset,
 						      bv.bv_page, bv.bv_offset,
-						      btrfs_submit_data_read_bio);
+						      true);
 			if (ret) {
 				refcount_dec(&cb->pending_ios);
 				status = errno_to_blk_status(ret);
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 2ec989b83f54..44ff41304247 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -797,7 +797,7 @@ static struct io_failure_record *btrfs_get_io_failure_record(struct inode *inode
 
 int btrfs_repair_one_sector(struct inode *inode, struct btrfs_bio *failed_bbio,
 			    u32 bio_offset, struct page *page, unsigned int pgoff,
-			    submit_bio_hook_t *submit_bio_hook)
+			    bool submit_buffered)
 {
 	u64 start = failed_bbio->file_offset + bio_offset;
 	struct io_failure_record *failrec;
@@ -856,11 +856,15 @@ int btrfs_repair_one_sector(struct inode *inode, struct btrfs_bio *failed_bbio,
 		    failrec->this_mirror);
 
 	/*
-	 * At this point we have a bio, so any errors from submit_bio_hook()
-	 * will be handled by the endio on the repair_bio, so we can't return an
+	 * At this point we have a bio, so any errors from bio submission will
+	 * be handled by the endio on the repair_bio, so we can't return an
 	 * error here.
 	 */
-	submit_bio_hook(inode, repair_bio, failrec->this_mirror, 0);
+	if (submit_buffered)
+		btrfs_submit_data_read_bio(inode, repair_bio, failrec->this_mirror, 0);
+	else
+		btrfs_submit_dio_repair_bio(inode, repair_bio, failrec->this_mirror, 0);
+
 	return BLK_STS_OK;
 }
 
@@ -951,7 +955,7 @@ static void submit_data_read_repair(struct inode *inode,
 
 		ret = btrfs_repair_one_sector(inode, failed_bbio,
 				bio_offset + offset, page, pgoff + offset,
-				btrfs_submit_data_read_bio);
+				true);
 		if (!ret) {
 			/*
 			 * We have submitted the read repair, the page release
diff --git a/fs/btrfs/extent_io.h b/fs/btrfs/extent_io.h
index a5ec1475988f..321680f229c6 100644
--- a/fs/btrfs/extent_io.h
+++ b/fs/btrfs/extent_io.h
@@ -70,10 +70,6 @@ struct extent_io_tree;
 int __init extent_buffer_init_cachep(void);
 void __cold extent_buffer_free_cachep(void);
 
-typedef void (submit_bio_hook_t)(struct inode *inode, struct bio *bio,
-					 int mirror_num,
-					 enum btrfs_compression_type compress_type);
-
 typedef blk_status_t (extent_submit_bio_start_t)(struct inode *inode,
 		struct bio *bio, u64 dio_file_offset);
 
@@ -277,7 +273,7 @@ struct io_failure_record {
 
 int btrfs_repair_one_sector(struct inode *inode, struct btrfs_bio *failed_bbio,
 			    u32 bio_offset, struct page *page, unsigned int pgoff,
-			    submit_bio_hook_t *submit_bio_hook);
+			    bool submit_buffered);
 void btrfs_free_io_failure_record(struct btrfs_inode *inode, u64 start, u64 end);
 int btrfs_clean_io_failure(struct btrfs_inode *inode, u64 start,
 			   struct page *page, unsigned int pg_offset);
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 255959574724..b9aa805bbe55 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -7922,9 +7922,9 @@ static void btrfs_dio_private_put(struct btrfs_dio_private *dip)
 	bio_endio(&dip->bio);
 }
 
-static void submit_dio_repair_bio(struct inode *inode, struct bio *bio,
-				  int mirror_num,
-				  enum btrfs_compression_type compress_type)
+void btrfs_submit_dio_repair_bio(struct inode *inode, struct bio *bio,
+				 int mirror_num,
+				 enum btrfs_compression_type compress_type)
 {
 	struct btrfs_dio_private *dip = btrfs_bio(bio)->private;
 	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
@@ -7959,8 +7959,7 @@ static blk_status_t btrfs_check_read_dio_bio(struct btrfs_dio_private *dip,
 			int ret;
 
 			ret = btrfs_repair_one_sector(inode, bbio, offset,
-					bv.bv_page, bv.bv_offset,
-					submit_dio_repair_bio);
+					bv.bv_page, bv.bv_offset, false);
 			if (ret)
 				err = errno_to_blk_status(ret);
 		}
-- 
2.37.3


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 02/40] btrfs: drop parameter compression_type from btrfs_submit_dio_repair_bio
  2022-11-01 20:11 [PATCH 00/40] Parameter and type changes to btrfs_inode David Sterba
  2022-11-01 20:11 ` [PATCH 01/40] btrfs: change how repair action is passed to btrfs_repair_one_sector David Sterba
@ 2022-11-01 20:11 ` David Sterba
  2022-11-01 20:11 ` [PATCH 03/40] btrfs: change how submit bio callback is passed to btrfs_wq_submit_bio David Sterba
                   ` (38 subsequent siblings)
  40 siblings, 0 replies; 46+ messages in thread
From: David Sterba @ 2022-11-01 20:11 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

Compression and direct io don't work together so the compression
parameter can be dropped after previous patch that changed the call
to direct.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/btrfs_inode.h | 4 +---
 fs/btrfs/extent_io.c   | 2 +-
 fs/btrfs/inode.c       | 4 +---
 3 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/fs/btrfs/btrfs_inode.h b/fs/btrfs/btrfs_inode.h
index fa0c72cabd8f..62019d7c1cbd 100644
--- a/fs/btrfs/btrfs_inode.h
+++ b/fs/btrfs/btrfs_inode.h
@@ -414,9 +414,7 @@ static inline void btrfs_inode_split_flags(u64 inode_item_flags,
 void btrfs_submit_data_write_bio(struct inode *inode, struct bio *bio, int mirror_num);
 void btrfs_submit_data_read_bio(struct inode *inode, struct bio *bio,
 			int mirror_num, enum btrfs_compression_type compress_type);
-void btrfs_submit_dio_repair_bio(struct inode *inode, struct bio *bio,
-				 int mirror_num,
-				 enum btrfs_compression_type compress_type);
+void btrfs_submit_dio_repair_bio(struct inode *inode, struct bio *bio, int mirror_num);
 int btrfs_check_sector_csum(struct btrfs_fs_info *fs_info, struct page *page,
 			    u32 pgoff, u8 *csum, const u8 * const csum_expected);
 int btrfs_check_data_csum(struct inode *inode, struct btrfs_bio *bbio,
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 44ff41304247..cc05ae772fa5 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -863,7 +863,7 @@ int btrfs_repair_one_sector(struct inode *inode, struct btrfs_bio *failed_bbio,
 	if (submit_buffered)
 		btrfs_submit_data_read_bio(inode, repair_bio, failrec->this_mirror, 0);
 	else
-		btrfs_submit_dio_repair_bio(inode, repair_bio, failrec->this_mirror, 0);
+		btrfs_submit_dio_repair_bio(inode, repair_bio, failrec->this_mirror);
 
 	return BLK_STS_OK;
 }
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index b9aa805bbe55..da9d3a8e2d93 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -7922,9 +7922,7 @@ static void btrfs_dio_private_put(struct btrfs_dio_private *dip)
 	bio_endio(&dip->bio);
 }
 
-void btrfs_submit_dio_repair_bio(struct inode *inode, struct bio *bio,
-				 int mirror_num,
-				 enum btrfs_compression_type compress_type)
+void btrfs_submit_dio_repair_bio(struct inode *inode, struct bio *bio, int mirror_num)
 {
 	struct btrfs_dio_private *dip = btrfs_bio(bio)->private;
 	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
-- 
2.37.3


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 03/40] btrfs: change how submit bio callback is passed to btrfs_wq_submit_bio
  2022-11-01 20:11 [PATCH 00/40] Parameter and type changes to btrfs_inode David Sterba
  2022-11-01 20:11 ` [PATCH 01/40] btrfs: change how repair action is passed to btrfs_repair_one_sector David Sterba
  2022-11-01 20:11 ` [PATCH 02/40] btrfs: drop parameter compression_type from btrfs_submit_dio_repair_bio David Sterba
@ 2022-11-01 20:11 ` David Sterba
  2022-11-01 20:11 ` [PATCH 04/40] btrfs: simplify btree_submit_bio_start and btrfs_submit_bio_start parameters David Sterba
                   ` (37 subsequent siblings)
  40 siblings, 0 replies; 46+ messages in thread
From: David Sterba @ 2022-11-01 20:11 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

There's a callback function parameter for btrfs_wq_submit_bio that can
be one of: metadata, buffered data, direct io data. The callback
abstraction is unnecessary as we have all functions available.

Replace the parameter with a command that leads to a direct call in
run_one_async_start. The called functions can be then simplified and we
can also remove the extent_submit_bio_start_t typedef.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/btrfs_inode.h |  5 +++++
 fs/btrfs/disk-io.c     | 33 +++++++++++++++++++++++----------
 fs/btrfs/disk-io.h     | 12 ++++++++++--
 fs/btrfs/extent_io.h   |  3 ---
 fs/btrfs/inode.c       | 15 +++++++--------
 5 files changed, 45 insertions(+), 23 deletions(-)

diff --git a/fs/btrfs/btrfs_inode.h b/fs/btrfs/btrfs_inode.h
index 62019d7c1cbd..72cf235b7beb 100644
--- a/fs/btrfs/btrfs_inode.h
+++ b/fs/btrfs/btrfs_inode.h
@@ -415,6 +415,11 @@ void btrfs_submit_data_write_bio(struct inode *inode, struct bio *bio, int mirro
 void btrfs_submit_data_read_bio(struct inode *inode, struct bio *bio,
 			int mirror_num, enum btrfs_compression_type compress_type);
 void btrfs_submit_dio_repair_bio(struct inode *inode, struct bio *bio, int mirror_num);
+blk_status_t btrfs_submit_bio_start(struct inode *inode, struct bio *bio,
+				    u64 dio_file_offset);
+blk_status_t btrfs_submit_bio_start_direct_io(struct inode *inode,
+					      struct bio *bio,
+					      u64 dio_file_offset);
 int btrfs_check_sector_csum(struct btrfs_fs_info *fs_info, struct page *page,
 			    u32 pgoff, u8 *csum, const u8 * const csum_expected);
 int btrfs_check_data_csum(struct inode *inode, struct btrfs_bio *bbio,
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 5c099d046170..f2d5677a9e6f 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -86,10 +86,10 @@ static void btrfs_free_csum_hash(struct btrfs_fs_info *fs_info)
 struct async_submit_bio {
 	struct inode *inode;
 	struct bio *bio;
-	extent_submit_bio_start_t *submit_bio_start;
+	enum btrfs_wq_submit_cmd submit_cmd;
 	int mirror_num;
 
-	/* Optional parameter for submit_bio_start used by direct io */
+	/* Optional parameter for used by direct io */
 	u64 dio_file_offset;
 	struct btrfs_work work;
 	blk_status_t status;
@@ -637,8 +637,22 @@ static void run_one_async_start(struct btrfs_work *work)
 	blk_status_t ret;
 
 	async = container_of(work, struct  async_submit_bio, work);
-	ret = async->submit_bio_start(async->inode, async->bio,
-				      async->dio_file_offset);
+	switch (async->submit_cmd) {
+	case WQ_SUBMIT_METADATA:
+		ret = btree_submit_bio_start(async->inode, async->bio,
+					     async->dio_file_offset);
+		break;
+	case WQ_SUBMIT_DATA:
+		ret = btrfs_submit_bio_start(async->inode, async->bio,
+					     async->dio_file_offset);
+
+		break;
+	case WQ_SUBMIT_DATA_DIO:
+		ret = btrfs_submit_bio_start_direct_io(async->inode, async->bio,
+						       async->dio_file_offset);
+
+		break;
+	}
 	if (ret)
 		async->status = ret;
 }
@@ -689,8 +703,7 @@ static void run_one_async_free(struct btrfs_work *work)
  * - false in case of error
  */
 bool btrfs_wq_submit_bio(struct inode *inode, struct bio *bio, int mirror_num,
-			 u64 dio_file_offset,
-			 extent_submit_bio_start_t *submit_bio_start)
+			 u64 dio_file_offset, enum btrfs_wq_submit_cmd cmd)
 {
 	struct btrfs_fs_info *fs_info = BTRFS_I(inode)->root->fs_info;
 	struct async_submit_bio *async;
@@ -702,7 +715,7 @@ bool btrfs_wq_submit_bio(struct inode *inode, struct bio *bio, int mirror_num,
 	async->inode = inode;
 	async->bio = bio;
 	async->mirror_num = mirror_num;
-	async->submit_bio_start = submit_bio_start;
+	async->submit_cmd = cmd;
 
 	btrfs_init_work(&async->work, run_one_async_start, run_one_async_done,
 			run_one_async_free);
@@ -736,8 +749,8 @@ static blk_status_t btree_csum_one_bio(struct bio *bio)
 	return errno_to_blk_status(ret);
 }
 
-static blk_status_t btree_submit_bio_start(struct inode *inode, struct bio *bio,
-					   u64 dio_file_offset)
+blk_status_t btree_submit_bio_start(struct inode *inode, struct bio *bio,
+				    u64 dio_file_offset)
 {
 	/*
 	 * when we're called for a write, we're already in the async
@@ -776,7 +789,7 @@ void btrfs_submit_metadata_bio(struct inode *inode, struct bio *bio, int mirror_
 	 * happen in parallel across all CPUs.
 	 */
 	if (should_async_write(fs_info, BTRFS_I(inode)) &&
-	    btrfs_wq_submit_bio(inode, bio, mirror_num, 0, btree_submit_bio_start))
+	    btrfs_wq_submit_bio(inode, bio, mirror_num, 0, WQ_SUBMIT_METADATA))
 		return;
 
 	ret = btree_csum_one_bio(bio);
diff --git a/fs/btrfs/disk-io.h b/fs/btrfs/disk-io.h
index 6edc66b4b4d3..5998b2589830 100644
--- a/fs/btrfs/disk-io.h
+++ b/fs/btrfs/disk-io.h
@@ -113,9 +113,17 @@ int btrfs_buffer_uptodate(struct extent_buffer *buf, u64 parent_transid,
 			  int atomic);
 int btrfs_read_extent_buffer(struct extent_buffer *buf, u64 parent_transid,
 			     int level, struct btrfs_key *first_key);
+
+enum btrfs_wq_submit_cmd {
+	WQ_SUBMIT_METADATA,
+	WQ_SUBMIT_DATA,
+	WQ_SUBMIT_DATA_DIO,
+};
+
 bool btrfs_wq_submit_bio(struct inode *inode, struct bio *bio, int mirror_num,
-			 u64 dio_file_offset,
-			 extent_submit_bio_start_t *submit_bio_start);
+			 u64 dio_file_offset, enum btrfs_wq_submit_cmd cmd);
+blk_status_t btree_submit_bio_start(struct inode *inode, struct bio *bio,
+				    u64 dio_file_offset);
 int btrfs_alloc_log_tree_node(struct btrfs_trans_handle *trans,
 			      struct btrfs_root *root);
 int btrfs_init_log_root_tree(struct btrfs_trans_handle *trans,
diff --git a/fs/btrfs/extent_io.h b/fs/btrfs/extent_io.h
index 321680f229c6..b3d4b568fe33 100644
--- a/fs/btrfs/extent_io.h
+++ b/fs/btrfs/extent_io.h
@@ -70,9 +70,6 @@ struct extent_io_tree;
 int __init extent_buffer_init_cachep(void);
 void __cold extent_buffer_free_cachep(void);
 
-typedef blk_status_t (extent_submit_bio_start_t)(struct inode *inode,
-		struct bio *bio, u64 dio_file_offset);
-
 #define INLINE_EXTENT_BUFFER_PAGES     (BTRFS_MAX_METADATA_BLOCKSIZE / PAGE_SIZE)
 struct extent_buffer {
 	u64 start;
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index da9d3a8e2d93..962e39b4f7cb 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -2550,8 +2550,8 @@ void btrfs_clear_delalloc_extent(struct inode *vfs_inode,
  * At IO completion time the cums attached on the ordered extent record
  * are inserted into the btree
  */
-static blk_status_t btrfs_submit_bio_start(struct inode *inode, struct bio *bio,
-					   u64 dio_file_offset)
+blk_status_t btrfs_submit_bio_start(struct inode *inode, struct bio *bio,
+				    u64 dio_file_offset)
 {
 	return btrfs_csum_one_bio(BTRFS_I(inode), bio, (u64)-1, false);
 }
@@ -2758,8 +2758,7 @@ void btrfs_submit_data_write_bio(struct inode *inode, struct bio *bio, int mirro
 	    !test_bit(BTRFS_FS_STATE_NO_CSUMS, &fs_info->fs_state) &&
 	    !btrfs_is_data_reloc_root(bi->root)) {
 		if (!atomic_read(&bi->sync_writers) &&
-		    btrfs_wq_submit_bio(inode, bio, mirror_num, 0,
-					btrfs_submit_bio_start))
+		    btrfs_wq_submit_bio(inode, bio, mirror_num, 0, WQ_SUBMIT_DATA))
 			return;
 
 		ret = btrfs_csum_one_bio(bi, bio, (u64)-1, false);
@@ -7966,9 +7965,9 @@ static blk_status_t btrfs_check_read_dio_bio(struct btrfs_dio_private *dip,
 	return err;
 }
 
-static blk_status_t btrfs_submit_bio_start_direct_io(struct inode *inode,
-						     struct bio *bio,
-						     u64 dio_file_offset)
+blk_status_t btrfs_submit_bio_start_direct_io(struct inode *inode,
+					      struct bio *bio,
+					      u64 dio_file_offset)
 {
 	return btrfs_csum_one_bio(BTRFS_I(inode), bio, dio_file_offset, false);
 }
@@ -8016,7 +8015,7 @@ static void btrfs_submit_dio_bio(struct bio *bio, struct inode *inode,
 		/* Check btrfs_submit_data_write_bio() for async submit rules */
 		if (async_submit && !atomic_read(&BTRFS_I(inode)->sync_writers) &&
 		    btrfs_wq_submit_bio(inode, bio, 0, file_offset,
-					btrfs_submit_bio_start_direct_io))
+					WQ_SUBMIT_DATA_DIO))
 			return;
 
 		/*
-- 
2.37.3


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 04/40] btrfs: simplify btree_submit_bio_start and btrfs_submit_bio_start parameters
  2022-11-01 20:11 [PATCH 00/40] Parameter and type changes to btrfs_inode David Sterba
                   ` (2 preceding siblings ...)
  2022-11-01 20:11 ` [PATCH 03/40] btrfs: change how submit bio callback is passed to btrfs_wq_submit_bio David Sterba
@ 2022-11-01 20:11 ` David Sterba
  2022-11-02  0:12   ` Anand Jain
  2022-11-01 20:11 ` [PATCH 05/40] btrfs: switch async_submit_bio::inode to btrfs_inode David Sterba
                   ` (36 subsequent siblings)
  40 siblings, 1 reply; 46+ messages in thread
From: David Sterba @ 2022-11-01 20:11 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

After previous patches the unused parameters can be removed from
btree_submit_bio_start and btrfs_submit_bio_start as they don't need to
conform to the extent_submit_bio_start_t typedef.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/btrfs_inode.h |  3 +--
 fs/btrfs/disk-io.c     | 11 +++--------
 fs/btrfs/disk-io.h     |  3 +--
 fs/btrfs/inode.c       |  3 +--
 4 files changed, 6 insertions(+), 14 deletions(-)

diff --git a/fs/btrfs/btrfs_inode.h b/fs/btrfs/btrfs_inode.h
index 72cf235b7beb..54bf002e0013 100644
--- a/fs/btrfs/btrfs_inode.h
+++ b/fs/btrfs/btrfs_inode.h
@@ -415,8 +415,7 @@ void btrfs_submit_data_write_bio(struct inode *inode, struct bio *bio, int mirro
 void btrfs_submit_data_read_bio(struct inode *inode, struct bio *bio,
 			int mirror_num, enum btrfs_compression_type compress_type);
 void btrfs_submit_dio_repair_bio(struct inode *inode, struct bio *bio, int mirror_num);
-blk_status_t btrfs_submit_bio_start(struct inode *inode, struct bio *bio,
-				    u64 dio_file_offset);
+blk_status_t btrfs_submit_bio_start(struct inode *inode, struct bio *bio);
 blk_status_t btrfs_submit_bio_start_direct_io(struct inode *inode,
 					      struct bio *bio,
 					      u64 dio_file_offset);
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index f2d5677a9e6f..6ae9d63036ce 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -639,18 +639,14 @@ static void run_one_async_start(struct btrfs_work *work)
 	async = container_of(work, struct  async_submit_bio, work);
 	switch (async->submit_cmd) {
 	case WQ_SUBMIT_METADATA:
-		ret = btree_submit_bio_start(async->inode, async->bio,
-					     async->dio_file_offset);
+		ret = btree_submit_bio_start(async->bio);
 		break;
 	case WQ_SUBMIT_DATA:
-		ret = btrfs_submit_bio_start(async->inode, async->bio,
-					     async->dio_file_offset);
-
+		ret = btrfs_submit_bio_start(async->inode, async->bio);
 		break;
 	case WQ_SUBMIT_DATA_DIO:
 		ret = btrfs_submit_bio_start_direct_io(async->inode, async->bio,
 						       async->dio_file_offset);
-
 		break;
 	}
 	if (ret)
@@ -749,8 +745,7 @@ static blk_status_t btree_csum_one_bio(struct bio *bio)
 	return errno_to_blk_status(ret);
 }
 
-blk_status_t btree_submit_bio_start(struct inode *inode, struct bio *bio,
-				    u64 dio_file_offset)
+blk_status_t btree_submit_bio_start(struct bio *bio)
 {
 	/*
 	 * when we're called for a write, we're already in the async
diff --git a/fs/btrfs/disk-io.h b/fs/btrfs/disk-io.h
index 5998b2589830..d5b25fa8037b 100644
--- a/fs/btrfs/disk-io.h
+++ b/fs/btrfs/disk-io.h
@@ -122,8 +122,7 @@ enum btrfs_wq_submit_cmd {
 
 bool btrfs_wq_submit_bio(struct inode *inode, struct bio *bio, int mirror_num,
 			 u64 dio_file_offset, enum btrfs_wq_submit_cmd cmd);
-blk_status_t btree_submit_bio_start(struct inode *inode, struct bio *bio,
-				    u64 dio_file_offset);
+blk_status_t btree_submit_bio_start(struct bio *bio);
 int btrfs_alloc_log_tree_node(struct btrfs_trans_handle *trans,
 			      struct btrfs_root *root);
 int btrfs_init_log_root_tree(struct btrfs_trans_handle *trans,
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 962e39b4f7cb..2a61b610e02b 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -2550,8 +2550,7 @@ void btrfs_clear_delalloc_extent(struct inode *vfs_inode,
  * At IO completion time the cums attached on the ordered extent record
  * are inserted into the btree
  */
-blk_status_t btrfs_submit_bio_start(struct inode *inode, struct bio *bio,
-				    u64 dio_file_offset)
+blk_status_t btrfs_submit_bio_start(struct inode *inode, struct bio *bio);
 {
 	return btrfs_csum_one_bio(BTRFS_I(inode), bio, (u64)-1, false);
 }
-- 
2.37.3


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 05/40] btrfs: switch async_submit_bio::inode to btrfs_inode
  2022-11-01 20:11 [PATCH 00/40] Parameter and type changes to btrfs_inode David Sterba
                   ` (3 preceding siblings ...)
  2022-11-01 20:11 ` [PATCH 04/40] btrfs: simplify btree_submit_bio_start and btrfs_submit_bio_start parameters David Sterba
@ 2022-11-01 20:11 ` David Sterba
  2022-11-01 20:11 ` [PATCH 06/40] btrfs: pass btrfs_inode to btrfs_submit_bio_start David Sterba
                   ` (35 subsequent siblings)
  40 siblings, 0 replies; 46+ messages in thread
From: David Sterba @ 2022-11-01 20:11 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

The async bio submit is for internal interfaces so we should use the
btrfs_inode.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/disk-io.c | 14 +++++++-------
 fs/btrfs/inode.c   |  2 +-
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 6ae9d63036ce..51e98e0997d5 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -84,7 +84,7 @@ static void btrfs_free_csum_hash(struct btrfs_fs_info *fs_info)
  * just before they are sent down the IO stack.
  */
 struct async_submit_bio {
-	struct inode *inode;
+	struct btrfs_inode *inode;
 	struct bio *bio;
 	enum btrfs_wq_submit_cmd submit_cmd;
 	int mirror_num;
@@ -642,11 +642,11 @@ static void run_one_async_start(struct btrfs_work *work)
 		ret = btree_submit_bio_start(async->bio);
 		break;
 	case WQ_SUBMIT_DATA:
-		ret = btrfs_submit_bio_start(async->inode, async->bio);
+		ret = btrfs_submit_bio_start(&async->inode->vfs_inode, async->bio);
 		break;
 	case WQ_SUBMIT_DATA_DIO:
-		ret = btrfs_submit_bio_start_direct_io(async->inode, async->bio,
-						       async->dio_file_offset);
+		ret = btrfs_submit_bio_start_direct_io(&async->inode->vfs_inode,
+				async->bio, async->dio_file_offset);
 		break;
 	}
 	if (ret)
@@ -665,7 +665,7 @@ static void run_one_async_done(struct btrfs_work *work)
 {
 	struct async_submit_bio *async =
 		container_of(work, struct  async_submit_bio, work);
-	struct inode *inode = async->inode;
+	struct btrfs_inode *inode = async->inode;
 	struct btrfs_bio *bbio = btrfs_bio(async->bio);
 
 	/* If an error occurred we just want to clean up the bio and move on */
@@ -680,7 +680,7 @@ static void run_one_async_done(struct btrfs_work *work)
 	 * This changes nothing when cgroups aren't in use.
 	 */
 	async->bio->bi_opf |= REQ_CGROUP_PUNT;
-	btrfs_submit_bio(btrfs_sb(inode->i_sb), async->bio, async->mirror_num);
+	btrfs_submit_bio(inode->root->fs_info, async->bio, async->mirror_num);
 }
 
 static void run_one_async_free(struct btrfs_work *work)
@@ -708,7 +708,7 @@ bool btrfs_wq_submit_bio(struct inode *inode, struct bio *bio, int mirror_num,
 	if (!async)
 		return false;
 
-	async->inode = inode;
+	async->inode = BTRFS_I(inode);
 	async->bio = bio;
 	async->mirror_num = mirror_num;
 	async->submit_cmd = cmd;
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 2a61b610e02b..b7cc5cfcf220 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -2550,7 +2550,7 @@ void btrfs_clear_delalloc_extent(struct inode *vfs_inode,
  * At IO completion time the cums attached on the ordered extent record
  * are inserted into the btree
  */
-blk_status_t btrfs_submit_bio_start(struct inode *inode, struct bio *bio);
+blk_status_t btrfs_submit_bio_start(struct inode *inode, struct bio *bio)
 {
 	return btrfs_csum_one_bio(BTRFS_I(inode), bio, (u64)-1, false);
 }
-- 
2.37.3


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 06/40] btrfs: pass btrfs_inode to btrfs_submit_bio_start
  2022-11-01 20:11 [PATCH 00/40] Parameter and type changes to btrfs_inode David Sterba
                   ` (4 preceding siblings ...)
  2022-11-01 20:11 ` [PATCH 05/40] btrfs: switch async_submit_bio::inode to btrfs_inode David Sterba
@ 2022-11-01 20:11 ` David Sterba
  2022-11-01 20:11 ` [PATCH 07/40] btrfs: pass btrfs_inode to btrfs_submit_bio_start_direct_io David Sterba
                   ` (34 subsequent siblings)
  40 siblings, 0 replies; 46+ messages in thread
From: David Sterba @ 2022-11-01 20:11 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

The function is for internal interfaces so we should use the
btrfs_inode.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/btrfs_inode.h | 2 +-
 fs/btrfs/disk-io.c     | 2 +-
 fs/btrfs/inode.c       | 4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/btrfs/btrfs_inode.h b/fs/btrfs/btrfs_inode.h
index 54bf002e0013..4ec6a74dd6ba 100644
--- a/fs/btrfs/btrfs_inode.h
+++ b/fs/btrfs/btrfs_inode.h
@@ -415,7 +415,7 @@ void btrfs_submit_data_write_bio(struct inode *inode, struct bio *bio, int mirro
 void btrfs_submit_data_read_bio(struct inode *inode, struct bio *bio,
 			int mirror_num, enum btrfs_compression_type compress_type);
 void btrfs_submit_dio_repair_bio(struct inode *inode, struct bio *bio, int mirror_num);
-blk_status_t btrfs_submit_bio_start(struct inode *inode, struct bio *bio);
+blk_status_t btrfs_submit_bio_start(struct btrfs_inode *inode, struct bio *bio);
 blk_status_t btrfs_submit_bio_start_direct_io(struct inode *inode,
 					      struct bio *bio,
 					      u64 dio_file_offset);
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 51e98e0997d5..6319df271cff 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -642,7 +642,7 @@ static void run_one_async_start(struct btrfs_work *work)
 		ret = btree_submit_bio_start(async->bio);
 		break;
 	case WQ_SUBMIT_DATA:
-		ret = btrfs_submit_bio_start(&async->inode->vfs_inode, async->bio);
+		ret = btrfs_submit_bio_start(async->inode, async->bio);
 		break;
 	case WQ_SUBMIT_DATA_DIO:
 		ret = btrfs_submit_bio_start_direct_io(&async->inode->vfs_inode,
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index b7cc5cfcf220..aa27c8b990cf 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -2550,9 +2550,9 @@ void btrfs_clear_delalloc_extent(struct inode *vfs_inode,
  * At IO completion time the cums attached on the ordered extent record
  * are inserted into the btree
  */
-blk_status_t btrfs_submit_bio_start(struct inode *inode, struct bio *bio)
+blk_status_t btrfs_submit_bio_start(struct btrfs_inode *inode, struct bio *bio)
 {
-	return btrfs_csum_one_bio(BTRFS_I(inode), bio, (u64)-1, false);
+	return btrfs_csum_one_bio(inode, bio, (u64)-1, false);
 }
 
 /*
-- 
2.37.3


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 07/40] btrfs: pass btrfs_inode to btrfs_submit_bio_start_direct_io
  2022-11-01 20:11 [PATCH 00/40] Parameter and type changes to btrfs_inode David Sterba
                   ` (5 preceding siblings ...)
  2022-11-01 20:11 ` [PATCH 06/40] btrfs: pass btrfs_inode to btrfs_submit_bio_start David Sterba
@ 2022-11-01 20:11 ` David Sterba
  2022-11-01 20:11 ` [PATCH 08/40] btrfs: pass btrfs_inode to btrfs_wq_submit_bio David Sterba
                   ` (33 subsequent siblings)
  40 siblings, 0 replies; 46+ messages in thread
From: David Sterba @ 2022-11-01 20:11 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

The function is for internal interfaces so we should use the
btrfs_inode.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/btrfs_inode.h | 2 +-
 fs/btrfs/disk-io.c     | 2 +-
 fs/btrfs/inode.c       | 4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/btrfs/btrfs_inode.h b/fs/btrfs/btrfs_inode.h
index 4ec6a74dd6ba..a41d4f953bfa 100644
--- a/fs/btrfs/btrfs_inode.h
+++ b/fs/btrfs/btrfs_inode.h
@@ -416,7 +416,7 @@ void btrfs_submit_data_read_bio(struct inode *inode, struct bio *bio,
 			int mirror_num, enum btrfs_compression_type compress_type);
 void btrfs_submit_dio_repair_bio(struct inode *inode, struct bio *bio, int mirror_num);
 blk_status_t btrfs_submit_bio_start(struct btrfs_inode *inode, struct bio *bio);
-blk_status_t btrfs_submit_bio_start_direct_io(struct inode *inode,
+blk_status_t btrfs_submit_bio_start_direct_io(struct btrfs_inode *inode,
 					      struct bio *bio,
 					      u64 dio_file_offset);
 int btrfs_check_sector_csum(struct btrfs_fs_info *fs_info, struct page *page,
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 6319df271cff..49c2beb72d21 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -645,7 +645,7 @@ static void run_one_async_start(struct btrfs_work *work)
 		ret = btrfs_submit_bio_start(async->inode, async->bio);
 		break;
 	case WQ_SUBMIT_DATA_DIO:
-		ret = btrfs_submit_bio_start_direct_io(&async->inode->vfs_inode,
+		ret = btrfs_submit_bio_start_direct_io(async->inode,
 				async->bio, async->dio_file_offset);
 		break;
 	}
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index aa27c8b990cf..2c786075196a 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -7964,11 +7964,11 @@ static blk_status_t btrfs_check_read_dio_bio(struct btrfs_dio_private *dip,
 	return err;
 }
 
-blk_status_t btrfs_submit_bio_start_direct_io(struct inode *inode,
+blk_status_t btrfs_submit_bio_start_direct_io(struct btrfs_inode *inode,
 					      struct bio *bio,
 					      u64 dio_file_offset)
 {
-	return btrfs_csum_one_bio(BTRFS_I(inode), bio, dio_file_offset, false);
+	return btrfs_csum_one_bio(inode, bio, dio_file_offset, false);
 }
 
 static void btrfs_end_dio_bio(struct btrfs_bio *bbio)
-- 
2.37.3


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 08/40] btrfs: pass btrfs_inode to btrfs_wq_submit_bio
  2022-11-01 20:11 [PATCH 00/40] Parameter and type changes to btrfs_inode David Sterba
                   ` (6 preceding siblings ...)
  2022-11-01 20:11 ` [PATCH 07/40] btrfs: pass btrfs_inode to btrfs_submit_bio_start_direct_io David Sterba
@ 2022-11-01 20:11 ` David Sterba
  2022-11-01 20:11 ` [PATCH 09/40] btrfs: pass btrfs_inode to btrfs_submit_metadata_bio David Sterba
                   ` (32 subsequent siblings)
  40 siblings, 0 replies; 46+ messages in thread
From: David Sterba @ 2022-11-01 20:11 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

The function is for internal interfaces so we should use the
btrfs_inode.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/disk-io.c | 8 ++++----
 fs/btrfs/disk-io.h | 2 +-
 fs/btrfs/inode.c   | 4 ++--
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 49c2beb72d21..ced90987127b 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -698,17 +698,17 @@ static void run_one_async_free(struct btrfs_work *work)
  * - true if the work has been succesfuly submitted
  * - false in case of error
  */
-bool btrfs_wq_submit_bio(struct inode *inode, struct bio *bio, int mirror_num,
+bool btrfs_wq_submit_bio(struct btrfs_inode *inode, struct bio *bio, int mirror_num,
 			 u64 dio_file_offset, enum btrfs_wq_submit_cmd cmd)
 {
-	struct btrfs_fs_info *fs_info = BTRFS_I(inode)->root->fs_info;
+	struct btrfs_fs_info *fs_info = inode->root->fs_info;
 	struct async_submit_bio *async;
 
 	async = kmalloc(sizeof(*async), GFP_NOFS);
 	if (!async)
 		return false;
 
-	async->inode = BTRFS_I(inode);
+	async->inode = inode;
 	async->bio = bio;
 	async->mirror_num = mirror_num;
 	async->submit_cmd = cmd;
@@ -784,7 +784,7 @@ void btrfs_submit_metadata_bio(struct inode *inode, struct bio *bio, int mirror_
 	 * happen in parallel across all CPUs.
 	 */
 	if (should_async_write(fs_info, BTRFS_I(inode)) &&
-	    btrfs_wq_submit_bio(inode, bio, mirror_num, 0, WQ_SUBMIT_METADATA))
+	    btrfs_wq_submit_bio(BTRFS_I(inode), bio, mirror_num, 0, WQ_SUBMIT_METADATA))
 		return;
 
 	ret = btree_csum_one_bio(bio);
diff --git a/fs/btrfs/disk-io.h b/fs/btrfs/disk-io.h
index d5b25fa8037b..65cf976b74e8 100644
--- a/fs/btrfs/disk-io.h
+++ b/fs/btrfs/disk-io.h
@@ -120,7 +120,7 @@ enum btrfs_wq_submit_cmd {
 	WQ_SUBMIT_DATA_DIO,
 };
 
-bool btrfs_wq_submit_bio(struct inode *inode, struct bio *bio, int mirror_num,
+bool btrfs_wq_submit_bio(struct btrfs_inode *inode, struct bio *bio, int mirror_num,
 			 u64 dio_file_offset, enum btrfs_wq_submit_cmd cmd);
 blk_status_t btree_submit_bio_start(struct bio *bio);
 int btrfs_alloc_log_tree_node(struct btrfs_trans_handle *trans,
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 2c786075196a..c05b5639337a 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -2757,7 +2757,7 @@ void btrfs_submit_data_write_bio(struct inode *inode, struct bio *bio, int mirro
 	    !test_bit(BTRFS_FS_STATE_NO_CSUMS, &fs_info->fs_state) &&
 	    !btrfs_is_data_reloc_root(bi->root)) {
 		if (!atomic_read(&bi->sync_writers) &&
-		    btrfs_wq_submit_bio(inode, bio, mirror_num, 0, WQ_SUBMIT_DATA))
+		    btrfs_wq_submit_bio(bi, bio, mirror_num, 0, WQ_SUBMIT_DATA))
 			return;
 
 		ret = btrfs_csum_one_bio(bi, bio, (u64)-1, false);
@@ -8013,7 +8013,7 @@ static void btrfs_submit_dio_bio(struct bio *bio, struct inode *inode,
 	if (btrfs_op(bio) == BTRFS_MAP_WRITE) {
 		/* Check btrfs_submit_data_write_bio() for async submit rules */
 		if (async_submit && !atomic_read(&BTRFS_I(inode)->sync_writers) &&
-		    btrfs_wq_submit_bio(inode, bio, 0, file_offset,
+		    btrfs_wq_submit_bio(BTRFS_I(inode), bio, 0, file_offset,
 					WQ_SUBMIT_DATA_DIO))
 			return;
 
-- 
2.37.3


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 09/40] btrfs: pass btrfs_inode to btrfs_submit_metadata_bio
  2022-11-01 20:11 [PATCH 00/40] Parameter and type changes to btrfs_inode David Sterba
                   ` (7 preceding siblings ...)
  2022-11-01 20:11 ` [PATCH 08/40] btrfs: pass btrfs_inode to btrfs_wq_submit_bio David Sterba
@ 2022-11-01 20:11 ` David Sterba
  2022-11-01 20:12 ` [PATCH 10/40] btrfs: pass btrfs_inode to btrfs_submit_data_write_bio David Sterba
                   ` (31 subsequent siblings)
  40 siblings, 0 replies; 46+ messages in thread
From: David Sterba @ 2022-11-01 20:11 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

The function is for internal interfaces so we should use the
btrfs_inode.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/disk-io.c   | 8 ++++----
 fs/btrfs/disk-io.h   | 2 +-
 fs/btrfs/extent_io.c | 2 +-
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index ced90987127b..c86513e70ff3 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -766,9 +766,9 @@ static bool should_async_write(struct btrfs_fs_info *fs_info,
 	return true;
 }
 
-void btrfs_submit_metadata_bio(struct inode *inode, struct bio *bio, int mirror_num)
+void btrfs_submit_metadata_bio(struct btrfs_inode *inode, struct bio *bio, int mirror_num)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = inode->root->fs_info;
 	struct btrfs_bio *bbio = btrfs_bio(bio);
 	blk_status_t ret;
 
@@ -783,8 +783,8 @@ void btrfs_submit_metadata_bio(struct inode *inode, struct bio *bio, int mirror_
 	 * Kthread helpers are used to submit writes so that checksumming can
 	 * happen in parallel across all CPUs.
 	 */
-	if (should_async_write(fs_info, BTRFS_I(inode)) &&
-	    btrfs_wq_submit_bio(BTRFS_I(inode), bio, mirror_num, 0, WQ_SUBMIT_METADATA))
+	if (should_async_write(fs_info, inode) &&
+	    btrfs_wq_submit_bio(inode, bio, mirror_num, 0, WQ_SUBMIT_METADATA))
 		return;
 
 	ret = btree_csum_one_bio(bio);
diff --git a/fs/btrfs/disk-io.h b/fs/btrfs/disk-io.h
index 65cf976b74e8..f2c507fd0e04 100644
--- a/fs/btrfs/disk-io.h
+++ b/fs/btrfs/disk-io.h
@@ -86,7 +86,7 @@ void btrfs_drop_and_free_fs_root(struct btrfs_fs_info *fs_info,
 int btrfs_validate_metadata_buffer(struct btrfs_bio *bbio,
 				   struct page *page, u64 start, u64 end,
 				   int mirror);
-void btrfs_submit_metadata_bio(struct inode *inode, struct bio *bio, int mirror_num);
+void btrfs_submit_metadata_bio(struct btrfs_inode *inode, struct bio *bio, int mirror_num);
 #ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS
 struct btrfs_root *btrfs_alloc_dummy_root(struct btrfs_fs_info *fs_info);
 #endif
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index cc05ae772fa5..e770cbc5cb6a 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -134,7 +134,7 @@ static void submit_one_bio(struct btrfs_bio_ctrl *bio_ctrl)
 	btrfs_bio(bio)->file_offset = page_offset(bv->bv_page) + bv->bv_offset;
 
 	if (!is_data_inode(inode))
-		btrfs_submit_metadata_bio(inode, bio, mirror_num);
+		btrfs_submit_metadata_bio(BTRFS_I(inode), bio, mirror_num);
 	else if (btrfs_op(bio) == BTRFS_MAP_WRITE)
 		btrfs_submit_data_write_bio(inode, bio, mirror_num);
 	else
-- 
2.37.3


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 10/40] btrfs: pass btrfs_inode to btrfs_submit_data_write_bio
  2022-11-01 20:11 [PATCH 00/40] Parameter and type changes to btrfs_inode David Sterba
                   ` (8 preceding siblings ...)
  2022-11-01 20:11 ` [PATCH 09/40] btrfs: pass btrfs_inode to btrfs_submit_metadata_bio David Sterba
@ 2022-11-01 20:12 ` David Sterba
  2022-11-01 20:12 ` [PATCH 11/40] btrfs: pass btrfs_inode to btrfs_submit_data_read_bio David Sterba
                   ` (30 subsequent siblings)
  40 siblings, 0 replies; 46+ messages in thread
From: David Sterba @ 2022-11-01 20:12 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

The function is for internal interfaces so we should use the
btrfs_inode.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/btrfs_inode.h |  2 +-
 fs/btrfs/extent_io.c   |  2 +-
 fs/btrfs/inode.c       | 17 ++++++++---------
 3 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/fs/btrfs/btrfs_inode.h b/fs/btrfs/btrfs_inode.h
index a41d4f953bfa..01fc62d39ed2 100644
--- a/fs/btrfs/btrfs_inode.h
+++ b/fs/btrfs/btrfs_inode.h
@@ -411,7 +411,7 @@ static inline void btrfs_inode_split_flags(u64 inode_item_flags,
 #define CSUM_FMT				"0x%*phN"
 #define CSUM_FMT_VALUE(size, bytes)		size, bytes
 
-void btrfs_submit_data_write_bio(struct inode *inode, struct bio *bio, int mirror_num);
+void btrfs_submit_data_write_bio(struct btrfs_inode *inode, struct bio *bio, int mirror_num);
 void btrfs_submit_data_read_bio(struct inode *inode, struct bio *bio,
 			int mirror_num, enum btrfs_compression_type compress_type);
 void btrfs_submit_dio_repair_bio(struct inode *inode, struct bio *bio, int mirror_num);
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index e770cbc5cb6a..13fba51be32d 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -136,7 +136,7 @@ static void submit_one_bio(struct btrfs_bio_ctrl *bio_ctrl)
 	if (!is_data_inode(inode))
 		btrfs_submit_metadata_bio(BTRFS_I(inode), bio, mirror_num);
 	else if (btrfs_op(bio) == BTRFS_MAP_WRITE)
-		btrfs_submit_data_write_bio(inode, bio, mirror_num);
+		btrfs_submit_data_write_bio(BTRFS_I(inode), bio, mirror_num);
 	else
 		btrfs_submit_data_read_bio(inode, bio, mirror_num,
 					   bio_ctrl->compress_type);
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index c05b5639337a..f10eb3430756 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -2730,14 +2730,13 @@ static blk_status_t extract_ordered_extent(struct btrfs_inode *inode,
 	return errno_to_blk_status(ret);
 }
 
-void btrfs_submit_data_write_bio(struct inode *inode, struct bio *bio, int mirror_num)
+void btrfs_submit_data_write_bio(struct btrfs_inode *inode, struct bio *bio, int mirror_num)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
-	struct btrfs_inode *bi = BTRFS_I(inode);
+	struct btrfs_fs_info *fs_info = inode->root->fs_info;
 	blk_status_t ret;
 
 	if (bio_op(bio) == REQ_OP_ZONE_APPEND) {
-		ret = extract_ordered_extent(bi, bio,
+		ret = extract_ordered_extent(inode, bio,
 				page_offset(bio_first_bvec_all(bio)->bv_page));
 		if (ret) {
 			btrfs_bio_end_io(btrfs_bio(bio), ret);
@@ -2753,14 +2752,14 @@ void btrfs_submit_data_write_bio(struct inode *inode, struct bio *bio, int mirro
 	 * Csum items for reloc roots have already been cloned at this point,
 	 * so they are handled as part of the no-checksum case.
 	 */
-	if (!(bi->flags & BTRFS_INODE_NODATASUM) &&
+	if (!(inode->flags & BTRFS_INODE_NODATASUM) &&
 	    !test_bit(BTRFS_FS_STATE_NO_CSUMS, &fs_info->fs_state) &&
-	    !btrfs_is_data_reloc_root(bi->root)) {
-		if (!atomic_read(&bi->sync_writers) &&
-		    btrfs_wq_submit_bio(bi, bio, mirror_num, 0, WQ_SUBMIT_DATA))
+	    !btrfs_is_data_reloc_root(inode->root)) {
+		if (!atomic_read(&inode->sync_writers) &&
+		    btrfs_wq_submit_bio(inode, bio, mirror_num, 0, WQ_SUBMIT_DATA))
 			return;
 
-		ret = btrfs_csum_one_bio(bi, bio, (u64)-1, false);
+		ret = btrfs_csum_one_bio(inode, bio, (u64)-1, false);
 		if (ret) {
 			btrfs_bio_end_io(btrfs_bio(bio), ret);
 			return;
-- 
2.37.3


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 11/40] btrfs: pass btrfs_inode to btrfs_submit_data_read_bio
  2022-11-01 20:11 [PATCH 00/40] Parameter and type changes to btrfs_inode David Sterba
                   ` (9 preceding siblings ...)
  2022-11-01 20:12 ` [PATCH 10/40] btrfs: pass btrfs_inode to btrfs_submit_data_write_bio David Sterba
@ 2022-11-01 20:12 ` David Sterba
  2022-11-01 20:12 ` [PATCH 12/40] btrfs: pass btrfs_inode to btrfs_submit_dio_repair_bio David Sterba
                   ` (29 subsequent siblings)
  40 siblings, 0 replies; 46+ messages in thread
From: David Sterba @ 2022-11-01 20:12 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

The function is for internal interfaces so we should use the
btrfs_inode.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/btrfs_inode.h | 2 +-
 fs/btrfs/extent_io.c   | 5 +++--
 fs/btrfs/inode.c       | 8 ++++----
 3 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/fs/btrfs/btrfs_inode.h b/fs/btrfs/btrfs_inode.h
index 01fc62d39ed2..5406a2f817b2 100644
--- a/fs/btrfs/btrfs_inode.h
+++ b/fs/btrfs/btrfs_inode.h
@@ -412,7 +412,7 @@ static inline void btrfs_inode_split_flags(u64 inode_item_flags,
 #define CSUM_FMT_VALUE(size, bytes)		size, bytes
 
 void btrfs_submit_data_write_bio(struct btrfs_inode *inode, struct bio *bio, int mirror_num);
-void btrfs_submit_data_read_bio(struct inode *inode, struct bio *bio,
+void btrfs_submit_data_read_bio(struct btrfs_inode *inode, struct bio *bio,
 			int mirror_num, enum btrfs_compression_type compress_type);
 void btrfs_submit_dio_repair_bio(struct inode *inode, struct bio *bio, int mirror_num);
 blk_status_t btrfs_submit_bio_start(struct btrfs_inode *inode, struct bio *bio);
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 13fba51be32d..ac69e5f1605c 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -138,7 +138,7 @@ static void submit_one_bio(struct btrfs_bio_ctrl *bio_ctrl)
 	else if (btrfs_op(bio) == BTRFS_MAP_WRITE)
 		btrfs_submit_data_write_bio(BTRFS_I(inode), bio, mirror_num);
 	else
-		btrfs_submit_data_read_bio(inode, bio, mirror_num,
+		btrfs_submit_data_read_bio(BTRFS_I(inode), bio, mirror_num,
 					   bio_ctrl->compress_type);
 
 	/* The bio is owned by the end_io handler now */
@@ -861,7 +861,8 @@ int btrfs_repair_one_sector(struct inode *inode, struct btrfs_bio *failed_bbio,
 	 * error here.
 	 */
 	if (submit_buffered)
-		btrfs_submit_data_read_bio(inode, repair_bio, failrec->this_mirror, 0);
+		btrfs_submit_data_read_bio(BTRFS_I(inode), repair_bio,
+					   failrec->this_mirror, 0);
 	else
 		btrfs_submit_dio_repair_bio(inode, repair_bio, failrec->this_mirror);
 
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index f10eb3430756..06ae712be423 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -2768,10 +2768,10 @@ void btrfs_submit_data_write_bio(struct btrfs_inode *inode, struct bio *bio, int
 	btrfs_submit_bio(fs_info, bio, mirror_num);
 }
 
-void btrfs_submit_data_read_bio(struct inode *inode, struct bio *bio,
+void btrfs_submit_data_read_bio(struct btrfs_inode *inode, struct bio *bio,
 			int mirror_num, enum btrfs_compression_type compress_type)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = inode->root->fs_info;
 	blk_status_t ret;
 
 	if (compress_type != BTRFS_COMPRESS_NONE) {
@@ -2779,7 +2779,7 @@ void btrfs_submit_data_read_bio(struct inode *inode, struct bio *bio,
 		 * btrfs_submit_compressed_read will handle completing the bio
 		 * if there were any errors, so just return here.
 		 */
-		btrfs_submit_compressed_read(inode, bio, mirror_num);
+		btrfs_submit_compressed_read(&inode->vfs_inode, bio, mirror_num);
 		return;
 	}
 
@@ -2790,7 +2790,7 @@ void btrfs_submit_data_read_bio(struct inode *inode, struct bio *bio,
 	 * Lookup bio sums does extra checks around whether we need to csum or
 	 * not, which is why we ignore skip_sum here.
 	 */
-	ret = btrfs_lookup_bio_sums(inode, bio, NULL);
+	ret = btrfs_lookup_bio_sums(&inode->vfs_inode, bio, NULL);
 	if (ret) {
 		btrfs_bio_end_io(btrfs_bio(bio), ret);
 		return;
-- 
2.37.3


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 12/40] btrfs: pass btrfs_inode to btrfs_submit_dio_repair_bio
  2022-11-01 20:11 [PATCH 00/40] Parameter and type changes to btrfs_inode David Sterba
                   ` (10 preceding siblings ...)
  2022-11-01 20:12 ` [PATCH 11/40] btrfs: pass btrfs_inode to btrfs_submit_data_read_bio David Sterba
@ 2022-11-01 20:12 ` David Sterba
  2022-11-01 20:12 ` [PATCH 13/40] btrfs: pass btrfs_inode to submit_one_bio David Sterba
                   ` (28 subsequent siblings)
  40 siblings, 0 replies; 46+ messages in thread
From: David Sterba @ 2022-11-01 20:12 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

The function is for internal interfaces so we should use the
btrfs_inode.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/btrfs_inode.h | 2 +-
 fs/btrfs/extent_io.c   | 3 ++-
 fs/btrfs/inode.c       | 5 ++---
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/fs/btrfs/btrfs_inode.h b/fs/btrfs/btrfs_inode.h
index 5406a2f817b2..9fe1a11a2eb3 100644
--- a/fs/btrfs/btrfs_inode.h
+++ b/fs/btrfs/btrfs_inode.h
@@ -414,7 +414,7 @@ static inline void btrfs_inode_split_flags(u64 inode_item_flags,
 void btrfs_submit_data_write_bio(struct btrfs_inode *inode, struct bio *bio, int mirror_num);
 void btrfs_submit_data_read_bio(struct btrfs_inode *inode, struct bio *bio,
 			int mirror_num, enum btrfs_compression_type compress_type);
-void btrfs_submit_dio_repair_bio(struct inode *inode, struct bio *bio, int mirror_num);
+void btrfs_submit_dio_repair_bio(struct btrfs_inode *inode, struct bio *bio, int mirror_num);
 blk_status_t btrfs_submit_bio_start(struct btrfs_inode *inode, struct bio *bio);
 blk_status_t btrfs_submit_bio_start_direct_io(struct btrfs_inode *inode,
 					      struct bio *bio,
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index ac69e5f1605c..bddda397e438 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -864,7 +864,8 @@ int btrfs_repair_one_sector(struct inode *inode, struct btrfs_bio *failed_bbio,
 		btrfs_submit_data_read_bio(BTRFS_I(inode), repair_bio,
 					   failrec->this_mirror, 0);
 	else
-		btrfs_submit_dio_repair_bio(inode, repair_bio, failrec->this_mirror);
+		btrfs_submit_dio_repair_bio(BTRFS_I(inode), repair_bio,
+					    failrec->this_mirror);
 
 	return BLK_STS_OK;
 }
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 06ae712be423..477d4db2d14e 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -7919,15 +7919,14 @@ static void btrfs_dio_private_put(struct btrfs_dio_private *dip)
 	bio_endio(&dip->bio);
 }
 
-void btrfs_submit_dio_repair_bio(struct inode *inode, struct bio *bio, int mirror_num)
+void btrfs_submit_dio_repair_bio(struct btrfs_inode *inode, struct bio *bio, int mirror_num)
 {
 	struct btrfs_dio_private *dip = btrfs_bio(bio)->private;
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
 
 	BUG_ON(bio_op(bio) == REQ_OP_WRITE);
 
 	refcount_inc(&dip->refs);
-	btrfs_submit_bio(fs_info, bio, mirror_num);
+	btrfs_submit_bio(inode->root->fs_info, bio, mirror_num);
 }
 
 static blk_status_t btrfs_check_read_dio_bio(struct btrfs_dio_private *dip,
-- 
2.37.3


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 13/40] btrfs: pass btrfs_inode to submit_one_bio
  2022-11-01 20:11 [PATCH 00/40] Parameter and type changes to btrfs_inode David Sterba
                   ` (11 preceding siblings ...)
  2022-11-01 20:12 ` [PATCH 12/40] btrfs: pass btrfs_inode to btrfs_submit_dio_repair_bio David Sterba
@ 2022-11-01 20:12 ` David Sterba
  2022-11-01 20:12 ` [PATCH 14/40] btrfs: pass btrfs_inode to btrfs_repair_one_sector David Sterba
                   ` (27 subsequent siblings)
  40 siblings, 0 replies; 46+ messages in thread
From: David Sterba @ 2022-11-01 20:12 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

The function is for internal interfaces so we should use the
btrfs_inode.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/extent_io.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index bddda397e438..192f604ac7ea 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -117,7 +117,7 @@ static void submit_one_bio(struct btrfs_bio_ctrl *bio_ctrl)
 {
 	struct bio *bio;
 	struct bio_vec *bv;
-	struct inode *inode;
+	struct btrfs_inode *inode;
 	int mirror_num;
 
 	if (!bio_ctrl->bio)
@@ -125,7 +125,7 @@ static void submit_one_bio(struct btrfs_bio_ctrl *bio_ctrl)
 
 	bio = bio_ctrl->bio;
 	bv = bio_first_bvec_all(bio);
-	inode = bv->bv_page->mapping->host;
+	inode = BTRFS_I(bv->bv_page->mapping->host);
 	mirror_num = bio_ctrl->mirror_num;
 
 	/* Caller should ensure the bio has at least some range added */
@@ -133,12 +133,12 @@ static void submit_one_bio(struct btrfs_bio_ctrl *bio_ctrl)
 
 	btrfs_bio(bio)->file_offset = page_offset(bv->bv_page) + bv->bv_offset;
 
-	if (!is_data_inode(inode))
-		btrfs_submit_metadata_bio(BTRFS_I(inode), bio, mirror_num);
+	if (!is_data_inode(&inode->vfs_inode))
+		btrfs_submit_metadata_bio(inode, bio, mirror_num);
 	else if (btrfs_op(bio) == BTRFS_MAP_WRITE)
-		btrfs_submit_data_write_bio(BTRFS_I(inode), bio, mirror_num);
+		btrfs_submit_data_write_bio(inode, bio, mirror_num);
 	else
-		btrfs_submit_data_read_bio(BTRFS_I(inode), bio, mirror_num,
+		btrfs_submit_data_read_bio(inode, bio, mirror_num,
 					   bio_ctrl->compress_type);
 
 	/* The bio is owned by the end_io handler now */
-- 
2.37.3


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 14/40] btrfs: pass btrfs_inode to btrfs_repair_one_sector
  2022-11-01 20:11 [PATCH 00/40] Parameter and type changes to btrfs_inode David Sterba
                   ` (12 preceding siblings ...)
  2022-11-01 20:12 ` [PATCH 13/40] btrfs: pass btrfs_inode to submit_one_bio David Sterba
@ 2022-11-01 20:12 ` David Sterba
  2022-11-01 20:12 ` [PATCH 15/40] btrfs: switch btrfs_dio_private::inode to btrfs_inode David Sterba
                   ` (26 subsequent siblings)
  40 siblings, 0 replies; 46+ messages in thread
From: David Sterba @ 2022-11-01 20:12 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

The function is for internal interfaces so we should use the
btrfs_inode.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/compression.c |  2 +-
 fs/btrfs/extent_io.c   | 17 ++++++++---------
 fs/btrfs/extent_io.h   |  2 +-
 fs/btrfs/inode.c       |  2 +-
 4 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c
index e84764ef250b..7e9135ddaebb 100644
--- a/fs/btrfs/compression.c
+++ b/fs/btrfs/compression.c
@@ -194,7 +194,7 @@ static void end_compressed_bio_read(struct btrfs_bio *bbio)
 			int ret;
 
 			refcount_inc(&cb->pending_ios);
-			ret = btrfs_repair_one_sector(inode, bbio, offset,
+			ret = btrfs_repair_one_sector(BTRFS_I(inode), bbio, offset,
 						      bv.bv_page, bv.bv_offset,
 						      true);
 			if (ret) {
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 192f604ac7ea..05768f7f7872 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -795,13 +795,13 @@ static struct io_failure_record *btrfs_get_io_failure_record(struct inode *inode
 	return failrec;
 }
 
-int btrfs_repair_one_sector(struct inode *inode, struct btrfs_bio *failed_bbio,
+int btrfs_repair_one_sector(struct btrfs_inode *inode, struct btrfs_bio *failed_bbio,
 			    u32 bio_offset, struct page *page, unsigned int pgoff,
 			    bool submit_buffered)
 {
 	u64 start = failed_bbio->file_offset + bio_offset;
 	struct io_failure_record *failrec;
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = inode->root->fs_info;
 	struct bio *failed_bio = &failed_bbio->bio;
 	const int icsum = bio_offset >> fs_info->sectorsize_bits;
 	struct bio *repair_bio;
@@ -812,7 +812,7 @@ int btrfs_repair_one_sector(struct inode *inode, struct btrfs_bio *failed_bbio,
 
 	BUG_ON(bio_op(failed_bio) == REQ_OP_WRITE);
 
-	failrec = btrfs_get_io_failure_record(inode, failed_bbio, bio_offset);
+	failrec = btrfs_get_io_failure_record(&inode->vfs_inode, failed_bbio, bio_offset);
 	if (IS_ERR(failrec))
 		return PTR_ERR(failrec);
 
@@ -830,7 +830,7 @@ int btrfs_repair_one_sector(struct inode *inode, struct btrfs_bio *failed_bbio,
 		btrfs_debug(fs_info,
 			"failed to repair num_copies %d this_mirror %d failed_mirror %d",
 			failrec->num_copies, failrec->this_mirror, failrec->failed_mirror);
-		free_io_failure(BTRFS_I(inode), failrec);
+		free_io_failure(inode, failrec);
 		return -EIO;
 	}
 
@@ -851,7 +851,7 @@ int btrfs_repair_one_sector(struct inode *inode, struct btrfs_bio *failed_bbio,
 	bio_add_page(repair_bio, page, failrec->len, pgoff);
 	repair_bbio->iter = repair_bio->bi_iter;
 
-	btrfs_debug(btrfs_sb(inode->i_sb),
+	btrfs_debug(fs_info,
 		    "repair read error: submitting new read to mirror %d",
 		    failrec->this_mirror);
 
@@ -861,11 +861,10 @@ int btrfs_repair_one_sector(struct inode *inode, struct btrfs_bio *failed_bbio,
 	 * error here.
 	 */
 	if (submit_buffered)
-		btrfs_submit_data_read_bio(BTRFS_I(inode), repair_bio,
+		btrfs_submit_data_read_bio(inode, repair_bio,
 					   failrec->this_mirror, 0);
 	else
-		btrfs_submit_dio_repair_bio(BTRFS_I(inode), repair_bio,
-					    failrec->this_mirror);
+		btrfs_submit_dio_repair_bio(inode, repair_bio, failrec->this_mirror);
 
 	return BLK_STS_OK;
 }
@@ -955,7 +954,7 @@ static void submit_data_read_repair(struct inode *inode,
 			goto next;
 		}
 
-		ret = btrfs_repair_one_sector(inode, failed_bbio,
+		ret = btrfs_repair_one_sector(BTRFS_I(inode), failed_bbio,
 				bio_offset + offset, page, pgoff + offset,
 				true);
 		if (!ret) {
diff --git a/fs/btrfs/extent_io.h b/fs/btrfs/extent_io.h
index b3d4b568fe33..805e262811b4 100644
--- a/fs/btrfs/extent_io.h
+++ b/fs/btrfs/extent_io.h
@@ -268,7 +268,7 @@ struct io_failure_record {
 	int num_copies;
 };
 
-int btrfs_repair_one_sector(struct inode *inode, struct btrfs_bio *failed_bbio,
+int btrfs_repair_one_sector(struct btrfs_inode *inode, struct btrfs_bio *failed_bbio,
 			    u32 bio_offset, struct page *page, unsigned int pgoff,
 			    bool submit_buffered);
 void btrfs_free_io_failure_record(struct btrfs_inode *inode, u64 start, u64 end);
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 477d4db2d14e..594fade31002 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -7952,7 +7952,7 @@ static blk_status_t btrfs_check_read_dio_bio(struct btrfs_dio_private *dip,
 		} else {
 			int ret;
 
-			ret = btrfs_repair_one_sector(inode, bbio, offset,
+			ret = btrfs_repair_one_sector(BTRFS_I(inode), bbio, offset,
 					bv.bv_page, bv.bv_offset, false);
 			if (ret)
 				err = errno_to_blk_status(ret);
-- 
2.37.3


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 15/40] btrfs: switch btrfs_dio_private::inode to btrfs_inode
  2022-11-01 20:11 [PATCH 00/40] Parameter and type changes to btrfs_inode David Sterba
                   ` (13 preceding siblings ...)
  2022-11-01 20:12 ` [PATCH 14/40] btrfs: pass btrfs_inode to btrfs_repair_one_sector David Sterba
@ 2022-11-01 20:12 ` David Sterba
  2022-11-01 20:12 ` [PATCH 16/40] btrfs: pass btrfs_inode to btrfs_submit_dio_bio David Sterba
                   ` (25 subsequent siblings)
  40 siblings, 0 replies; 46+ messages in thread
From: David Sterba @ 2022-11-01 20:12 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

The btrfs_dio_private structure is for internal interfaces so we should
use the btrfs_inode.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/inode.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 594fade31002..652335c0c930 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -84,7 +84,7 @@ struct btrfs_dio_data {
 };
 
 struct btrfs_dio_private {
-	struct inode *inode;
+	struct btrfs_inode *inode;
 
 	/*
 	 * Since DIO can use anonymous page, we cannot use page_offset() to
@@ -7906,11 +7906,11 @@ static void btrfs_dio_private_put(struct btrfs_dio_private *dip)
 		return;
 
 	if (btrfs_op(&dip->bio) == BTRFS_MAP_WRITE) {
-		btrfs_mark_ordered_io_finished(BTRFS_I(dip->inode), NULL,
+		btrfs_mark_ordered_io_finished(dip->inode, NULL,
 					       dip->file_offset, dip->bytes,
 					       !dip->bio.bi_status);
 	} else {
-		unlock_extent(&BTRFS_I(dip->inode)->io_tree,
+		unlock_extent(&dip->inode->io_tree,
 			      dip->file_offset,
 			      dip->file_offset + dip->bytes - 1, NULL);
 	}
@@ -7933,7 +7933,7 @@ static blk_status_t btrfs_check_read_dio_bio(struct btrfs_dio_private *dip,
 					     struct btrfs_bio *bbio,
 					     const bool uptodate)
 {
-	struct inode *inode = dip->inode;
+	struct inode *inode = &dip->inode->vfs_inode;
 	struct btrfs_fs_info *fs_info = BTRFS_I(inode)->root->fs_info;
 	const bool csum = !(BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM);
 	blk_status_t err = BLK_STS_OK;
@@ -7976,9 +7976,9 @@ static void btrfs_end_dio_bio(struct btrfs_bio *bbio)
 	blk_status_t err = bio->bi_status;
 
 	if (err)
-		btrfs_warn(BTRFS_I(dip->inode)->root->fs_info,
+		btrfs_warn(dip->inode->root->fs_info,
 			   "direct IO failed ino %llu rw %d,%u sector %#Lx len %u err no %d",
-			   btrfs_ino(BTRFS_I(dip->inode)), bio_op(bio),
+			   btrfs_ino(dip->inode), bio_op(bio),
 			   bio->bi_opf, bio->bi_iter.bi_sector,
 			   bio->bi_iter.bi_size, err);
 
@@ -7988,7 +7988,7 @@ static void btrfs_end_dio_bio(struct btrfs_bio *bbio)
 	if (err)
 		dip->bio.bi_status = err;
 
-	btrfs_record_physical_zoned(dip->inode, bbio->file_offset, bio);
+	btrfs_record_physical_zoned(&dip->inode->vfs_inode, bbio->file_offset, bio);
 
 	bio_put(bio);
 	btrfs_dio_private_put(dip);
@@ -8055,7 +8055,7 @@ static void btrfs_submit_direct(const struct iomap_iter *iter,
 	struct btrfs_dio_data *dio_data = iter->private;
 	struct extent_map *em = NULL;
 
-	dip->inode = inode;
+	dip->inode = BTRFS_I(inode);
 	dip->file_offset = file_offset;
 	dip->bytes = dio_bio->bi_iter.bi_size;
 	refcount_set(&dip->refs, 1);
-- 
2.37.3


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 16/40] btrfs: pass btrfs_inode to btrfs_submit_dio_bio
  2022-11-01 20:11 [PATCH 00/40] Parameter and type changes to btrfs_inode David Sterba
                   ` (14 preceding siblings ...)
  2022-11-01 20:12 ` [PATCH 15/40] btrfs: switch btrfs_dio_private::inode to btrfs_inode David Sterba
@ 2022-11-01 20:12 ` David Sterba
  2022-11-01 20:12 ` [PATCH 17/40] btrfs: pass btrfs_inode to btrfs_truncate David Sterba
                   ` (24 subsequent siblings)
  40 siblings, 0 replies; 46+ messages in thread
From: David Sterba @ 2022-11-01 20:12 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

The function is for internal interfaces so we should use the
btrfs_inode.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/inode.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 652335c0c930..dbe55974eb82 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -7994,10 +7994,10 @@ static void btrfs_end_dio_bio(struct btrfs_bio *bbio)
 	btrfs_dio_private_put(dip);
 }
 
-static void btrfs_submit_dio_bio(struct bio *bio, struct inode *inode,
+static void btrfs_submit_dio_bio(struct bio *bio, struct btrfs_inode *inode,
 				 u64 file_offset, int async_submit)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = inode->root->fs_info;
 	struct btrfs_dio_private *dip = btrfs_bio(bio)->private;
 	blk_status_t ret;
 
@@ -8005,13 +8005,13 @@ static void btrfs_submit_dio_bio(struct bio *bio, struct inode *inode,
 	if (btrfs_op(bio) == BTRFS_MAP_READ)
 		btrfs_bio(bio)->iter = bio->bi_iter;
 
-	if (BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM)
+	if (inode->flags & BTRFS_INODE_NODATASUM)
 		goto map;
 
 	if (btrfs_op(bio) == BTRFS_MAP_WRITE) {
 		/* Check btrfs_submit_data_write_bio() for async submit rules */
-		if (async_submit && !atomic_read(&BTRFS_I(inode)->sync_writers) &&
-		    btrfs_wq_submit_bio(BTRFS_I(inode), bio, 0, file_offset,
+		if (async_submit && !atomic_read(&inode->sync_writers) &&
+		    btrfs_wq_submit_bio(inode, bio, 0, file_offset,
 					WQ_SUBMIT_DATA_DIO))
 			return;
 
@@ -8019,7 +8019,7 @@ static void btrfs_submit_dio_bio(struct bio *bio, struct inode *inode,
 		 * If we aren't doing async submit, calculate the csum of the
 		 * bio now.
 		 */
-		ret = btrfs_csum_one_bio(BTRFS_I(inode), bio, file_offset, false);
+		ret = btrfs_csum_one_bio(inode, bio, file_offset, false);
 		if (ret) {
 			btrfs_bio_end_io(btrfs_bio(bio), ret);
 			return;
@@ -8141,7 +8141,7 @@ static void btrfs_submit_direct(const struct iomap_iter *iter,
 				async_submit = 1;
 		}
 
-		btrfs_submit_dio_bio(bio, inode, file_offset, async_submit);
+		btrfs_submit_dio_bio(bio, BTRFS_I(inode), file_offset, async_submit);
 
 		dio_data->submitted += clone_len;
 		clone_offset += clone_len;
-- 
2.37.3


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 17/40] btrfs: pass btrfs_inode to btrfs_truncate
  2022-11-01 20:11 [PATCH 00/40] Parameter and type changes to btrfs_inode David Sterba
                   ` (15 preceding siblings ...)
  2022-11-01 20:12 ` [PATCH 16/40] btrfs: pass btrfs_inode to btrfs_submit_dio_bio David Sterba
@ 2022-11-01 20:12 ` David Sterba
  2022-11-01 20:12 ` [PATCH 18/40] btrfs: pass btrfs_inode to btrfs_inode_lock David Sterba
                   ` (23 subsequent siblings)
  40 siblings, 0 replies; 46+ messages in thread
From: David Sterba @ 2022-11-01 20:12 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

The function is for internal interfaces so we should use the
btrfs_inode.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/inode.c | 41 ++++++++++++++++++++---------------------
 1 file changed, 20 insertions(+), 21 deletions(-)

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index dbe55974eb82..b5601d280ef9 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -124,7 +124,7 @@ static const struct file_operations btrfs_dir_file_operations;
 static struct kmem_cache *btrfs_inode_cachep;
 
 static int btrfs_setsize(struct inode *inode, struct iattr *attr);
-static int btrfs_truncate(struct inode *inode, bool skip_writeback);
+static int btrfs_truncate(struct btrfs_inode *inode, bool skip_writeback);
 static noinline int cow_file_range(struct btrfs_inode *inode,
 				   struct page *locked_page,
 				   u64 start, u64 end, int *page_started,
@@ -5269,7 +5269,7 @@ static int btrfs_setsize(struct inode *inode, struct iattr *attr)
 
 		inode_dio_wait(inode);
 
-		ret = btrfs_truncate(inode, newsize == oldsize);
+		ret = btrfs_truncate(BTRFS_I(inode), newsize == oldsize);
 		if (ret && inode->i_nlink) {
 			int err;
 
@@ -8631,16 +8631,16 @@ vm_fault_t btrfs_page_mkwrite(struct vm_fault *vmf)
 	return ret;
 }
 
-static int btrfs_truncate(struct inode *inode, bool skip_writeback)
+static int btrfs_truncate(struct btrfs_inode *inode, bool skip_writeback)
 {
 	struct btrfs_truncate_control control = {
-		.inode = BTRFS_I(inode),
-		.ino = btrfs_ino(BTRFS_I(inode)),
+		.inode = inode,
+		.ino = btrfs_ino(inode),
 		.min_type = BTRFS_EXTENT_DATA_KEY,
 		.clear_extent_range = true,
 	};
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
-	struct btrfs_root *root = BTRFS_I(inode)->root;
+	struct btrfs_root *root = inode->root;
+	struct btrfs_fs_info *fs_info = root->fs_info;
 	struct btrfs_block_rsv *rsv;
 	int ret;
 	struct btrfs_trans_handle *trans;
@@ -8648,7 +8648,8 @@ static int btrfs_truncate(struct inode *inode, bool skip_writeback)
 	u64 min_size = btrfs_calc_metadata_size(fs_info, 1);
 
 	if (!skip_writeback) {
-		ret = btrfs_wait_ordered_range(inode, inode->i_size & (~mask),
+		ret = btrfs_wait_ordered_range(&inode->vfs_inode,
+					       inode->vfs_inode.i_size & (~mask),
 					       (u64)-1);
 		if (ret)
 			return ret;
@@ -8707,34 +8708,32 @@ static int btrfs_truncate(struct inode *inode, bool skip_writeback)
 
 	while (1) {
 		struct extent_state *cached_state = NULL;
-		const u64 new_size = inode->i_size;
+		const u64 new_size = inode->vfs_inode.i_size;
 		const u64 lock_start = ALIGN_DOWN(new_size, fs_info->sectorsize);
 
 		control.new_size = new_size;
-		lock_extent(&BTRFS_I(inode)->io_tree, lock_start, (u64)-1,
-				 &cached_state);
+		lock_extent(&inode->io_tree, lock_start, (u64)-1, &cached_state);
 		/*
 		 * We want to drop from the next block forward in case this new
 		 * size is not block aligned since we will be keeping the last
 		 * block of the extent just the way it is.
 		 */
-		btrfs_drop_extent_map_range(BTRFS_I(inode),
+		btrfs_drop_extent_map_range(inode,
 					    ALIGN(new_size, fs_info->sectorsize),
 					    (u64)-1, false);
 
 		ret = btrfs_truncate_inode_items(trans, root, &control);
 
-		inode_sub_bytes(inode, control.sub_bytes);
-		btrfs_inode_safe_disk_i_size_write(BTRFS_I(inode), control.last_size);
+		inode_sub_bytes(&inode->vfs_inode, control.sub_bytes);
+		btrfs_inode_safe_disk_i_size_write(inode, control.last_size);
 
-		unlock_extent(&BTRFS_I(inode)->io_tree, lock_start, (u64)-1,
-			      &cached_state);
+		unlock_extent(&inode->io_tree, lock_start, (u64)-1, &cached_state);
 
 		trans->block_rsv = &fs_info->trans_block_rsv;
 		if (ret != -ENOSPC && ret != -EAGAIN)
 			break;
 
-		ret = btrfs_update_inode(trans, root, BTRFS_I(inode));
+		ret = btrfs_update_inode(trans, root, inode);
 		if (ret)
 			break;
 
@@ -8765,7 +8764,7 @@ static int btrfs_truncate(struct inode *inode, bool skip_writeback)
 		btrfs_end_transaction(trans);
 		btrfs_btree_balance_dirty(fs_info);
 
-		ret = btrfs_truncate_block(BTRFS_I(inode), inode->i_size, 0, 0);
+		ret = btrfs_truncate_block(inode, inode->vfs_inode.i_size, 0, 0);
 		if (ret)
 			goto out;
 		trans = btrfs_start_transaction(root, 1);
@@ -8773,14 +8772,14 @@ static int btrfs_truncate(struct inode *inode, bool skip_writeback)
 			ret = PTR_ERR(trans);
 			goto out;
 		}
-		btrfs_inode_safe_disk_i_size_write(BTRFS_I(inode), 0);
+		btrfs_inode_safe_disk_i_size_write(inode, 0);
 	}
 
 	if (trans) {
 		int ret2;
 
 		trans->block_rsv = &fs_info->trans_block_rsv;
-		ret2 = btrfs_update_inode(trans, root, BTRFS_I(inode));
+		ret2 = btrfs_update_inode(trans, root, inode);
 		if (ret2 && !ret)
 			ret = ret2;
 
@@ -8806,7 +8805,7 @@ static int btrfs_truncate(struct inode *inode, bool skip_writeback)
 	 * extents beyond i_size to drop.
 	 */
 	if (control.extents_found > 0)
-		btrfs_set_inode_full_sync(BTRFS_I(inode));
+		btrfs_set_inode_full_sync(inode);
 
 	return ret;
 }
-- 
2.37.3


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 18/40] btrfs: pass btrfs_inode to btrfs_inode_lock
  2022-11-01 20:11 [PATCH 00/40] Parameter and type changes to btrfs_inode David Sterba
                   ` (16 preceding siblings ...)
  2022-11-01 20:12 ` [PATCH 17/40] btrfs: pass btrfs_inode to btrfs_truncate David Sterba
@ 2022-11-01 20:12 ` David Sterba
  2022-11-01 20:12 ` [PATCH 19/40] btrfs: pass btrfs_inode to btrfs_inode_unlock David Sterba
                   ` (22 subsequent siblings)
  40 siblings, 0 replies; 46+ messages in thread
From: David Sterba @ 2022-11-01 20:12 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

The function is for internal interfaces so we should use the
btrfs_inode.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/btrfs_inode.h   |  2 +-
 fs/btrfs/defrag.c        |  4 ++--
 fs/btrfs/delayed-inode.c |  2 +-
 fs/btrfs/file.c          | 16 ++++++++--------
 fs/btrfs/inode.c         | 14 +++++++-------
 fs/btrfs/ioctl.c         |  2 +-
 fs/btrfs/reflink.c       |  2 +-
 fs/btrfs/relocation.c    |  2 +-
 8 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/fs/btrfs/btrfs_inode.h b/fs/btrfs/btrfs_inode.h
index 9fe1a11a2eb3..a06d1c0a0cc2 100644
--- a/fs/btrfs/btrfs_inode.h
+++ b/fs/btrfs/btrfs_inode.h
@@ -545,7 +545,7 @@ enum btrfs_ilock_type {
 	ENUM_BIT(BTRFS_ILOCK_MMAP),
 };
 
-int btrfs_inode_lock(struct inode *inode, unsigned int ilock_flags);
+int btrfs_inode_lock(struct btrfs_inode *inode, unsigned int ilock_flags);
 void btrfs_inode_unlock(struct inode *inode, unsigned int ilock_flags);
 void btrfs_update_inode_bytes(struct btrfs_inode *inode, const u64 add_bytes,
 			      const u64 del_bytes);
diff --git a/fs/btrfs/defrag.c b/fs/btrfs/defrag.c
index 919dfe0f7e50..6aade4838927 100644
--- a/fs/btrfs/defrag.c
+++ b/fs/btrfs/defrag.c
@@ -1295,7 +1295,7 @@ int btrfs_defrag_file(struct inode *inode, struct file_ra_state *ra,
 			       (SZ_256K >> PAGE_SHIFT)) << PAGE_SHIFT) - 1;
 		cluster_end = min(cluster_end, last_byte);
 
-		btrfs_inode_lock(inode, 0);
+		btrfs_inode_lock(BTRFS_I(inode), 0);
 		if (IS_SWAPFILE(inode)) {
 			ret = -ETXTBSY;
 			btrfs_inode_unlock(inode, 0);
@@ -1351,7 +1351,7 @@ int btrfs_defrag_file(struct inode *inode, struct file_ra_state *ra,
 		ret = sectors_defragged;
 	}
 	if (do_compress) {
-		btrfs_inode_lock(inode, 0);
+		btrfs_inode_lock(BTRFS_I(inode), 0);
 		BTRFS_I(inode)->defrag_compress = BTRFS_COMPRESS_NONE;
 		btrfs_inode_unlock(inode, 0);
 	}
diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
index c024f97de9e0..4edf44d8cd9e 100644
--- a/fs/btrfs/delayed-inode.c
+++ b/fs/btrfs/delayed-inode.c
@@ -1647,7 +1647,7 @@ bool btrfs_readdir_get_delayed_items(struct inode *inode,
 	 * item->readdir_list.
 	 */
 	btrfs_inode_unlock(inode, BTRFS_ILOCK_SHARED);
-	btrfs_inode_lock(inode, 0);
+	btrfs_inode_lock(BTRFS_I(inode), 0);
 
 	mutex_lock(&delayed_node->mutex);
 	item = __btrfs_first_delayed_insertion_item(delayed_node);
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index b7855f794ba6..d498984c7212 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -1193,7 +1193,7 @@ static noinline ssize_t btrfs_buffered_write(struct kiocb *iocb,
 	if (nowait)
 		ilock_flags |= BTRFS_ILOCK_TRY;
 
-	ret = btrfs_inode_lock(inode, ilock_flags);
+	ret = btrfs_inode_lock(BTRFS_I(inode), ilock_flags);
 	if (ret < 0)
 		return ret;
 
@@ -1463,7 +1463,7 @@ static ssize_t btrfs_direct_write(struct kiocb *iocb, struct iov_iter *from)
 		ilock_flags |= BTRFS_ILOCK_SHARED;
 
 relock:
-	err = btrfs_inode_lock(inode, ilock_flags);
+	err = btrfs_inode_lock(BTRFS_I(inode), ilock_flags);
 	if (err < 0)
 		return err;
 
@@ -1611,7 +1611,7 @@ static ssize_t btrfs_encoded_write(struct kiocb *iocb, struct iov_iter *from,
 	loff_t count;
 	ssize_t ret;
 
-	btrfs_inode_lock(inode, 0);
+	btrfs_inode_lock(BTRFS_I(inode), 0);
 	count = encoded->len;
 	ret = generic_write_checks_count(iocb, &count);
 	if (ret == 0 && count != encoded->len) {
@@ -1801,7 +1801,7 @@ int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
 	if (ret)
 		goto out;
 
-	btrfs_inode_lock(inode, BTRFS_ILOCK_MMAP);
+	btrfs_inode_lock(BTRFS_I(inode), BTRFS_ILOCK_MMAP);
 
 	atomic_inc(&root->log_batch);
 
@@ -2591,7 +2591,7 @@ static int btrfs_punch_hole(struct file *file, loff_t offset, loff_t len)
 	bool truncated_block = false;
 	bool updated_inode = false;
 
-	btrfs_inode_lock(inode, BTRFS_ILOCK_MMAP);
+	btrfs_inode_lock(BTRFS_I(inode), BTRFS_ILOCK_MMAP);
 
 	ret = btrfs_wait_ordered_range(inode, offset, len);
 	if (ret)
@@ -3049,7 +3049,7 @@ static long btrfs_fallocate(struct file *file, int mode,
 	if (mode & FALLOC_FL_PUNCH_HOLE)
 		return btrfs_punch_hole(file, offset, len);
 
-	btrfs_inode_lock(inode, BTRFS_ILOCK_MMAP);
+	btrfs_inode_lock(BTRFS_I(inode), BTRFS_ILOCK_MMAP);
 
 	if (!(mode & FALLOC_FL_KEEP_SIZE) && offset + len > inode->i_size) {
 		ret = inode_newsize_ok(inode, offset + len);
@@ -3686,7 +3686,7 @@ static loff_t btrfs_file_llseek(struct file *file, loff_t offset, int whence)
 		return generic_file_llseek(file, offset, whence);
 	case SEEK_DATA:
 	case SEEK_HOLE:
-		btrfs_inode_lock(inode, BTRFS_ILOCK_SHARED);
+		btrfs_inode_lock(BTRFS_I(inode), BTRFS_ILOCK_SHARED);
 		offset = find_desired_extent(BTRFS_I(inode), offset, whence);
 		btrfs_inode_unlock(inode, BTRFS_ILOCK_SHARED);
 		break;
@@ -3743,7 +3743,7 @@ static ssize_t btrfs_direct_read(struct kiocb *iocb, struct iov_iter *to)
 	if (check_direct_read(btrfs_sb(inode->i_sb), to, iocb->ki_pos))
 		return 0;
 
-	btrfs_inode_lock(inode, BTRFS_ILOCK_SHARED);
+	btrfs_inode_lock(BTRFS_I(inode), BTRFS_ILOCK_SHARED);
 again:
 	/*
 	 * This is similar to what we do for direct IO writes, see the comment
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index b5601d280ef9..53cbe21f45b6 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -172,27 +172,27 @@ static void __cold btrfs_print_data_csum_error(struct btrfs_inode *inode,
  *		     return -EAGAIN
  * BTRFS_ILOCK_MMAP - acquire a write lock on the i_mmap_lock
  */
-int btrfs_inode_lock(struct inode *inode, unsigned int ilock_flags)
+int btrfs_inode_lock(struct btrfs_inode *inode, unsigned int ilock_flags)
 {
 	if (ilock_flags & BTRFS_ILOCK_SHARED) {
 		if (ilock_flags & BTRFS_ILOCK_TRY) {
-			if (!inode_trylock_shared(inode))
+			if (!inode_trylock_shared(&inode->vfs_inode))
 				return -EAGAIN;
 			else
 				return 0;
 		}
-		inode_lock_shared(inode);
+		inode_lock_shared(&inode->vfs_inode);
 	} else {
 		if (ilock_flags & BTRFS_ILOCK_TRY) {
-			if (!inode_trylock(inode))
+			if (!inode_trylock(&inode->vfs_inode))
 				return -EAGAIN;
 			else
 				return 0;
 		}
-		inode_lock(inode);
+		inode_lock(&inode->vfs_inode);
 	}
 	if (ilock_flags & BTRFS_ILOCK_MMAP)
-		down_write(&BTRFS_I(inode)->i_mmap_lock);
+		down_write(&inode->i_mmap_lock);
 	return 0;
 }
 
@@ -10528,7 +10528,7 @@ ssize_t btrfs_encoded_read(struct kiocb *iocb, struct iov_iter *iter,
 
 	file_accessed(iocb->ki_filp);
 
-	btrfs_inode_lock(&inode->vfs_inode, BTRFS_ILOCK_SHARED);
+	btrfs_inode_lock(inode, BTRFS_ILOCK_SHARED);
 
 	if (iocb->ki_pos >= inode->vfs_inode.i_size) {
 		btrfs_inode_unlock(&inode->vfs_inode, BTRFS_ILOCK_SHARED);
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 9c1cb5113178..20fd8a6c6fca 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -2525,7 +2525,7 @@ static noinline int btrfs_ioctl_snap_destroy(struct file *file,
 		goto out_dput;
 	}
 
-	btrfs_inode_lock(inode, 0);
+	btrfs_inode_lock(BTRFS_I(inode), 0);
 	err = btrfs_delete_subvolume(dir, dentry);
 	btrfs_inode_unlock(inode, 0);
 	if (!err)
diff --git a/fs/btrfs/reflink.c b/fs/btrfs/reflink.c
index 9d728107536e..c62c7fdd55d9 100644
--- a/fs/btrfs/reflink.c
+++ b/fs/btrfs/reflink.c
@@ -893,7 +893,7 @@ loff_t btrfs_remap_file_range(struct file *src_file, loff_t off,
 		return -EINVAL;
 
 	if (same_inode) {
-		btrfs_inode_lock(src_inode, BTRFS_ILOCK_MMAP);
+		btrfs_inode_lock(BTRFS_I(src_inode), BTRFS_ILOCK_MMAP);
 	} else {
 		lock_two_nondirectories(src_inode, dst_inode);
 		btrfs_double_mmap_lock(src_inode, dst_inode);
diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index d119986d1599..773295d5da6d 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -2874,7 +2874,7 @@ static noinline_for_stack int prealloc_file_extent_cluster(
 	if (ret)
 		return ret;
 
-	btrfs_inode_lock(&inode->vfs_inode, 0);
+	btrfs_inode_lock(inode, 0);
 	for (nr = 0; nr < cluster->nr; nr++) {
 		struct extent_state *cached_state = NULL;
 
-- 
2.37.3


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 19/40] btrfs: pass btrfs_inode to btrfs_inode_unlock
  2022-11-01 20:11 [PATCH 00/40] Parameter and type changes to btrfs_inode David Sterba
                   ` (17 preceding siblings ...)
  2022-11-01 20:12 ` [PATCH 18/40] btrfs: pass btrfs_inode to btrfs_inode_lock David Sterba
@ 2022-11-01 20:12 ` David Sterba
  2022-11-01 20:12 ` [PATCH 20/40] btrfs: pass btrfs_inode to btrfs_dirty_inode David Sterba
                   ` (21 subsequent siblings)
  40 siblings, 0 replies; 46+ messages in thread
From: David Sterba @ 2022-11-01 20:12 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

The function is for internal interfaces so we should use the
btrfs_inode.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/btrfs_inode.h   |  2 +-
 fs/btrfs/defrag.c        |  8 ++++----
 fs/btrfs/delayed-inode.c |  2 +-
 fs/btrfs/file.c          | 32 ++++++++++++++++----------------
 fs/btrfs/inode.c         | 18 +++++++++---------
 fs/btrfs/ioctl.c         |  6 +++---
 fs/btrfs/reflink.c       |  2 +-
 fs/btrfs/relocation.c    |  2 +-
 8 files changed, 36 insertions(+), 36 deletions(-)

diff --git a/fs/btrfs/btrfs_inode.h b/fs/btrfs/btrfs_inode.h
index a06d1c0a0cc2..279bbbc59dc6 100644
--- a/fs/btrfs/btrfs_inode.h
+++ b/fs/btrfs/btrfs_inode.h
@@ -546,7 +546,7 @@ enum btrfs_ilock_type {
 };
 
 int btrfs_inode_lock(struct btrfs_inode *inode, unsigned int ilock_flags);
-void btrfs_inode_unlock(struct inode *inode, unsigned int ilock_flags);
+void btrfs_inode_unlock(struct btrfs_inode *inode, unsigned int ilock_flags);
 void btrfs_update_inode_bytes(struct btrfs_inode *inode, const u64 add_bytes,
 			      const u64 del_bytes);
 void btrfs_assert_inode_range_clean(struct btrfs_inode *inode, u64 start, u64 end);
diff --git a/fs/btrfs/defrag.c b/fs/btrfs/defrag.c
index 6aade4838927..0a3c261b69c9 100644
--- a/fs/btrfs/defrag.c
+++ b/fs/btrfs/defrag.c
@@ -1298,11 +1298,11 @@ int btrfs_defrag_file(struct inode *inode, struct file_ra_state *ra,
 		btrfs_inode_lock(BTRFS_I(inode), 0);
 		if (IS_SWAPFILE(inode)) {
 			ret = -ETXTBSY;
-			btrfs_inode_unlock(inode, 0);
+			btrfs_inode_unlock(BTRFS_I(inode), 0);
 			break;
 		}
 		if (!(inode->i_sb->s_flags & SB_ACTIVE)) {
-			btrfs_inode_unlock(inode, 0);
+			btrfs_inode_unlock(BTRFS_I(inode), 0);
 			break;
 		}
 		if (do_compress)
@@ -1315,7 +1315,7 @@ int btrfs_defrag_file(struct inode *inode, struct file_ra_state *ra,
 		if (sectors_defragged > prev_sectors_defragged)
 			balance_dirty_pages_ratelimited(inode->i_mapping);
 
-		btrfs_inode_unlock(inode, 0);
+		btrfs_inode_unlock(BTRFS_I(inode), 0);
 		if (ret < 0)
 			break;
 		cur = max(cluster_end + 1, last_scanned);
@@ -1353,7 +1353,7 @@ int btrfs_defrag_file(struct inode *inode, struct file_ra_state *ra,
 	if (do_compress) {
 		btrfs_inode_lock(BTRFS_I(inode), 0);
 		BTRFS_I(inode)->defrag_compress = BTRFS_COMPRESS_NONE;
-		btrfs_inode_unlock(inode, 0);
+		btrfs_inode_unlock(BTRFS_I(inode), 0);
 	}
 	return ret;
 }
diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
index 4edf44d8cd9e..0095c6e4c3d1 100644
--- a/fs/btrfs/delayed-inode.c
+++ b/fs/btrfs/delayed-inode.c
@@ -1646,7 +1646,7 @@ bool btrfs_readdir_get_delayed_items(struct inode *inode,
 	 * We can only do one readdir with delayed items at a time because of
 	 * item->readdir_list.
 	 */
-	btrfs_inode_unlock(inode, BTRFS_ILOCK_SHARED);
+	btrfs_inode_unlock(BTRFS_I(inode), BTRFS_ILOCK_SHARED);
 	btrfs_inode_lock(BTRFS_I(inode), 0);
 
 	mutex_lock(&delayed_node->mutex);
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index d498984c7212..5de89c1c6789 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -1423,7 +1423,7 @@ static noinline ssize_t btrfs_buffered_write(struct kiocb *iocb,
 		iocb->ki_pos += num_written;
 	}
 out:
-	btrfs_inode_unlock(inode, ilock_flags);
+	btrfs_inode_unlock(BTRFS_I(inode), ilock_flags);
 	return num_written ? num_written : ret;
 }
 
@@ -1469,13 +1469,13 @@ static ssize_t btrfs_direct_write(struct kiocb *iocb, struct iov_iter *from)
 
 	err = generic_write_checks(iocb, from);
 	if (err <= 0) {
-		btrfs_inode_unlock(inode, ilock_flags);
+		btrfs_inode_unlock(BTRFS_I(inode), ilock_flags);
 		return err;
 	}
 
 	err = btrfs_write_check(iocb, from, err);
 	if (err < 0) {
-		btrfs_inode_unlock(inode, ilock_flags);
+		btrfs_inode_unlock(BTRFS_I(inode), ilock_flags);
 		goto out;
 	}
 
@@ -1486,13 +1486,13 @@ static ssize_t btrfs_direct_write(struct kiocb *iocb, struct iov_iter *from)
 	 */
 	if ((ilock_flags & BTRFS_ILOCK_SHARED) &&
 	    pos + iov_iter_count(from) > i_size_read(inode)) {
-		btrfs_inode_unlock(inode, ilock_flags);
+		btrfs_inode_unlock(BTRFS_I(inode), ilock_flags);
 		ilock_flags &= ~BTRFS_ILOCK_SHARED;
 		goto relock;
 	}
 
 	if (check_direct_IO(fs_info, from, pos)) {
-		btrfs_inode_unlock(inode, ilock_flags);
+		btrfs_inode_unlock(BTRFS_I(inode), ilock_flags);
 		goto buffered;
 	}
 
@@ -1523,7 +1523,7 @@ static ssize_t btrfs_direct_write(struct kiocb *iocb, struct iov_iter *from)
 	 * iocb, and that needs to lock the inode. So unlock it before calling
 	 * iomap_dio_complete() to avoid a deadlock.
 	 */
-	btrfs_inode_unlock(inode, ilock_flags);
+	btrfs_inode_unlock(BTRFS_I(inode), ilock_flags);
 
 	if (IS_ERR_OR_NULL(dio))
 		err = PTR_ERR_OR_ZERO(dio);
@@ -1630,7 +1630,7 @@ static ssize_t btrfs_encoded_write(struct kiocb *iocb, struct iov_iter *from,
 
 	ret = btrfs_do_encoded_write(iocb, from, encoded);
 out:
-	btrfs_inode_unlock(inode, 0);
+	btrfs_inode_unlock(BTRFS_I(inode), 0);
 	return ret;
 }
 
@@ -1825,7 +1825,7 @@ int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
 	 */
 	ret = start_ordered_ops(inode, start, end);
 	if (ret) {
-		btrfs_inode_unlock(inode, BTRFS_ILOCK_MMAP);
+		btrfs_inode_unlock(BTRFS_I(inode), BTRFS_ILOCK_MMAP);
 		goto out;
 	}
 
@@ -1928,7 +1928,7 @@ int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
 	 * file again, but that will end up using the synchronization
 	 * inside btrfs_sync_log to keep things safe.
 	 */
-	btrfs_inode_unlock(inode, BTRFS_ILOCK_MMAP);
+	btrfs_inode_unlock(BTRFS_I(inode), BTRFS_ILOCK_MMAP);
 
 	if (ret == BTRFS_NO_LOG_SYNC) {
 		ret = btrfs_end_transaction(trans);
@@ -1996,7 +1996,7 @@ int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
 
 out_release_extents:
 	btrfs_release_log_ctx_extents(&ctx);
-	btrfs_inode_unlock(inode, BTRFS_ILOCK_MMAP);
+	btrfs_inode_unlock(BTRFS_I(inode), BTRFS_ILOCK_MMAP);
 	goto out;
 }
 
@@ -2639,7 +2639,7 @@ static int btrfs_punch_hole(struct file *file, loff_t offset, loff_t len)
 		truncated_block = true;
 		ret = btrfs_truncate_block(BTRFS_I(inode), offset, 0, 0);
 		if (ret) {
-			btrfs_inode_unlock(inode, BTRFS_ILOCK_MMAP);
+			btrfs_inode_unlock(BTRFS_I(inode), BTRFS_ILOCK_MMAP);
 			return ret;
 		}
 	}
@@ -2738,7 +2738,7 @@ static int btrfs_punch_hole(struct file *file, loff_t offset, loff_t len)
 				ret = ret2;
 		}
 	}
-	btrfs_inode_unlock(inode, BTRFS_ILOCK_MMAP);
+	btrfs_inode_unlock(BTRFS_I(inode), BTRFS_ILOCK_MMAP);
 	return ret;
 }
 
@@ -3099,7 +3099,7 @@ static long btrfs_fallocate(struct file *file, int mode,
 
 	if (mode & FALLOC_FL_ZERO_RANGE) {
 		ret = btrfs_zero_range(inode, offset, len, mode);
-		btrfs_inode_unlock(inode, BTRFS_ILOCK_MMAP);
+		btrfs_inode_unlock(BTRFS_I(inode), BTRFS_ILOCK_MMAP);
 		return ret;
 	}
 
@@ -3197,7 +3197,7 @@ static long btrfs_fallocate(struct file *file, int mode,
 	unlock_extent(&BTRFS_I(inode)->io_tree, alloc_start, locked_end,
 		      &cached_state);
 out:
-	btrfs_inode_unlock(inode, BTRFS_ILOCK_MMAP);
+	btrfs_inode_unlock(BTRFS_I(inode), BTRFS_ILOCK_MMAP);
 	extent_changeset_free(data_reserved);
 	return ret;
 }
@@ -3688,7 +3688,7 @@ static loff_t btrfs_file_llseek(struct file *file, loff_t offset, int whence)
 	case SEEK_HOLE:
 		btrfs_inode_lock(BTRFS_I(inode), BTRFS_ILOCK_SHARED);
 		offset = find_desired_extent(BTRFS_I(inode), offset, whence);
-		btrfs_inode_unlock(inode, BTRFS_ILOCK_SHARED);
+		btrfs_inode_unlock(BTRFS_I(inode), BTRFS_ILOCK_SHARED);
 		break;
 	}
 
@@ -3792,7 +3792,7 @@ static ssize_t btrfs_direct_read(struct kiocb *iocb, struct iov_iter *to)
 			goto again;
 		}
 	}
-	btrfs_inode_unlock(inode, BTRFS_ILOCK_SHARED);
+	btrfs_inode_unlock(BTRFS_I(inode), BTRFS_ILOCK_SHARED);
 	return ret < 0 ? ret : read;
 }
 
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 53cbe21f45b6..977def66afab 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -202,14 +202,14 @@ int btrfs_inode_lock(struct btrfs_inode *inode, unsigned int ilock_flags)
  * ilock_flags should contain the same bits set as passed to btrfs_inode_lock()
  * to decide whether the lock acquired is shared or exclusive.
  */
-void btrfs_inode_unlock(struct inode *inode, unsigned int ilock_flags)
+void btrfs_inode_unlock(struct btrfs_inode *inode, unsigned int ilock_flags)
 {
 	if (ilock_flags & BTRFS_ILOCK_MMAP)
-		up_write(&BTRFS_I(inode)->i_mmap_lock);
+		up_write(&inode->i_mmap_lock);
 	if (ilock_flags & BTRFS_ILOCK_SHARED)
-		inode_unlock_shared(inode);
+		inode_unlock_shared(&inode->vfs_inode);
 	else
-		inode_unlock(inode);
+		inode_unlock(&inode->vfs_inode);
 }
 
 /*
@@ -10276,7 +10276,7 @@ static ssize_t btrfs_encoded_read_inline(
 	read_extent_buffer(leaf, tmp, ptr, count);
 	btrfs_release_path(path);
 	unlock_extent(io_tree, start, lockend, cached_state);
-	btrfs_inode_unlock(&inode->vfs_inode, BTRFS_ILOCK_SHARED);
+	btrfs_inode_unlock(inode, BTRFS_ILOCK_SHARED);
 	*unlocked = true;
 
 	ret = copy_to_iter(tmp, count, iter);
@@ -10479,7 +10479,7 @@ static ssize_t btrfs_encoded_read_regular(struct kiocb *iocb,
 		goto out;
 
 	unlock_extent(io_tree, start, lockend, cached_state);
-	btrfs_inode_unlock(&inode->vfs_inode, BTRFS_ILOCK_SHARED);
+	btrfs_inode_unlock(inode, BTRFS_ILOCK_SHARED);
 	*unlocked = true;
 
 	if (compressed) {
@@ -10531,7 +10531,7 @@ ssize_t btrfs_encoded_read(struct kiocb *iocb, struct iov_iter *iter,
 	btrfs_inode_lock(inode, BTRFS_ILOCK_SHARED);
 
 	if (iocb->ki_pos >= inode->vfs_inode.i_size) {
-		btrfs_inode_unlock(&inode->vfs_inode, BTRFS_ILOCK_SHARED);
+		btrfs_inode_unlock(inode, BTRFS_ILOCK_SHARED);
 		return 0;
 	}
 	start = ALIGN_DOWN(iocb->ki_pos, fs_info->sectorsize);
@@ -10629,7 +10629,7 @@ ssize_t btrfs_encoded_read(struct kiocb *iocb, struct iov_iter *iter,
 
 	if (disk_bytenr == EXTENT_MAP_HOLE) {
 		unlock_extent(io_tree, start, lockend, &cached_state);
-		btrfs_inode_unlock(&inode->vfs_inode, BTRFS_ILOCK_SHARED);
+		btrfs_inode_unlock(inode, BTRFS_ILOCK_SHARED);
 		unlocked = true;
 		ret = iov_iter_zero(count, iter);
 		if (ret != count)
@@ -10652,7 +10652,7 @@ ssize_t btrfs_encoded_read(struct kiocb *iocb, struct iov_iter *iter,
 		unlock_extent(io_tree, start, lockend, &cached_state);
 out_unlock_inode:
 	if (!unlocked)
-		btrfs_inode_unlock(&inode->vfs_inode, BTRFS_ILOCK_SHARED);
+		btrfs_inode_unlock(inode, BTRFS_ILOCK_SHARED);
 	return ret;
 }
 
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 20fd8a6c6fca..0873eae20f63 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -1002,7 +1002,7 @@ static noinline int btrfs_mksubvol(const struct path *parent,
 out_dput:
 	dput(dentry);
 out_unlock:
-	btrfs_inode_unlock(dir, 0);
+	btrfs_inode_unlock(BTRFS_I(dir), 0);
 	return error;
 }
 
@@ -2527,14 +2527,14 @@ static noinline int btrfs_ioctl_snap_destroy(struct file *file,
 
 	btrfs_inode_lock(BTRFS_I(inode), 0);
 	err = btrfs_delete_subvolume(dir, dentry);
-	btrfs_inode_unlock(inode, 0);
+	btrfs_inode_unlock(BTRFS_I(inode), 0);
 	if (!err)
 		d_delete_notify(dir, dentry);
 
 out_dput:
 	dput(dentry);
 out_unlock_dir:
-	btrfs_inode_unlock(dir, 0);
+	btrfs_inode_unlock(BTRFS_I(dir), 0);
 free_subvol_name:
 	kfree(subvol_name_ptr);
 free_parent:
diff --git a/fs/btrfs/reflink.c b/fs/btrfs/reflink.c
index c62c7fdd55d9..0474bbe39da7 100644
--- a/fs/btrfs/reflink.c
+++ b/fs/btrfs/reflink.c
@@ -911,7 +911,7 @@ loff_t btrfs_remap_file_range(struct file *src_file, loff_t off,
 
 out_unlock:
 	if (same_inode) {
-		btrfs_inode_unlock(src_inode, BTRFS_ILOCK_MMAP);
+		btrfs_inode_unlock(BTRFS_I(src_inode), BTRFS_ILOCK_MMAP);
 	} else {
 		btrfs_double_mmap_unlock(src_inode, dst_inode);
 		unlock_two_nondirectories(src_inode, dst_inode);
diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index 773295d5da6d..1a337602723c 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -2894,7 +2894,7 @@ static noinline_for_stack int prealloc_file_extent_cluster(
 		if (ret)
 			break;
 	}
-	btrfs_inode_unlock(&inode->vfs_inode, 0);
+	btrfs_inode_unlock(inode, 0);
 
 	if (cur_offset < prealloc_end)
 		btrfs_free_reserved_data_space_noquota(inode->root->fs_info,
-- 
2.37.3


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 20/40] btrfs: pass btrfs_inode to btrfs_dirty_inode
  2022-11-01 20:11 [PATCH 00/40] Parameter and type changes to btrfs_inode David Sterba
                   ` (18 preceding siblings ...)
  2022-11-01 20:12 ` [PATCH 19/40] btrfs: pass btrfs_inode to btrfs_inode_unlock David Sterba
@ 2022-11-01 20:12 ` David Sterba
  2022-11-01 20:12 ` [PATCH 21/40] btrfs: pass btrfs_inode to btrfs_add_delalloc_inodes David Sterba
                   ` (20 subsequent siblings)
  40 siblings, 0 replies; 46+ messages in thread
From: David Sterba @ 2022-11-01 20:12 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

The function is for internal interfaces so we should use the
btrfs_inode.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/inode.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 977def66afab..754198b18d41 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -286,7 +286,7 @@ static inline void btrfs_cleanup_ordered_extents(struct btrfs_inode *inode,
 	return btrfs_mark_ordered_io_finished(inode, NULL, offset, bytes, false);
 }
 
-static int btrfs_dirty_inode(struct inode *inode);
+static int btrfs_dirty_inode(struct btrfs_inode *inode);
 
 static int btrfs_init_inode_security(struct btrfs_trans_handle *trans,
 				     struct btrfs_new_inode_args *args)
@@ -5312,7 +5312,7 @@ static int btrfs_setattr(struct user_namespace *mnt_userns, struct dentry *dentr
 	if (attr->ia_valid) {
 		setattr_copy(mnt_userns, inode, attr);
 		inode_inc_iversion(inode);
-		err = btrfs_dirty_inode(inode);
+		err = btrfs_dirty_inode(BTRFS_I(inode));
 
 		if (!err && attr->ia_valid & ATTR_MODE)
 			err = posix_acl_chmod(mnt_userns, inode, inode->i_mode);
@@ -6143,21 +6143,21 @@ static int btrfs_real_readdir(struct file *file, struct dir_context *ctx)
  * FIXME, needs more benchmarking...there are no reasons other than performance
  * to keep or drop this code.
  */
-static int btrfs_dirty_inode(struct inode *inode)
+static int btrfs_dirty_inode(struct btrfs_inode *inode)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
-	struct btrfs_root *root = BTRFS_I(inode)->root;
+	struct btrfs_root *root = inode->root;
+	struct btrfs_fs_info *fs_info = root->fs_info;
 	struct btrfs_trans_handle *trans;
 	int ret;
 
-	if (test_bit(BTRFS_INODE_DUMMY, &BTRFS_I(inode)->runtime_flags))
+	if (test_bit(BTRFS_INODE_DUMMY, &inode->runtime_flags))
 		return 0;
 
 	trans = btrfs_join_transaction(root);
 	if (IS_ERR(trans))
 		return PTR_ERR(trans);
 
-	ret = btrfs_update_inode(trans, root, BTRFS_I(inode));
+	ret = btrfs_update_inode(trans, root, inode);
 	if (ret && (ret == -ENOSPC || ret == -EDQUOT)) {
 		/* whoops, lets try again with the full transaction */
 		btrfs_end_transaction(trans);
@@ -6165,10 +6165,10 @@ static int btrfs_dirty_inode(struct inode *inode)
 		if (IS_ERR(trans))
 			return PTR_ERR(trans);
 
-		ret = btrfs_update_inode(trans, root, BTRFS_I(inode));
+		ret = btrfs_update_inode(trans, root, inode);
 	}
 	btrfs_end_transaction(trans);
-	if (BTRFS_I(inode)->delayed_node)
+	if (inode->delayed_node)
 		btrfs_balance_delayed_items(fs_info);
 
 	return ret;
@@ -6195,7 +6195,7 @@ static int btrfs_update_time(struct inode *inode, struct timespec64 *now,
 		inode->i_mtime = *now;
 	if (flags & S_ATIME)
 		inode->i_atime = *now;
-	return dirty ? btrfs_dirty_inode(inode) : 0;
+	return dirty ? btrfs_dirty_inode(BTRFS_I(inode)) : 0;
 }
 
 /*
-- 
2.37.3


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 21/40] btrfs: pass btrfs_inode to btrfs_add_delalloc_inodes
  2022-11-01 20:11 [PATCH 00/40] Parameter and type changes to btrfs_inode David Sterba
                   ` (19 preceding siblings ...)
  2022-11-01 20:12 ` [PATCH 20/40] btrfs: pass btrfs_inode to btrfs_dirty_inode David Sterba
@ 2022-11-01 20:12 ` David Sterba
  2022-11-01 20:12 ` [PATCH 22/40] btrfs: switch btrfs_writepage_fixup::inode to btrfs_inode David Sterba
                   ` (19 subsequent siblings)
  40 siblings, 0 replies; 46+ messages in thread
From: David Sterba @ 2022-11-01 20:12 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

The function is for internal interfaces so we should use the
btrfs_inode.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/inode.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 754198b18d41..45c46043f5e4 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -2369,16 +2369,14 @@ void btrfs_merge_delalloc_extent(struct inode *inode, struct extent_state *new,
 }
 
 static void btrfs_add_delalloc_inodes(struct btrfs_root *root,
-				      struct inode *inode)
+				      struct btrfs_inode *inode)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = inode->root->fs_info;
 
 	spin_lock(&root->delalloc_lock);
-	if (list_empty(&BTRFS_I(inode)->delalloc_inodes)) {
-		list_add_tail(&BTRFS_I(inode)->delalloc_inodes,
-			      &root->delalloc_inodes);
-		set_bit(BTRFS_INODE_IN_DELALLOC_LIST,
-			&BTRFS_I(inode)->runtime_flags);
+	if (list_empty(&inode->delalloc_inodes)) {
+		list_add_tail(&inode->delalloc_inodes, &root->delalloc_inodes);
+		set_bit(BTRFS_INODE_IN_DELALLOC_LIST, &inode->runtime_flags);
 		root->nr_delalloc_inodes++;
 		if (root->nr_delalloc_inodes == 1) {
 			spin_lock(&fs_info->delalloc_root_lock);
@@ -2391,7 +2389,6 @@ static void btrfs_add_delalloc_inodes(struct btrfs_root *root,
 	spin_unlock(&root->delalloc_lock);
 }
 
-
 void __btrfs_del_delalloc_inode(struct btrfs_root *root,
 				struct btrfs_inode *inode)
 {
@@ -2458,7 +2455,7 @@ void btrfs_set_delalloc_extent(struct inode *inode, struct extent_state *state,
 			BTRFS_I(inode)->defrag_bytes += len;
 		if (do_list && !test_bit(BTRFS_INODE_IN_DELALLOC_LIST,
 					 &BTRFS_I(inode)->runtime_flags))
-			btrfs_add_delalloc_inodes(root, inode);
+			btrfs_add_delalloc_inodes(root, BTRFS_I(inode));
 		spin_unlock(&BTRFS_I(inode)->lock);
 	}
 
-- 
2.37.3


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 22/40] btrfs: switch btrfs_writepage_fixup::inode to btrfs_inode
  2022-11-01 20:11 [PATCH 00/40] Parameter and type changes to btrfs_inode David Sterba
                   ` (20 preceding siblings ...)
  2022-11-01 20:12 ` [PATCH 21/40] btrfs: pass btrfs_inode to btrfs_add_delalloc_inodes David Sterba
@ 2022-11-01 20:12 ` David Sterba
  2022-11-01 20:12 ` [PATCH 23/40] btrfs: pass btrfs_inode to btrfs_check_data_csum David Sterba
                   ` (18 subsequent siblings)
  40 siblings, 0 replies; 46+ messages in thread
From: David Sterba @ 2022-11-01 20:12 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

The btrfs_writepage_fixup structure is for internal interfaces so we
should use the btrfs_inode.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/inode.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 45c46043f5e4..3e2cb80c6c63 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -2890,7 +2890,7 @@ int btrfs_set_extent_delalloc(struct btrfs_inode *inode, u64 start, u64 end,
 /* see btrfs_writepage_start_hook for details on why this is required */
 struct btrfs_writepage_fixup {
 	struct page *page;
-	struct inode *inode;
+	struct btrfs_inode *inode;
 	struct btrfs_work work;
 };
 
@@ -2909,7 +2909,7 @@ static void btrfs_writepage_fixup_worker(struct btrfs_work *work)
 
 	fixup = container_of(work, struct btrfs_writepage_fixup, work);
 	page = fixup->page;
-	inode = BTRFS_I(fixup->inode);
+	inode = fixup->inode;
 	page_start = page_offset(page);
 	page_end = page_offset(page) + PAGE_SIZE - 1;
 
@@ -3068,7 +3068,7 @@ int btrfs_writepage_cow_fixup(struct page *page)
 	get_page(page);
 	btrfs_init_work(&fixup->work, btrfs_writepage_fixup_worker, NULL, NULL);
 	fixup->page = page;
-	fixup->inode = inode;
+	fixup->inode = BTRFS_I(inode);
 	btrfs_queue_work(fs_info->fixup_workers, &fixup->work);
 
 	return -EAGAIN;
-- 
2.37.3


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 23/40] btrfs: pass btrfs_inode to btrfs_check_data_csum
  2022-11-01 20:11 [PATCH 00/40] Parameter and type changes to btrfs_inode David Sterba
                   ` (21 preceding siblings ...)
  2022-11-01 20:12 ` [PATCH 22/40] btrfs: switch btrfs_writepage_fixup::inode to btrfs_inode David Sterba
@ 2022-11-01 20:12 ` David Sterba
  2022-11-01 20:12 ` [PATCH 24/40] btrfs: pass btrfs_inode to __unlink_start_trans David Sterba
                   ` (17 subsequent siblings)
  40 siblings, 0 replies; 46+ messages in thread
From: David Sterba @ 2022-11-01 20:12 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

The function is for internal interfaces so we should use the
btrfs_inode.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/btrfs_inode.h |  4 +---
 fs/btrfs/compression.c |  2 +-
 fs/btrfs/inode.c       | 15 +++++++--------
 3 files changed, 9 insertions(+), 12 deletions(-)

diff --git a/fs/btrfs/btrfs_inode.h b/fs/btrfs/btrfs_inode.h
index 279bbbc59dc6..ba0dbdc91ec5 100644
--- a/fs/btrfs/btrfs_inode.h
+++ b/fs/btrfs/btrfs_inode.h
@@ -421,13 +421,11 @@ blk_status_t btrfs_submit_bio_start_direct_io(struct btrfs_inode *inode,
 					      u64 dio_file_offset);
 int btrfs_check_sector_csum(struct btrfs_fs_info *fs_info, struct page *page,
 			    u32 pgoff, u8 *csum, const u8 * const csum_expected);
-int btrfs_check_data_csum(struct inode *inode, struct btrfs_bio *bbio,
+int btrfs_check_data_csum(struct btrfs_inode *inode, struct btrfs_bio *bbio,
 			  u32 bio_offset, struct page *page, u32 pgoff);
 unsigned int btrfs_verify_data_csum(struct btrfs_bio *bbio,
 				    u32 bio_offset, struct page *page,
 				    u64 start, u64 end);
-int btrfs_check_data_csum(struct inode *inode, struct btrfs_bio *bbio,
-			  u32 bio_offset, struct page *page, u32 pgoff);
 noinline int can_nocow_extent(struct inode *inode, u64 offset, u64 *len,
 			      u64 *orig_start, u64 *orig_block_len,
 			      u64 *ram_bytes, bool nowait, bool strict);
diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c
index 7e9135ddaebb..a58aab446b1f 100644
--- a/fs/btrfs/compression.c
+++ b/fs/btrfs/compression.c
@@ -186,7 +186,7 @@ static void end_compressed_bio_read(struct btrfs_bio *bbio)
 		u64 start = bbio->file_offset + offset;
 
 		if (!status &&
-		    (!csum || !btrfs_check_data_csum(inode, bbio, offset,
+		    (!csum || !btrfs_check_data_csum(bi, bbio, offset,
 						     bv.bv_page, bv.bv_offset))) {
 			btrfs_clean_io_failure(bi, start, bv.bv_page,
 					       bv.bv_offset);
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 3e2cb80c6c63..b0504743613c 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -3490,10 +3490,10 @@ static u8 *btrfs_csum_ptr(const struct btrfs_fs_info *fs_info, u8 *csums, u64 of
  * When csum mismatch is detected, we will also report the error and fill the
  * corrupted range with zero. (Thus it needs the extra parameters)
  */
-int btrfs_check_data_csum(struct inode *inode, struct btrfs_bio *bbio,
+int btrfs_check_data_csum(struct btrfs_inode *inode, struct btrfs_bio *bbio,
 			  u32 bio_offset, struct page *page, u32 pgoff)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = inode->root->fs_info;
 	u32 len = fs_info->sectorsize;
 	u8 *csum_expected;
 	u8 csum[BTRFS_CSUM_SIZE];
@@ -3507,8 +3507,7 @@ int btrfs_check_data_csum(struct inode *inode, struct btrfs_bio *bbio,
 	return 0;
 
 zeroit:
-	btrfs_print_data_csum_error(BTRFS_I(inode),
-				    bbio->file_offset + bio_offset,
+	btrfs_print_data_csum_error(inode, bbio->file_offset + bio_offset,
 				    csum, csum_expected, bbio->mirror_num);
 	if (bbio->device)
 		btrfs_dev_stat_inc_and_print(bbio->device,
@@ -3573,7 +3572,7 @@ unsigned int btrfs_verify_data_csum(struct btrfs_bio *bbio,
 					  EXTENT_NODATASUM);
 			continue;
 		}
-		ret = btrfs_check_data_csum(inode, bbio, bio_offset, page, pg_off);
+		ret = btrfs_check_data_csum(BTRFS_I(inode), bbio, bio_offset, page, pg_off);
 		if (ret < 0) {
 			const int nr_bit = (pg_off - offset_in_page(start)) >>
 				     root->fs_info->sectorsize_bits;
@@ -7942,8 +7941,8 @@ static blk_status_t btrfs_check_read_dio_bio(struct btrfs_dio_private *dip,
 		u64 start = bbio->file_offset + offset;
 
 		if (uptodate &&
-		    (!csum || !btrfs_check_data_csum(inode, bbio, offset, bv.bv_page,
-					       bv.bv_offset))) {
+		    (!csum || !btrfs_check_data_csum(BTRFS_I(inode), bbio, offset,
+						     bv.bv_page, bv.bv_offset))) {
 			btrfs_clean_io_failure(BTRFS_I(inode), start,
 					       bv.bv_page, bv.bv_offset);
 		} else {
@@ -10333,7 +10332,7 @@ static blk_status_t btrfs_encoded_read_verify_csum(struct btrfs_bio *bbio)
 		pgoff = bvec->bv_offset;
 		for (i = 0; i < nr_sectors; i++) {
 			ASSERT(pgoff < PAGE_SIZE);
-			if (btrfs_check_data_csum(&inode->vfs_inode, bbio, bio_offset,
+			if (btrfs_check_data_csum(inode, bbio, bio_offset,
 					    bvec->bv_page, pgoff))
 				return BLK_STS_IOERR;
 			bio_offset += sectorsize;
-- 
2.37.3


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 24/40] btrfs: pass btrfs_inode to __unlink_start_trans
  2022-11-01 20:11 [PATCH 00/40] Parameter and type changes to btrfs_inode David Sterba
                   ` (22 preceding siblings ...)
  2022-11-01 20:12 ` [PATCH 23/40] btrfs: pass btrfs_inode to btrfs_check_data_csum David Sterba
@ 2022-11-01 20:12 ` David Sterba
  2022-11-01 20:12 ` [PATCH 25/40] btrfs: pass btrfs_inode to btrfs_delete_subvolume David Sterba
                   ` (16 subsequent siblings)
  40 siblings, 0 replies; 46+ messages in thread
From: David Sterba @ 2022-11-01 20:12 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

The function is for internal interfaces so we should use the
btrfs_inode.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/inode.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index b0504743613c..3307564c80e7 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -4415,9 +4415,9 @@ int btrfs_unlink_inode(struct btrfs_trans_handle *trans,
  * plenty of slack room in the global reserve to migrate, otherwise we cannot
  * allow the unlink to occur.
  */
-static struct btrfs_trans_handle *__unlink_start_trans(struct inode *dir)
+static struct btrfs_trans_handle *__unlink_start_trans(struct btrfs_inode *dir)
 {
-	struct btrfs_root *root = BTRFS_I(dir)->root;
+	struct btrfs_root *root = dir->root;
 
 	/*
 	 * 1 for the possible orphan item
@@ -4443,7 +4443,7 @@ static int btrfs_unlink(struct inode *dir, struct dentry *dentry)
 
 	/* This needs to handle no-key deletions later on */
 
-	trans = __unlink_start_trans(dir);
+	trans = __unlink_start_trans(BTRFS_I(dir));
 	if (IS_ERR(trans)) {
 		ret = PTR_ERR(trans);
 		goto out;
@@ -4856,7 +4856,7 @@ static int btrfs_rmdir(struct inode *dir, struct dentry *dentry)
 
 	/* This needs to handle no-key deletions later on */
 
-	trans = __unlink_start_trans(dir);
+	trans = __unlink_start_trans(BTRFS_I(dir));
 	if (IS_ERR(trans)) {
 		err = PTR_ERR(trans);
 		goto out_notrans;
-- 
2.37.3


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 25/40] btrfs: pass btrfs_inode to btrfs_delete_subvolume
  2022-11-01 20:11 [PATCH 00/40] Parameter and type changes to btrfs_inode David Sterba
                   ` (23 preceding siblings ...)
  2022-11-01 20:12 ` [PATCH 24/40] btrfs: pass btrfs_inode to __unlink_start_trans David Sterba
@ 2022-11-01 20:12 ` David Sterba
  2022-11-01 20:12 ` [PATCH 26/40] btrfs: drop private_data parameter from extent_io_tree_init David Sterba
                   ` (15 subsequent siblings)
  40 siblings, 0 replies; 46+ messages in thread
From: David Sterba @ 2022-11-01 20:12 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

The function is for internal interfaces so we should use the
btrfs_inode.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/btrfs_inode.h |  2 +-
 fs/btrfs/inode.c       | 10 +++++-----
 fs/btrfs/ioctl.c       |  2 +-
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/fs/btrfs/btrfs_inode.h b/fs/btrfs/btrfs_inode.h
index ba0dbdc91ec5..481c75c47fc4 100644
--- a/fs/btrfs/btrfs_inode.h
+++ b/fs/btrfs/btrfs_inode.h
@@ -439,7 +439,7 @@ int btrfs_unlink_inode(struct btrfs_trans_handle *trans,
 int btrfs_add_link(struct btrfs_trans_handle *trans,
 		   struct btrfs_inode *parent_inode, struct btrfs_inode *inode,
 		   const struct fscrypt_str *name, int add_backref, u64 index);
-int btrfs_delete_subvolume(struct inode *dir, struct dentry *dentry);
+int btrfs_delete_subvolume(struct btrfs_inode *dir, struct dentry *dentry);
 int btrfs_truncate_block(struct btrfs_inode *inode, loff_t from, loff_t len,
 			 int front);
 
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 3307564c80e7..203298546c7e 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -4697,10 +4697,10 @@ static void btrfs_prune_dentries(struct btrfs_root *root)
 	spin_unlock(&root->inode_lock);
 }
 
-int btrfs_delete_subvolume(struct inode *dir, struct dentry *dentry)
+int btrfs_delete_subvolume(struct btrfs_inode *dir, struct dentry *dentry)
 {
 	struct btrfs_fs_info *fs_info = btrfs_sb(dentry->d_sb);
-	struct btrfs_root *root = BTRFS_I(dir)->root;
+	struct btrfs_root *root = dir->root;
 	struct inode *inode = d_inode(dentry);
 	struct btrfs_root *dest = BTRFS_I(inode)->root;
 	struct btrfs_trans_handle *trans;
@@ -4757,9 +4757,9 @@ int btrfs_delete_subvolume(struct inode *dir, struct dentry *dentry)
 	trans->block_rsv = &block_rsv;
 	trans->bytes_reserved = block_rsv.size;
 
-	btrfs_record_snapshot_destroy(trans, BTRFS_I(dir));
+	btrfs_record_snapshot_destroy(trans, dir);
 
-	ret = btrfs_unlink_subvol(trans, dir, dentry);
+	ret = btrfs_unlink_subvol(trans, &dir->vfs_inode, dentry);
 	if (ret) {
 		btrfs_abort_transaction(trans, ret);
 		goto out_end_trans;
@@ -4847,7 +4847,7 @@ static int btrfs_rmdir(struct inode *dir, struct dentry *dentry)
 			"extent tree v2 doesn't support snapshot deletion yet");
 			return -EOPNOTSUPP;
 		}
-		return btrfs_delete_subvolume(dir, dentry);
+		return btrfs_delete_subvolume(BTRFS_I(dir), dentry);
 	}
 
 	err = fscrypt_setup_filename(dir, &dentry->d_name, 1, &fname);
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 0873eae20f63..a64a71d882dc 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -2526,7 +2526,7 @@ static noinline int btrfs_ioctl_snap_destroy(struct file *file,
 	}
 
 	btrfs_inode_lock(BTRFS_I(inode), 0);
-	err = btrfs_delete_subvolume(dir, dentry);
+	err = btrfs_delete_subvolume(BTRFS_I(dir), dentry);
 	btrfs_inode_unlock(BTRFS_I(inode), 0);
 	if (!err)
 		d_delete_notify(dir, dentry);
-- 
2.37.3


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 26/40] btrfs: drop private_data parameter from extent_io_tree_init
  2022-11-01 20:11 [PATCH 00/40] Parameter and type changes to btrfs_inode David Sterba
                   ` (24 preceding siblings ...)
  2022-11-01 20:12 ` [PATCH 25/40] btrfs: pass btrfs_inode to btrfs_delete_subvolume David Sterba
@ 2022-11-01 20:12 ` David Sterba
  2022-11-01 20:12 ` [PATCH 27/40] btrfs: switch extent_io_tree::private_data to btrfs_inode and rename David Sterba
                   ` (14 subsequent siblings)
  40 siblings, 0 replies; 46+ messages in thread
From: David Sterba @ 2022-11-01 20:12 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

All callers except one pass NULL, so the parameter can be dropped and
the inode::io_tree initialization can be open coded.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/disk-io.c               | 8 ++++----
 fs/btrfs/extent-io-tree.c        | 5 ++---
 fs/btrfs/extent-io-tree.h        | 3 +--
 fs/btrfs/inode.c                 | 5 +++--
 fs/btrfs/relocation.c            | 3 +--
 fs/btrfs/tests/btrfs-tests.c     | 2 +-
 fs/btrfs/tests/extent-io-tests.c | 4 ++--
 fs/btrfs/transaction.c           | 4 ++--
 fs/btrfs/volumes.c               | 3 +--
 9 files changed, 17 insertions(+), 20 deletions(-)

diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index c86513e70ff3..d93bb971cc73 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -1044,9 +1044,9 @@ static void __setup_root(struct btrfs_root *root, struct btrfs_fs_info *fs_info,
 	root->anon_dev = 0;
 	if (!dummy) {
 		extent_io_tree_init(fs_info, &root->dirty_log_pages,
-				    IO_TREE_ROOT_DIRTY_LOG_PAGES, NULL);
+				    IO_TREE_ROOT_DIRTY_LOG_PAGES);
 		extent_io_tree_init(fs_info, &root->log_csum_range,
-				    IO_TREE_LOG_CSUM_RANGE, NULL);
+				    IO_TREE_LOG_CSUM_RANGE);
 	}
 
 	spin_lock_init(&root->root_item_lock);
@@ -2252,7 +2252,7 @@ static void btrfs_init_btree_inode(struct btrfs_fs_info *fs_info)
 
 	RB_CLEAR_NODE(&BTRFS_I(inode)->rb_node);
 	extent_io_tree_init(fs_info, &BTRFS_I(inode)->io_tree,
-			    IO_TREE_BTREE_INODE_IO, NULL);
+			    IO_TREE_BTREE_INODE_IO);
 	extent_map_tree_init(&BTRFS_I(inode)->extent_tree);
 
 	BTRFS_I(inode)->root = btrfs_grab_root(fs_info->tree_root);
@@ -3076,7 +3076,7 @@ void btrfs_init_fs_info(struct btrfs_fs_info *fs_info)
 	fs_info->block_group_cache_tree = RB_ROOT_CACHED;
 
 	extent_io_tree_init(fs_info, &fs_info->excluded_extents,
-			    IO_TREE_FS_EXCLUDED_EXTENTS, NULL);
+			    IO_TREE_FS_EXCLUDED_EXTENTS);
 
 	mutex_init(&fs_info->ordered_operations_mutex);
 	mutex_init(&fs_info->tree_log_mutex);
diff --git a/fs/btrfs/extent-io-tree.c b/fs/btrfs/extent-io-tree.c
index 2cdff74ff033..81365870576f 100644
--- a/fs/btrfs/extent-io-tree.c
+++ b/fs/btrfs/extent-io-tree.c
@@ -94,13 +94,12 @@ struct tree_entry {
 };
 
 void extent_io_tree_init(struct btrfs_fs_info *fs_info,
-			 struct extent_io_tree *tree, unsigned int owner,
-			 void *private_data)
+			 struct extent_io_tree *tree, unsigned int owner)
 {
 	tree->fs_info = fs_info;
 	tree->state = RB_ROOT;
 	spin_lock_init(&tree->lock);
-	tree->private_data = private_data;
+	tree->private_data = NULL;
 	tree->owner = owner;
 	if (owner == IO_TREE_INODE_FILE_EXTENT)
 		lockdep_set_class(&tree->lock, &file_extent_tree_class);
diff --git a/fs/btrfs/extent-io-tree.h b/fs/btrfs/extent-io-tree.h
index d73ef24bad2e..0e16642c28a3 100644
--- a/fs/btrfs/extent-io-tree.h
+++ b/fs/btrfs/extent-io-tree.h
@@ -104,8 +104,7 @@ struct extent_state {
 };
 
 void extent_io_tree_init(struct btrfs_fs_info *fs_info,
-			 struct extent_io_tree *tree, unsigned int owner,
-			 void *private_data);
+			 struct extent_io_tree *tree, unsigned int owner);
 void extent_io_tree_release(struct extent_io_tree *tree);
 
 int lock_extent(struct extent_io_tree *tree, u64 start, u64 end,
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 203298546c7e..35b8aae4de5d 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -8870,9 +8870,10 @@ struct inode *btrfs_alloc_inode(struct super_block *sb)
 
 	inode = &ei->vfs_inode;
 	extent_map_tree_init(&ei->extent_tree);
-	extent_io_tree_init(fs_info, &ei->io_tree, IO_TREE_INODE_IO, inode);
+	extent_io_tree_init(fs_info, &ei->io_tree, IO_TREE_INODE_IO);
+	ei->io_tree.private_data = inode;
 	extent_io_tree_init(fs_info, &ei->file_extent_tree,
-			    IO_TREE_INODE_FILE_EXTENT, NULL);
+			    IO_TREE_INODE_FILE_EXTENT);
 	ei->io_failure_tree = RB_ROOT;
 	atomic_set(&ei->sync_writers, 0);
 	mutex_init(&ei->log_mutex);
diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index 1a337602723c..bdf845077002 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -3925,8 +3925,7 @@ static struct reloc_control *alloc_reloc_control(struct btrfs_fs_info *fs_info)
 	INIT_LIST_HEAD(&rc->dirty_subvol_roots);
 	btrfs_backref_init_cache(fs_info, &rc->backref_cache, 1);
 	mapping_tree_init(&rc->reloc_root_tree);
-	extent_io_tree_init(fs_info, &rc->processed_blocks,
-			    IO_TREE_RELOC_BLOCKS, NULL);
+	extent_io_tree_init(fs_info, &rc->processed_blocks, IO_TREE_RELOC_BLOCKS);
 	return rc;
 }
 
diff --git a/fs/btrfs/tests/btrfs-tests.c b/fs/btrfs/tests/btrfs-tests.c
index 1538c65f2b17..9d5cb7fa51d0 100644
--- a/fs/btrfs/tests/btrfs-tests.c
+++ b/fs/btrfs/tests/btrfs-tests.c
@@ -102,7 +102,7 @@ struct btrfs_device *btrfs_alloc_dummy_device(struct btrfs_fs_info *fs_info)
 	if (!dev)
 		return ERR_PTR(-ENOMEM);
 
-	extent_io_tree_init(NULL, &dev->alloc_state, 0, NULL);
+	extent_io_tree_init(NULL, &dev->alloc_state, 0);
 	INIT_LIST_HEAD(&dev->dev_list);
 	list_add(&dev->dev_list, &fs_info->fs_devices->devices);
 
diff --git a/fs/btrfs/tests/extent-io-tests.c b/fs/btrfs/tests/extent-io-tests.c
index 350da449db08..dfc5c7fa6038 100644
--- a/fs/btrfs/tests/extent-io-tests.c
+++ b/fs/btrfs/tests/extent-io-tests.c
@@ -132,7 +132,7 @@ static int test_find_delalloc(u32 sectorsize)
 	 * Passing NULL as we don't have fs_info but tracepoints are not used
 	 * at this point
 	 */
-	extent_io_tree_init(NULL, tmp, IO_TREE_SELFTEST, NULL);
+	extent_io_tree_init(NULL, tmp, IO_TREE_SELFTEST);
 
 	/*
 	 * First go through and create and mark all of our pages dirty, we pin
@@ -489,7 +489,7 @@ static int test_find_first_clear_extent_bit(void)
 
 	test_msg("running find_first_clear_extent_bit test");
 
-	extent_io_tree_init(NULL, &tree, IO_TREE_SELFTEST, NULL);
+	extent_io_tree_init(NULL, &tree, IO_TREE_SELFTEST);
 
 	/* Test correct handling of empty tree */
 	find_first_clear_extent_bit(&tree, 0, &start, &end, CHUNK_TRIMMED);
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index 2e2dd2ea109b..b8c52e89688c 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -378,9 +378,9 @@ static noinline int join_transaction(struct btrfs_fs_info *fs_info,
 	spin_lock_init(&cur_trans->releasing_ebs_lock);
 	list_add_tail(&cur_trans->list, &fs_info->trans_list);
 	extent_io_tree_init(fs_info, &cur_trans->dirty_pages,
-			IO_TREE_TRANS_DIRTY_PAGES, NULL);
+			IO_TREE_TRANS_DIRTY_PAGES);
 	extent_io_tree_init(fs_info, &cur_trans->pinned_extents,
-			IO_TREE_FS_PINNED_EXTENTS, NULL);
+			IO_TREE_FS_PINNED_EXTENTS);
 	fs_info->generation++;
 	cur_trans->transid = fs_info->generation;
 	fs_info->running_transaction = cur_trans;
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 27fa43f5c4f4..0e3c8860c0a4 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -7036,8 +7036,7 @@ struct btrfs_device *btrfs_alloc_device(struct btrfs_fs_info *fs_info,
 
 	atomic_set(&dev->dev_stats_ccnt, 0);
 	btrfs_device_data_ordered_init(dev);
-	extent_io_tree_init(fs_info, &dev->alloc_state,
-			    IO_TREE_DEVICE_ALLOC_STATE, NULL);
+	extent_io_tree_init(fs_info, &dev->alloc_state, IO_TREE_DEVICE_ALLOC_STATE);
 
 	if (devid)
 		tmp = *devid;
-- 
2.37.3


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 27/40] btrfs: switch extent_io_tree::private_data to btrfs_inode and rename
  2022-11-01 20:11 [PATCH 00/40] Parameter and type changes to btrfs_inode David Sterba
                   ` (25 preceding siblings ...)
  2022-11-01 20:12 ` [PATCH 26/40] btrfs: drop private_data parameter from extent_io_tree_init David Sterba
@ 2022-11-01 20:12 ` David Sterba
  2022-11-01 20:12 ` [PATCH 28/40] btrfs: pass btrfs_inode to btrfs_merge_delalloc_extent David Sterba
                   ` (13 subsequent siblings)
  40 siblings, 0 replies; 46+ messages in thread
From: David Sterba @ 2022-11-01 20:12 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

The extent_io_tree::private_data was meant to be a preparatory work for
the metadata inode rework but that never materialized. Now it's used
only for an inode so it's better to change the appropriate type and
rename it.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/extent-io-tree.c    | 32 ++++++++++++++++----------------
 fs/btrfs/extent-io-tree.h    |  3 ++-
 fs/btrfs/inode.c             |  2 +-
 include/trace/events/btrfs.h | 27 ++++++++++++---------------
 4 files changed, 31 insertions(+), 33 deletions(-)

diff --git a/fs/btrfs/extent-io-tree.c b/fs/btrfs/extent-io-tree.c
index 81365870576f..bbcc65593d1d 100644
--- a/fs/btrfs/extent-io-tree.c
+++ b/fs/btrfs/extent-io-tree.c
@@ -58,17 +58,17 @@ static inline void __btrfs_debug_check_extent_io_range(const char *caller,
 						       struct extent_io_tree *tree,
 						       u64 start, u64 end)
 {
-	struct inode *inode = tree->private_data;
+	struct btrfs_inode *inode = tree->inode;
 	u64 isize;
 
 	if (!inode)
 		return;
 
-	isize = i_size_read(inode);
+	isize = i_size_read(&inode->vfs_inode);
 	if (end >= PAGE_SIZE && (end % 2) == 0 && end != isize - 1) {
-		btrfs_debug_rl(BTRFS_I(inode)->root->fs_info,
+		btrfs_debug_rl(inode->root->fs_info,
 		    "%s: ino %llu isize %llu odd range [%llu,%llu]",
-			caller, btrfs_ino(BTRFS_I(inode)), isize, start, end);
+			caller, btrfs_ino(inode), isize, start, end);
 	}
 }
 #else
@@ -99,7 +99,7 @@ void extent_io_tree_init(struct btrfs_fs_info *fs_info,
 	tree->fs_info = fs_info;
 	tree->state = RB_ROOT;
 	spin_lock_init(&tree->lock);
-	tree->private_data = NULL;
+	tree->inode = NULL;
 	tree->owner = owner;
 	if (owner == IO_TREE_INODE_FILE_EXTENT)
 		lockdep_set_class(&tree->lock, &file_extent_tree_class);
@@ -346,9 +346,9 @@ static void merge_state(struct extent_io_tree *tree, struct extent_state *state)
 	other = prev_state(state);
 	if (other && other->end == state->start - 1 &&
 	    other->state == state->state) {
-		if (tree->private_data)
-			btrfs_merge_delalloc_extent(tree->private_data,
-						    state, other);
+		if (tree->inode)
+			btrfs_merge_delalloc_extent(&tree->inode->vfs_inode, state,
+						    other);
 		state->start = other->start;
 		rb_erase(&other->rb_node, &tree->state);
 		RB_CLEAR_NODE(&other->rb_node);
@@ -357,8 +357,8 @@ static void merge_state(struct extent_io_tree *tree, struct extent_state *state)
 	other = next_state(state);
 	if (other && other->start == state->end + 1 &&
 	    other->state == state->state) {
-		if (tree->private_data)
-			btrfs_merge_delalloc_extent(tree->private_data, state,
+		if (tree->inode)
+			btrfs_merge_delalloc_extent(&tree->inode->vfs_inode, state,
 						    other);
 		state->end = other->end;
 		rb_erase(&other->rb_node, &tree->state);
@@ -374,8 +374,8 @@ static void set_state_bits(struct extent_io_tree *tree,
 	u32 bits_to_set = bits & ~EXTENT_CTLBITS;
 	int ret;
 
-	if (tree->private_data)
-		btrfs_set_delalloc_extent(tree->private_data, state, bits);
+	if (tree->inode)
+		btrfs_set_delalloc_extent(&tree->inode->vfs_inode, state, bits);
 
 	ret = add_extent_changeset(state, bits_to_set, changeset, 1);
 	BUG_ON(ret < 0);
@@ -462,8 +462,8 @@ static int split_state(struct extent_io_tree *tree, struct extent_state *orig,
 	struct rb_node *parent = NULL;
 	struct rb_node **node;
 
-	if (tree->private_data)
-		btrfs_split_delalloc_extent(tree->private_data, orig, split);
+	if (tree->inode)
+		btrfs_split_delalloc_extent(&tree->inode->vfs_inode, orig, split);
 
 	prealloc->start = orig->start;
 	prealloc->end = split - 1;
@@ -510,8 +510,8 @@ static struct extent_state *clear_state_bit(struct extent_io_tree *tree,
 	u32 bits_to_clear = bits & ~EXTENT_CTLBITS;
 	int ret;
 
-	if (tree->private_data)
-		btrfs_clear_delalloc_extent(tree->private_data, state, bits);
+	if (tree->inode)
+		btrfs_clear_delalloc_extent(&tree->inode->vfs_inode, state, bits);
 
 	ret = add_extent_changeset(state, bits_to_clear, changeset, 0);
 	BUG_ON(ret < 0);
diff --git a/fs/btrfs/extent-io-tree.h b/fs/btrfs/extent-io-tree.h
index 0e16642c28a3..cdee8c0854c8 100644
--- a/fs/btrfs/extent-io-tree.h
+++ b/fs/btrfs/extent-io-tree.h
@@ -80,7 +80,8 @@ enum {
 struct extent_io_tree {
 	struct rb_root state;
 	struct btrfs_fs_info *fs_info;
-	void *private_data;
+	/* Inode associated with this tree, or NULL. */
+	struct btrfs_inode *inode;
 
 	/* Who owns this io tree, should be one of IO_TREE_* */
 	u8 owner;
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 35b8aae4de5d..8b329a361096 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -8871,7 +8871,7 @@ struct inode *btrfs_alloc_inode(struct super_block *sb)
 	inode = &ei->vfs_inode;
 	extent_map_tree_init(&ei->extent_tree);
 	extent_io_tree_init(fs_info, &ei->io_tree, IO_TREE_INODE_IO);
-	ei->io_tree.private_data = inode;
+	ei->io_tree.inode = ei;
 	extent_io_tree_init(fs_info, &ei->file_extent_tree,
 			    IO_TREE_INODE_FILE_EXTENT);
 	ei->io_failure_tree = RB_ROOT;
diff --git a/include/trace/events/btrfs.h b/include/trace/events/btrfs.h
index ed50e81174bf..0bce0b4ff2fa 100644
--- a/include/trace/events/btrfs.h
+++ b/include/trace/events/btrfs.h
@@ -1993,12 +1993,11 @@ TRACE_EVENT(btrfs_set_extent_bit,
 
 	TP_fast_assign_btrfs(tree->fs_info,
 		__entry->owner = tree->owner;
-		if (tree->private_data) {
-			const struct inode *inode = tree->private_data;
+		if (tree->inode) {
+			const struct btrfs_inode *inode = tree->inode;
 
-			__entry->ino	= btrfs_ino(BTRFS_I(inode));
-			__entry->rootid	=
-				BTRFS_I(inode)->root->root_key.objectid;
+			__entry->ino	= btrfs_ino(inode);
+			__entry->rootid	= inode->root->root_key.objectid;
 		} else {
 			__entry->ino	= 0;
 			__entry->rootid	= 0;
@@ -2032,12 +2031,11 @@ TRACE_EVENT(btrfs_clear_extent_bit,
 
 	TP_fast_assign_btrfs(tree->fs_info,
 		__entry->owner = tree->owner;
-		if (tree->private_data) {
-			const struct inode *inode = tree->private_data;
+		if (tree->inode) {
+			const struct btrfs_inode *inode = tree->inode;
 
-			__entry->ino	= btrfs_ino(BTRFS_I(inode));
-			__entry->rootid	=
-				BTRFS_I(inode)->root->root_key.objectid;
+			__entry->ino	= btrfs_ino(inode);
+			__entry->rootid	= inode->root->root_key.objectid;
 		} else {
 			__entry->ino	= 0;
 			__entry->rootid	= 0;
@@ -2072,12 +2070,11 @@ TRACE_EVENT(btrfs_convert_extent_bit,
 
 	TP_fast_assign_btrfs(tree->fs_info,
 		__entry->owner = tree->owner;
-		if (tree->private_data) {
-			const struct inode *inode = tree->private_data;
+		if (tree->inode) {
+			const struct btrfs_inode *inode = tree->inode;
 
-			__entry->ino	= btrfs_ino(BTRFS_I(inode));
-			__entry->rootid	=
-				BTRFS_I(inode)->root->root_key.objectid;
+			__entry->ino	= btrfs_ino(inode);
+			__entry->rootid	= inode->root->root_key.objectid;
 		} else {
 			__entry->ino	= 0;
 			__entry->rootid	= 0;
-- 
2.37.3


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 28/40] btrfs: pass btrfs_inode to btrfs_merge_delalloc_extent
  2022-11-01 20:11 [PATCH 00/40] Parameter and type changes to btrfs_inode David Sterba
                   ` (26 preceding siblings ...)
  2022-11-01 20:12 ` [PATCH 27/40] btrfs: switch extent_io_tree::private_data to btrfs_inode and rename David Sterba
@ 2022-11-01 20:12 ` David Sterba
  2022-11-01 20:12 ` [PATCH 29/40] btrfs: pass btrfs_inode to btrfs_set_delalloc_extent David Sterba
                   ` (12 subsequent siblings)
  40 siblings, 0 replies; 46+ messages in thread
From: David Sterba @ 2022-11-01 20:12 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

The function is for internal interfaces so we should use the
btrfs_inode.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/btrfs_inode.h    |  2 +-
 fs/btrfs/extent-io-tree.c |  6 ++----
 fs/btrfs/inode.c          | 16 ++++++++--------
 3 files changed, 11 insertions(+), 13 deletions(-)

diff --git a/fs/btrfs/btrfs_inode.h b/fs/btrfs/btrfs_inode.h
index 481c75c47fc4..130c95c6f7df 100644
--- a/fs/btrfs/btrfs_inode.h
+++ b/fs/btrfs/btrfs_inode.h
@@ -475,7 +475,7 @@ struct inode *btrfs_new_subvol_inode(struct user_namespace *mnt_userns,
 			        u32 bits);
 void btrfs_clear_delalloc_extent(struct inode *inode,
 				 struct extent_state *state, u32 bits);
-void btrfs_merge_delalloc_extent(struct inode *inode, struct extent_state *new,
+void btrfs_merge_delalloc_extent(struct btrfs_inode *inode, struct extent_state *new,
 				 struct extent_state *other);
 void btrfs_split_delalloc_extent(struct inode *inode,
 				 struct extent_state *orig, u64 split);
diff --git a/fs/btrfs/extent-io-tree.c b/fs/btrfs/extent-io-tree.c
index bbcc65593d1d..942212e1dbaf 100644
--- a/fs/btrfs/extent-io-tree.c
+++ b/fs/btrfs/extent-io-tree.c
@@ -347,8 +347,7 @@ static void merge_state(struct extent_io_tree *tree, struct extent_state *state)
 	if (other && other->end == state->start - 1 &&
 	    other->state == state->state) {
 		if (tree->inode)
-			btrfs_merge_delalloc_extent(&tree->inode->vfs_inode, state,
-						    other);
+			btrfs_merge_delalloc_extent(tree->inode, state, other);
 		state->start = other->start;
 		rb_erase(&other->rb_node, &tree->state);
 		RB_CLEAR_NODE(&other->rb_node);
@@ -358,8 +357,7 @@ static void merge_state(struct extent_io_tree *tree, struct extent_state *state)
 	if (other && other->start == state->end + 1 &&
 	    other->state == state->state) {
 		if (tree->inode)
-			btrfs_merge_delalloc_extent(&tree->inode->vfs_inode, state,
-						    other);
+			btrfs_merge_delalloc_extent(tree->inode, state, other);
 		state->end = other->end;
 		rb_erase(&other->rb_node, &tree->state);
 		RB_CLEAR_NODE(&other->rb_node);
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 8b329a361096..27dd57978fdf 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -2314,10 +2314,10 @@ void btrfs_split_delalloc_extent(struct inode *inode,
  * that are just merged onto old extents, such as when we are doing sequential
  * writes, so we can properly account for the metadata space we'll need.
  */
-void btrfs_merge_delalloc_extent(struct inode *inode, struct extent_state *new,
+void btrfs_merge_delalloc_extent(struct btrfs_inode *inode, struct extent_state *new,
 				 struct extent_state *other)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = inode->root->fs_info;
 	u64 new_size, old_size;
 	u32 num_extents;
 
@@ -2332,9 +2332,9 @@ void btrfs_merge_delalloc_extent(struct inode *inode, struct extent_state *new,
 
 	/* we're not bigger than the max, unreserve the space and go */
 	if (new_size <= fs_info->max_extent_size) {
-		spin_lock(&BTRFS_I(inode)->lock);
-		btrfs_mod_outstanding_extents(BTRFS_I(inode), -1);
-		spin_unlock(&BTRFS_I(inode)->lock);
+		spin_lock(&inode->lock);
+		btrfs_mod_outstanding_extents(inode, -1);
+		spin_unlock(&inode->lock);
 		return;
 	}
 
@@ -2363,9 +2363,9 @@ void btrfs_merge_delalloc_extent(struct inode *inode, struct extent_state *new,
 	if (count_max_extents(fs_info, new_size) >= num_extents)
 		return;
 
-	spin_lock(&BTRFS_I(inode)->lock);
-	btrfs_mod_outstanding_extents(BTRFS_I(inode), -1);
-	spin_unlock(&BTRFS_I(inode)->lock);
+	spin_lock(&inode->lock);
+	btrfs_mod_outstanding_extents(inode, -1);
+	spin_unlock(&inode->lock);
 }
 
 static void btrfs_add_delalloc_inodes(struct btrfs_root *root,
-- 
2.37.3


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 29/40] btrfs: pass btrfs_inode to btrfs_set_delalloc_extent
  2022-11-01 20:11 [PATCH 00/40] Parameter and type changes to btrfs_inode David Sterba
                   ` (27 preceding siblings ...)
  2022-11-01 20:12 ` [PATCH 28/40] btrfs: pass btrfs_inode to btrfs_merge_delalloc_extent David Sterba
@ 2022-11-01 20:12 ` David Sterba
  2022-11-01 20:12 ` [PATCH 30/40] btrfs: pass btrfs_inode to btrfs_split_delalloc_extent David Sterba
                   ` (11 subsequent siblings)
  40 siblings, 0 replies; 46+ messages in thread
From: David Sterba @ 2022-11-01 20:12 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

The function is for internal interfaces so we should use the
btrfs_inode.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/btrfs_inode.h    |  2 +-
 fs/btrfs/extent-io-tree.c |  2 +-
 fs/btrfs/inode.c          | 33 ++++++++++++++++-----------------
 3 files changed, 18 insertions(+), 19 deletions(-)

diff --git a/fs/btrfs/btrfs_inode.h b/fs/btrfs/btrfs_inode.h
index 130c95c6f7df..8a8280233199 100644
--- a/fs/btrfs/btrfs_inode.h
+++ b/fs/btrfs/btrfs_inode.h
@@ -471,7 +471,7 @@ int btrfs_create_new_inode(struct btrfs_trans_handle *trans,
 void btrfs_new_inode_args_destroy(struct btrfs_new_inode_args *args);
 struct inode *btrfs_new_subvol_inode(struct user_namespace *mnt_userns,
 				     struct inode *dir);
- void btrfs_set_delalloc_extent(struct inode *inode, struct extent_state *state,
+ void btrfs_set_delalloc_extent(struct btrfs_inode *inode, struct extent_state *state,
 			        u32 bits);
 void btrfs_clear_delalloc_extent(struct inode *inode,
 				 struct extent_state *state, u32 bits);
diff --git a/fs/btrfs/extent-io-tree.c b/fs/btrfs/extent-io-tree.c
index 942212e1dbaf..1b4c52d7201d 100644
--- a/fs/btrfs/extent-io-tree.c
+++ b/fs/btrfs/extent-io-tree.c
@@ -373,7 +373,7 @@ static void set_state_bits(struct extent_io_tree *tree,
 	int ret;
 
 	if (tree->inode)
-		btrfs_set_delalloc_extent(&tree->inode->vfs_inode, state, bits);
+		btrfs_set_delalloc_extent(tree->inode, state, bits);
 
 	ret = add_extent_changeset(state, bits_to_set, changeset, 1);
 	BUG_ON(ret < 0);
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 27dd57978fdf..c373125e13c2 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -2421,10 +2421,10 @@ static void btrfs_del_delalloc_inode(struct btrfs_root *root,
  * Properly track delayed allocation bytes in the inode and to maintain the
  * list of inodes that have pending delalloc work to be done.
  */
-void btrfs_set_delalloc_extent(struct inode *inode, struct extent_state *state,
+void btrfs_set_delalloc_extent(struct btrfs_inode *inode, struct extent_state *state,
 			       u32 bits)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = inode->root->fs_info;
 
 	if ((bits & EXTENT_DEFRAG) && !(bits & EXTENT_DELALLOC))
 		WARN_ON(1);
@@ -2434,14 +2434,14 @@ void btrfs_set_delalloc_extent(struct inode *inode, struct extent_state *state,
 	 * bit, which is only set or cleared with irqs on
 	 */
 	if (!(state->state & EXTENT_DELALLOC) && (bits & EXTENT_DELALLOC)) {
-		struct btrfs_root *root = BTRFS_I(inode)->root;
+		struct btrfs_root *root = inode->root;
 		u64 len = state->end + 1 - state->start;
 		u32 num_extents = count_max_extents(fs_info, len);
-		bool do_list = !btrfs_is_free_space_inode(BTRFS_I(inode));
+		bool do_list = !btrfs_is_free_space_inode(inode);
 
-		spin_lock(&BTRFS_I(inode)->lock);
-		btrfs_mod_outstanding_extents(BTRFS_I(inode), num_extents);
-		spin_unlock(&BTRFS_I(inode)->lock);
+		spin_lock(&inode->lock);
+		btrfs_mod_outstanding_extents(inode, num_extents);
+		spin_unlock(&inode->lock);
 
 		/* For sanity tests */
 		if (btrfs_is_testing(fs_info))
@@ -2449,22 +2449,21 @@ void btrfs_set_delalloc_extent(struct inode *inode, struct extent_state *state,
 
 		percpu_counter_add_batch(&fs_info->delalloc_bytes, len,
 					 fs_info->delalloc_batch);
-		spin_lock(&BTRFS_I(inode)->lock);
-		BTRFS_I(inode)->delalloc_bytes += len;
+		spin_lock(&inode->lock);
+		inode->delalloc_bytes += len;
 		if (bits & EXTENT_DEFRAG)
-			BTRFS_I(inode)->defrag_bytes += len;
+			inode->defrag_bytes += len;
 		if (do_list && !test_bit(BTRFS_INODE_IN_DELALLOC_LIST,
-					 &BTRFS_I(inode)->runtime_flags))
-			btrfs_add_delalloc_inodes(root, BTRFS_I(inode));
-		spin_unlock(&BTRFS_I(inode)->lock);
+					 &inode->runtime_flags))
+			btrfs_add_delalloc_inodes(root, inode);
+		spin_unlock(&inode->lock);
 	}
 
 	if (!(state->state & EXTENT_DELALLOC_NEW) &&
 	    (bits & EXTENT_DELALLOC_NEW)) {
-		spin_lock(&BTRFS_I(inode)->lock);
-		BTRFS_I(inode)->new_delalloc_bytes += state->end + 1 -
-			state->start;
-		spin_unlock(&BTRFS_I(inode)->lock);
+		spin_lock(&inode->lock);
+		inode->new_delalloc_bytes += state->end + 1 - state->start;
+		spin_unlock(&inode->lock);
 	}
 }
 
-- 
2.37.3


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 30/40] btrfs: pass btrfs_inode to btrfs_split_delalloc_extent
  2022-11-01 20:11 [PATCH 00/40] Parameter and type changes to btrfs_inode David Sterba
                   ` (28 preceding siblings ...)
  2022-11-01 20:12 ` [PATCH 29/40] btrfs: pass btrfs_inode to btrfs_set_delalloc_extent David Sterba
@ 2022-11-01 20:12 ` David Sterba
  2022-11-01 20:12 ` [PATCH 31/40] btrfs: pass btrfs_inode to btrfs_clear_delalloc_extent David Sterba
                   ` (10 subsequent siblings)
  40 siblings, 0 replies; 46+ messages in thread
From: David Sterba @ 2022-11-01 20:12 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

The function is for internal interfaces so we should use the
btrfs_inode.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/btrfs_inode.h    |  2 +-
 fs/btrfs/extent-io-tree.c |  2 +-
 fs/btrfs/inode.c          | 10 +++++-----
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/fs/btrfs/btrfs_inode.h b/fs/btrfs/btrfs_inode.h
index 8a8280233199..ddf1867ba6d5 100644
--- a/fs/btrfs/btrfs_inode.h
+++ b/fs/btrfs/btrfs_inode.h
@@ -477,7 +477,7 @@ void btrfs_clear_delalloc_extent(struct inode *inode,
 				 struct extent_state *state, u32 bits);
 void btrfs_merge_delalloc_extent(struct btrfs_inode *inode, struct extent_state *new,
 				 struct extent_state *other);
-void btrfs_split_delalloc_extent(struct inode *inode,
+void btrfs_split_delalloc_extent(struct btrfs_inode *inode,
 				 struct extent_state *orig, u64 split);
 void btrfs_set_range_writeback(struct btrfs_inode *inode, u64 start, u64 end);
 vm_fault_t btrfs_page_mkwrite(struct vm_fault *vmf);
diff --git a/fs/btrfs/extent-io-tree.c b/fs/btrfs/extent-io-tree.c
index 1b4c52d7201d..124aede5e492 100644
--- a/fs/btrfs/extent-io-tree.c
+++ b/fs/btrfs/extent-io-tree.c
@@ -461,7 +461,7 @@ static int split_state(struct extent_io_tree *tree, struct extent_state *orig,
 	struct rb_node **node;
 
 	if (tree->inode)
-		btrfs_split_delalloc_extent(&tree->inode->vfs_inode, orig, split);
+		btrfs_split_delalloc_extent(tree->inode, orig, split);
 
 	prealloc->start = orig->start;
 	prealloc->end = split - 1;
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index c373125e13c2..9cbbccb2be5f 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -2277,10 +2277,10 @@ int btrfs_run_delalloc_range(struct btrfs_inode *inode, struct page *locked_page
 	return ret;
 }
 
-void btrfs_split_delalloc_extent(struct inode *inode,
+void btrfs_split_delalloc_extent(struct btrfs_inode *inode,
 				 struct extent_state *orig, u64 split)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = inode->root->fs_info;
 	u64 size;
 
 	/* not delalloc, ignore it */
@@ -2304,9 +2304,9 @@ void btrfs_split_delalloc_extent(struct inode *inode,
 			return;
 	}
 
-	spin_lock(&BTRFS_I(inode)->lock);
-	btrfs_mod_outstanding_extents(BTRFS_I(inode), 1);
-	spin_unlock(&BTRFS_I(inode)->lock);
+	spin_lock(&inode->lock);
+	btrfs_mod_outstanding_extents(inode, 1);
+	spin_unlock(&inode->lock);
 }
 
 /*
-- 
2.37.3


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 31/40] btrfs: pass btrfs_inode to btrfs_clear_delalloc_extent
  2022-11-01 20:11 [PATCH 00/40] Parameter and type changes to btrfs_inode David Sterba
                   ` (29 preceding siblings ...)
  2022-11-01 20:12 ` [PATCH 30/40] btrfs: pass btrfs_inode to btrfs_split_delalloc_extent David Sterba
@ 2022-11-01 20:12 ` David Sterba
  2022-11-01 20:12 ` [PATCH 32/40] btrfs: pass btrfs_inode to btrfs_unlink_subvol David Sterba
                   ` (9 subsequent siblings)
  40 siblings, 0 replies; 46+ messages in thread
From: David Sterba @ 2022-11-01 20:12 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

The function is for internal interfaces so we should use the
btrfs_inode.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/btrfs_inode.h    | 2 +-
 fs/btrfs/extent-io-tree.c | 2 +-
 fs/btrfs/inode.c          | 5 ++---
 3 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/fs/btrfs/btrfs_inode.h b/fs/btrfs/btrfs_inode.h
index ddf1867ba6d5..9e31dc8b0285 100644
--- a/fs/btrfs/btrfs_inode.h
+++ b/fs/btrfs/btrfs_inode.h
@@ -473,7 +473,7 @@ struct inode *btrfs_new_subvol_inode(struct user_namespace *mnt_userns,
 				     struct inode *dir);
  void btrfs_set_delalloc_extent(struct btrfs_inode *inode, struct extent_state *state,
 			        u32 bits);
-void btrfs_clear_delalloc_extent(struct inode *inode,
+void btrfs_clear_delalloc_extent(struct btrfs_inode *inode,
 				 struct extent_state *state, u32 bits);
 void btrfs_merge_delalloc_extent(struct btrfs_inode *inode, struct extent_state *new,
 				 struct extent_state *other);
diff --git a/fs/btrfs/extent-io-tree.c b/fs/btrfs/extent-io-tree.c
index 124aede5e492..285b0ff6e953 100644
--- a/fs/btrfs/extent-io-tree.c
+++ b/fs/btrfs/extent-io-tree.c
@@ -509,7 +509,7 @@ static struct extent_state *clear_state_bit(struct extent_io_tree *tree,
 	int ret;
 
 	if (tree->inode)
-		btrfs_clear_delalloc_extent(&tree->inode->vfs_inode, state, bits);
+		btrfs_clear_delalloc_extent(tree->inode, state, bits);
 
 	ret = add_extent_changeset(state, bits_to_clear, changeset, 0);
 	BUG_ON(ret < 0);
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 9cbbccb2be5f..a609b2071c99 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -2471,11 +2471,10 @@ void btrfs_set_delalloc_extent(struct btrfs_inode *inode, struct extent_state *s
  * Once a range is no longer delalloc this function ensures that proper
  * accounting happens.
  */
-void btrfs_clear_delalloc_extent(struct inode *vfs_inode,
+void btrfs_clear_delalloc_extent(struct btrfs_inode *inode,
 				 struct extent_state *state, u32 bits)
 {
-	struct btrfs_inode *inode = BTRFS_I(vfs_inode);
-	struct btrfs_fs_info *fs_info = btrfs_sb(vfs_inode->i_sb);
+	struct btrfs_fs_info *fs_info = inode->root->fs_info;
 	u64 len = state->end + 1 - state->start;
 	u32 num_extents = count_max_extents(fs_info, len);
 
-- 
2.37.3


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 32/40] btrfs: pass btrfs_inode to btrfs_unlink_subvol
  2022-11-01 20:11 [PATCH 00/40] Parameter and type changes to btrfs_inode David Sterba
                   ` (30 preceding siblings ...)
  2022-11-01 20:12 ` [PATCH 31/40] btrfs: pass btrfs_inode to btrfs_clear_delalloc_extent David Sterba
@ 2022-11-01 20:12 ` David Sterba
  2022-11-01 20:12 ` [PATCH 33/40] btrfs: pass btrfs_inode to btrfs_inode_by_name David Sterba
                   ` (8 subsequent siblings)
  40 siblings, 0 replies; 46+ messages in thread
From: David Sterba @ 2022-11-01 20:12 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

The function is for internal interfaces so we should use the
btrfs_inode.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/inode.c | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index a609b2071c99..240a95c90b9b 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -4469,9 +4469,9 @@ static int btrfs_unlink(struct inode *dir, struct dentry *dentry)
 }
 
 static int btrfs_unlink_subvol(struct btrfs_trans_handle *trans,
-			       struct inode *dir, struct dentry *dentry)
+			       struct btrfs_inode *dir, struct dentry *dentry)
 {
-	struct btrfs_root *root = BTRFS_I(dir)->root;
+	struct btrfs_root *root = dir->root;
 	struct btrfs_inode *inode = BTRFS_I(d_inode(dentry));
 	struct btrfs_path *path;
 	struct extent_buffer *leaf;
@@ -4480,10 +4480,10 @@ static int btrfs_unlink_subvol(struct btrfs_trans_handle *trans,
 	u64 index;
 	int ret;
 	u64 objectid;
-	u64 dir_ino = btrfs_ino(BTRFS_I(dir));
+	u64 dir_ino = btrfs_ino(dir);
 	struct fscrypt_name fname;
 
-	ret = fscrypt_setup_filename(dir, &dentry->d_name, 1, &fname);
+	ret = fscrypt_setup_filename(&dir->vfs_inode, &dentry->d_name, 1, &fname);
 	if (ret)
 		return ret;
 
@@ -4556,17 +4556,17 @@ static int btrfs_unlink_subvol(struct btrfs_trans_handle *trans,
 		}
 	}
 
-	ret = btrfs_delete_delayed_dir_index(trans, BTRFS_I(dir), index);
+	ret = btrfs_delete_delayed_dir_index(trans, dir, index);
 	if (ret) {
 		btrfs_abort_transaction(trans, ret);
 		goto out;
 	}
 
-	btrfs_i_size_write(BTRFS_I(dir), dir->i_size - fname.disk_name.len * 2);
-	inode_inc_iversion(dir);
-	dir->i_mtime = current_time(dir);
-	dir->i_ctime = dir->i_mtime;
-	ret = btrfs_update_inode_fallback(trans, root, BTRFS_I(dir));
+	btrfs_i_size_write(dir, dir->vfs_inode.i_size - fname.disk_name.len * 2);
+	inode_inc_iversion(&dir->vfs_inode);
+	dir->vfs_inode.i_mtime = current_time(&dir->vfs_inode);
+	dir->vfs_inode.i_ctime = dir->vfs_inode.i_mtime;
+	ret = btrfs_update_inode_fallback(trans, root, dir);
 	if (ret)
 		btrfs_abort_transaction(trans, ret);
 out:
@@ -4757,7 +4757,7 @@ int btrfs_delete_subvolume(struct btrfs_inode *dir, struct dentry *dentry)
 
 	btrfs_record_snapshot_destroy(trans, dir);
 
-	ret = btrfs_unlink_subvol(trans, &dir->vfs_inode, dentry);
+	ret = btrfs_unlink_subvol(trans, dir, dentry);
 	if (ret) {
 		btrfs_abort_transaction(trans, ret);
 		goto out_end_trans;
@@ -4861,7 +4861,7 @@ static int btrfs_rmdir(struct inode *dir, struct dentry *dentry)
 	}
 
 	if (unlikely(btrfs_ino(BTRFS_I(inode)) == BTRFS_EMPTY_SUBVOL_DIR_OBJECTID)) {
-		err = btrfs_unlink_subvol(trans, dir, dentry);
+		err = btrfs_unlink_subvol(trans, BTRFS_I(dir), dentry);
 		goto out;
 	}
 
@@ -9207,7 +9207,7 @@ static int btrfs_rename_exchange(struct inode *old_dir,
 
 	/* src is a subvolume */
 	if (old_ino == BTRFS_FIRST_FREE_OBJECTID) {
-		ret = btrfs_unlink_subvol(trans, old_dir, old_dentry);
+		ret = btrfs_unlink_subvol(trans, BTRFS_I(old_dir), old_dentry);
 	} else { /* src is an inode */
 		ret = __btrfs_unlink_inode(trans, BTRFS_I(old_dir),
 					   BTRFS_I(old_dentry->d_inode),
@@ -9222,7 +9222,7 @@ static int btrfs_rename_exchange(struct inode *old_dir,
 
 	/* dest is a subvolume */
 	if (new_ino == BTRFS_FIRST_FREE_OBJECTID) {
-		ret = btrfs_unlink_subvol(trans, new_dir, new_dentry);
+		ret = btrfs_unlink_subvol(trans, BTRFS_I(new_dir), new_dentry);
 	} else { /* dest is an inode */
 		ret = __btrfs_unlink_inode(trans, BTRFS_I(new_dir),
 					   BTRFS_I(new_dentry->d_inode),
@@ -9469,7 +9469,7 @@ static int btrfs_rename(struct user_namespace *mnt_userns,
 				BTRFS_I(old_inode), 1);
 
 	if (unlikely(old_ino == BTRFS_FIRST_FREE_OBJECTID)) {
-		ret = btrfs_unlink_subvol(trans, old_dir, old_dentry);
+		ret = btrfs_unlink_subvol(trans, BTRFS_I(old_dir), old_dentry);
 	} else {
 		ret = __btrfs_unlink_inode(trans, BTRFS_I(old_dir),
 					   BTRFS_I(d_inode(old_dentry)),
@@ -9487,7 +9487,7 @@ static int btrfs_rename(struct user_namespace *mnt_userns,
 		new_inode->i_ctime = current_time(new_inode);
 		if (unlikely(btrfs_ino(BTRFS_I(new_inode)) ==
 			     BTRFS_EMPTY_SUBVOL_DIR_OBJECTID)) {
-			ret = btrfs_unlink_subvol(trans, new_dir, new_dentry);
+			ret = btrfs_unlink_subvol(trans, BTRFS_I(new_dir), new_dentry);
 			BUG_ON(new_inode->i_nlink == 0);
 		} else {
 			ret = btrfs_unlink_inode(trans, BTRFS_I(new_dir),
-- 
2.37.3


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 33/40] btrfs: pass btrfs_inode to btrfs_inode_by_name
  2022-11-01 20:11 [PATCH 00/40] Parameter and type changes to btrfs_inode David Sterba
                   ` (31 preceding siblings ...)
  2022-11-01 20:12 ` [PATCH 32/40] btrfs: pass btrfs_inode to btrfs_unlink_subvol David Sterba
@ 2022-11-01 20:12 ` David Sterba
  2022-11-01 20:12 ` [PATCH 34/40] btrfs: pass btrfs_inode to fixup_tree_root_location David Sterba
                   ` (7 subsequent siblings)
  40 siblings, 0 replies; 46+ messages in thread
From: David Sterba @ 2022-11-01 20:12 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

The function is for internal interfaces so we should use the
btrfs_inode.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/inode.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 240a95c90b9b..0489c3df44c3 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -5564,12 +5564,12 @@ void btrfs_evict_inode(struct inode *inode)
  * If no dir entries were found, returns -ENOENT.
  * If found a corrupted location in dir entry, returns -EUCLEAN.
  */
-static int btrfs_inode_by_name(struct inode *dir, struct dentry *dentry,
+static int btrfs_inode_by_name(struct btrfs_inode *dir, struct dentry *dentry,
 			       struct btrfs_key *location, u8 *type)
 {
 	struct btrfs_dir_item *di;
 	struct btrfs_path *path;
-	struct btrfs_root *root = BTRFS_I(dir)->root;
+	struct btrfs_root *root = dir->root;
 	int ret = 0;
 	struct fscrypt_name fname;
 
@@ -5577,13 +5577,13 @@ static int btrfs_inode_by_name(struct inode *dir, struct dentry *dentry,
 	if (!path)
 		return -ENOMEM;
 
-	ret = fscrypt_setup_filename(dir, &dentry->d_name, 1, &fname);
+	ret = fscrypt_setup_filename(&dir->vfs_inode, &dentry->d_name, 1, &fname);
 	if (ret)
 		goto out;
 
 	/* This needs to handle no-key deletions later on */
 
-	di = btrfs_lookup_dir_item(NULL, root, path, btrfs_ino(BTRFS_I(dir)),
+	di = btrfs_lookup_dir_item(NULL, root, path, btrfs_ino(dir),
 				   &fname.disk_name, 0);
 	if (IS_ERR_OR_NULL(di)) {
 		ret = di ? PTR_ERR(di) : -ENOENT;
@@ -5596,7 +5596,7 @@ static int btrfs_inode_by_name(struct inode *dir, struct dentry *dentry,
 		ret = -EUCLEAN;
 		btrfs_warn(root->fs_info,
 "%s gets something invalid in DIR_ITEM (name %s, directory ino %llu, location(%llu %u %llu))",
-			   __func__, fname.disk_name.name, btrfs_ino(BTRFS_I(dir)),
+			   __func__, fname.disk_name.name, btrfs_ino(dir),
 			   location->objectid, location->type, location->offset);
 	}
 	if (!ret)
@@ -5880,7 +5880,7 @@ struct inode *btrfs_lookup_dentry(struct inode *dir, struct dentry *dentry)
 	if (dentry->d_name.len > BTRFS_NAME_LEN)
 		return ERR_PTR(-ENAMETOOLONG);
 
-	ret = btrfs_inode_by_name(dir, dentry, &location, &di_type);
+	ret = btrfs_inode_by_name(BTRFS_I(dir), dentry, &location, &di_type);
 	if (ret < 0)
 		return ERR_PTR(ret);
 
-- 
2.37.3


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 34/40] btrfs: pass btrfs_inode to fixup_tree_root_location
  2022-11-01 20:11 [PATCH 00/40] Parameter and type changes to btrfs_inode David Sterba
                   ` (32 preceding siblings ...)
  2022-11-01 20:12 ` [PATCH 33/40] btrfs: pass btrfs_inode to btrfs_inode_by_name David Sterba
@ 2022-11-01 20:12 ` David Sterba
  2022-11-01 20:12 ` [PATCH 35/40] btrfs: pass btrfs_inode to inode_tree_add David Sterba
                   ` (6 subsequent siblings)
  40 siblings, 0 replies; 46+ messages in thread
From: David Sterba @ 2022-11-01 20:12 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

The function is for internal interfaces so we should use the
btrfs_inode.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/inode.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 0489c3df44c3..4b4e360ce878 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -5613,7 +5613,7 @@ static int btrfs_inode_by_name(struct btrfs_inode *dir, struct dentry *dentry,
  * is kind of like crossing a mount point.
  */
 static int fixup_tree_root_location(struct btrfs_fs_info *fs_info,
-				    struct inode *dir,
+				    struct btrfs_inode *dir,
 				    struct dentry *dentry,
 				    struct btrfs_key *location,
 				    struct btrfs_root **sub_root)
@@ -5627,7 +5627,7 @@ static int fixup_tree_root_location(struct btrfs_fs_info *fs_info,
 	int err = 0;
 	struct fscrypt_name fname;
 
-	ret = fscrypt_setup_filename(dir, &dentry->d_name, 0, &fname);
+	ret = fscrypt_setup_filename(&dir->vfs_inode, &dentry->d_name, 0, &fname);
 	if (ret)
 		return ret;
 
@@ -5638,7 +5638,7 @@ static int fixup_tree_root_location(struct btrfs_fs_info *fs_info,
 	}
 
 	err = -ENOENT;
-	key.objectid = BTRFS_I(dir)->root->root_key.objectid;
+	key.objectid = dir->root->root_key.objectid;
 	key.type = BTRFS_ROOT_REF_KEY;
 	key.offset = location->objectid;
 
@@ -5651,7 +5651,7 @@ static int fixup_tree_root_location(struct btrfs_fs_info *fs_info,
 
 	leaf = path->nodes[0];
 	ref = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_root_ref);
-	if (btrfs_root_ref_dirid(leaf, ref) != btrfs_ino(BTRFS_I(dir)) ||
+	if (btrfs_root_ref_dirid(leaf, ref) != btrfs_ino(dir) ||
 	    btrfs_root_ref_name_len(leaf, ref) != fname.disk_name.len)
 		goto out;
 
@@ -5901,7 +5901,7 @@ struct inode *btrfs_lookup_dentry(struct inode *dir, struct dentry *dentry)
 		return inode;
 	}
 
-	ret = fixup_tree_root_location(fs_info, dir, dentry,
+	ret = fixup_tree_root_location(fs_info, BTRFS_I(dir), dentry,
 				       &location, &sub_root);
 	if (ret < 0) {
 		if (ret != -ENOENT)
-- 
2.37.3


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 35/40] btrfs: pass btrfs_inode to inode_tree_add
  2022-11-01 20:11 [PATCH 00/40] Parameter and type changes to btrfs_inode David Sterba
                   ` (33 preceding siblings ...)
  2022-11-01 20:12 ` [PATCH 34/40] btrfs: pass btrfs_inode to fixup_tree_root_location David Sterba
@ 2022-11-01 20:12 ` David Sterba
  2022-11-01 20:12 ` [PATCH 36/40] btrfs: pass btrfs_inode to btrfs_inherit_iflags David Sterba
                   ` (5 subsequent siblings)
  40 siblings, 0 replies; 46+ messages in thread
From: David Sterba @ 2022-11-01 20:12 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

The function is for internal interfaces so we should use the
btrfs_inode.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/inode.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 4b4e360ce878..c08c8d616eb2 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -5679,16 +5679,16 @@ static int fixup_tree_root_location(struct btrfs_fs_info *fs_info,
 	return err;
 }
 
-static void inode_tree_add(struct inode *inode)
+static void inode_tree_add(struct btrfs_inode *inode)
 {
-	struct btrfs_root *root = BTRFS_I(inode)->root;
+	struct btrfs_root *root = inode->root;
 	struct btrfs_inode *entry;
 	struct rb_node **p;
 	struct rb_node *parent;
-	struct rb_node *new = &BTRFS_I(inode)->rb_node;
-	u64 ino = btrfs_ino(BTRFS_I(inode));
+	struct rb_node *new = &inode->rb_node;
+	u64 ino = btrfs_ino(inode);
 
-	if (inode_unhashed(inode))
+	if (inode_unhashed(&inode->vfs_inode))
 		return;
 	parent = NULL;
 	spin_lock(&root->inode_lock);
@@ -5800,7 +5800,7 @@ struct inode *btrfs_iget_path(struct super_block *s, u64 ino,
 
 		ret = btrfs_read_locked_inode(inode, path);
 		if (!ret) {
-			inode_tree_add(inode);
+			inode_tree_add(BTRFS_I(inode));
 			unlock_new_inode(inode);
 		} else {
 			iget_failed(inode);
@@ -6567,7 +6567,7 @@ int btrfs_create_new_inode(struct btrfs_trans_handle *trans,
 		}
 	}
 
-	inode_tree_add(inode);
+	inode_tree_add(BTRFS_I(inode));
 
 	trace_btrfs_inode_new(inode);
 	btrfs_set_inode_last_trans(trans, BTRFS_I(inode));
-- 
2.37.3


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 36/40] btrfs: pass btrfs_inode to btrfs_inherit_iflags
  2022-11-01 20:11 [PATCH 00/40] Parameter and type changes to btrfs_inode David Sterba
                   ` (34 preceding siblings ...)
  2022-11-01 20:12 ` [PATCH 35/40] btrfs: pass btrfs_inode to inode_tree_add David Sterba
@ 2022-11-01 20:12 ` David Sterba
  2022-11-01 20:13 ` [PATCH 37/40] btrfs: switch async_chunk::inode to btrfs_inode David Sterba
                   ` (4 subsequent siblings)
  40 siblings, 0 replies; 46+ messages in thread
From: David Sterba @ 2022-11-01 20:12 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

The function is for internal interfaces so we should use the
btrfs_inode.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/inode.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index c08c8d616eb2..cb284388896c 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -6344,27 +6344,27 @@ void btrfs_new_inode_args_destroy(struct btrfs_new_inode_args *args)
  *
  * Currently only the compression flags and the cow flags are inherited.
  */
-static void btrfs_inherit_iflags(struct inode *inode, struct inode *dir)
+static void btrfs_inherit_iflags(struct btrfs_inode *inode, struct btrfs_inode *dir)
 {
 	unsigned int flags;
 
-	flags = BTRFS_I(dir)->flags;
+	flags = dir->flags;
 
 	if (flags & BTRFS_INODE_NOCOMPRESS) {
-		BTRFS_I(inode)->flags &= ~BTRFS_INODE_COMPRESS;
-		BTRFS_I(inode)->flags |= BTRFS_INODE_NOCOMPRESS;
+		inode->flags &= ~BTRFS_INODE_COMPRESS;
+		inode->flags |= BTRFS_INODE_NOCOMPRESS;
 	} else if (flags & BTRFS_INODE_COMPRESS) {
-		BTRFS_I(inode)->flags &= ~BTRFS_INODE_NOCOMPRESS;
-		BTRFS_I(inode)->flags |= BTRFS_INODE_COMPRESS;
+		inode->flags &= ~BTRFS_INODE_NOCOMPRESS;
+		inode->flags |= BTRFS_INODE_COMPRESS;
 	}
 
 	if (flags & BTRFS_INODE_NODATACOW) {
-		BTRFS_I(inode)->flags |= BTRFS_INODE_NODATACOW;
-		if (S_ISREG(inode->i_mode))
-			BTRFS_I(inode)->flags |= BTRFS_INODE_NODATASUM;
+		inode->flags |= BTRFS_INODE_NODATACOW;
+		if (S_ISREG(inode->vfs_inode.i_mode))
+			inode->flags |= BTRFS_INODE_NODATASUM;
 	}
 
-	btrfs_sync_inode_flags_to_i_flags(inode);
+	btrfs_sync_inode_flags_to_i_flags(&inode->vfs_inode);
 }
 
 int btrfs_create_new_inode(struct btrfs_trans_handle *trans,
@@ -6423,7 +6423,7 @@ int btrfs_create_new_inode(struct btrfs_trans_handle *trans,
 	 * change it now without compatibility issues.
 	 */
 	if (!args->subvol)
-		btrfs_inherit_iflags(inode, dir);
+		btrfs_inherit_iflags(BTRFS_I(inode), BTRFS_I(dir));
 
 	if (S_ISREG(inode->i_mode)) {
 		if (btrfs_test_opt(fs_info, NODATASUM))
-- 
2.37.3


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 37/40] btrfs: switch async_chunk::inode to btrfs_inode
  2022-11-01 20:11 [PATCH 00/40] Parameter and type changes to btrfs_inode David Sterba
                   ` (35 preceding siblings ...)
  2022-11-01 20:12 ` [PATCH 36/40] btrfs: pass btrfs_inode to btrfs_inherit_iflags David Sterba
@ 2022-11-01 20:13 ` David Sterba
  2022-11-01 20:13 ` [PATCH 38/40] btrfs: use btrfs_inode inside compress_file_range David Sterba
                   ` (3 subsequent siblings)
  40 siblings, 0 replies; 46+ messages in thread
From: David Sterba @ 2022-11-01 20:13 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

The async_chunk::inode structure is for internal interfaces so we should
use the btrfs_inode.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/inode.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index cb284388896c..ad5038dec0db 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -520,7 +520,7 @@ struct async_extent {
 };
 
 struct async_chunk {
-	struct inode *inode;
+	struct btrfs_inode *inode;
 	struct page *locked_page;
 	u64 start;
 	u64 end;
@@ -648,7 +648,7 @@ static inline void inode_should_defrag(struct btrfs_inode *inode,
  */
 static noinline int compress_file_range(struct async_chunk *async_chunk)
 {
-	struct inode *inode = async_chunk->inode;
+	struct inode *inode = &async_chunk->inode->vfs_inode;
 	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
 	u64 blocksize = fs_info->sectorsize;
 	u64 start = async_chunk->start;
@@ -1113,7 +1113,7 @@ static int submit_one_async_extent(struct btrfs_inode *inode,
  */
 static noinline void submit_compressed_extents(struct async_chunk *async_chunk)
 {
-	struct btrfs_inode *inode = BTRFS_I(async_chunk->inode);
+	struct btrfs_inode *inode = async_chunk->inode;
 	struct btrfs_fs_info *fs_info = inode->root->fs_info;
 	struct async_extent *async_extent;
 	u64 alloc_hint = 0;
@@ -1494,7 +1494,7 @@ static noinline void async_cow_start(struct btrfs_work *work)
 
 	compressed_extents = compress_file_range(async_chunk);
 	if (compressed_extents == 0) {
-		btrfs_add_delayed_iput(async_chunk->inode);
+		btrfs_add_delayed_iput(&async_chunk->inode->vfs_inode);
 		async_chunk->inode = NULL;
 	}
 }
@@ -1534,7 +1534,7 @@ static noinline void async_cow_free(struct btrfs_work *work)
 
 	async_chunk = container_of(work, struct async_chunk, work);
 	if (async_chunk->inode)
-		btrfs_add_delayed_iput(async_chunk->inode);
+		btrfs_add_delayed_iput(&async_chunk->inode->vfs_inode);
 	if (async_chunk->blkcg_css)
 		css_put(async_chunk->blkcg_css);
 
@@ -1602,7 +1602,7 @@ static int cow_file_range_async(struct btrfs_inode *inode,
 		 */
 		ihold(&inode->vfs_inode);
 		async_chunk[i].async_cow = ctx;
-		async_chunk[i].inode = &inode->vfs_inode;
+		async_chunk[i].inode = inode;
 		async_chunk[i].start = start;
 		async_chunk[i].end = cur_end;
 		async_chunk[i].write_flags = write_flags;
-- 
2.37.3


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 38/40] btrfs: use btrfs_inode inside compress_file_range
  2022-11-01 20:11 [PATCH 00/40] Parameter and type changes to btrfs_inode David Sterba
                   ` (36 preceding siblings ...)
  2022-11-01 20:13 ` [PATCH 37/40] btrfs: switch async_chunk::inode to btrfs_inode David Sterba
@ 2022-11-01 20:13 ` David Sterba
  2022-11-01 20:13 ` [PATCH 39/40] btrfs: use btrfs_inode inside btrfs_verify_data_csum David Sterba
                   ` (2 subsequent siblings)
  40 siblings, 0 replies; 46+ messages in thread
From: David Sterba @ 2022-11-01 20:13 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

The function is mostly using internal interfaces so we should use the
btrfs_inode.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/inode.c | 37 ++++++++++++++++++-------------------
 1 file changed, 18 insertions(+), 19 deletions(-)

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index ad5038dec0db..c55ffb856ae7 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -648,8 +648,8 @@ static inline void inode_should_defrag(struct btrfs_inode *inode,
  */
 static noinline int compress_file_range(struct async_chunk *async_chunk)
 {
-	struct inode *inode = &async_chunk->inode->vfs_inode;
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_inode *inode = async_chunk->inode;
+	struct btrfs_fs_info *fs_info = inode->root->fs_info;
 	u64 blocksize = fs_info->sectorsize;
 	u64 start = async_chunk->start;
 	u64 end = async_chunk->end;
@@ -666,8 +666,7 @@ static noinline int compress_file_range(struct async_chunk *async_chunk)
 	int compressed_extents = 0;
 	int redirty = 0;
 
-	inode_should_defrag(BTRFS_I(inode), start, end, end - start + 1,
-			SZ_16K);
+	inode_should_defrag(inode, start, end, end - start + 1, SZ_16K);
 
 	/*
 	 * We need to save i_size before now because it could change in between
@@ -679,7 +678,7 @@ static noinline int compress_file_range(struct async_chunk *async_chunk)
 	 * does that for us.
 	 */
 	barrier();
-	i_size = i_size_read(inode);
+	i_size = i_size_read(&inode->vfs_inode);
 	barrier();
 	actual_end = min_t(u64, i_size, end + 1);
 again:
@@ -708,7 +707,7 @@ static noinline int compress_file_range(struct async_chunk *async_chunk)
 	 * isn't an inline extent, since it doesn't save disk space at all.
 	 */
 	if (total_compressed <= blocksize &&
-	   (start > 0 || end + 1 < BTRFS_I(inode)->disk_i_size))
+	   (start > 0 || end + 1 < inode->disk_i_size))
 		goto cleanup_and_bail_uncompressed;
 
 	/*
@@ -732,7 +731,7 @@ static noinline int compress_file_range(struct async_chunk *async_chunk)
 	 * inode has not been flagged as nocompress.  This flag can
 	 * change at any time if we discover bad compression ratios.
 	 */
-	if (inode_need_compress(BTRFS_I(inode), start, end)) {
+	if (inode_need_compress(inode, start, end)) {
 		WARN_ON(pages);
 		pages = kcalloc(nr_pages, sizeof(struct page *), GFP_NOFS);
 		if (!pages) {
@@ -741,10 +740,10 @@ static noinline int compress_file_range(struct async_chunk *async_chunk)
 			goto cont;
 		}
 
-		if (BTRFS_I(inode)->defrag_compress)
-			compress_type = BTRFS_I(inode)->defrag_compress;
-		else if (BTRFS_I(inode)->prop_compress)
-			compress_type = BTRFS_I(inode)->prop_compress;
+		if (inode->defrag_compress)
+			compress_type = inode->defrag_compress;
+		else if (inode->prop_compress)
+			compress_type = inode->prop_compress;
 
 		/*
 		 * we need to call clear_page_dirty_for_io on each
@@ -759,14 +758,14 @@ static noinline int compress_file_range(struct async_chunk *async_chunk)
 		 * has moved, the end is the original one.
 		 */
 		if (!redirty) {
-			extent_range_clear_dirty_for_io(inode, start, end);
+			extent_range_clear_dirty_for_io(&inode->vfs_inode, start, end);
 			redirty = 1;
 		}
 
 		/* Compression level is applied here and only here */
 		ret = btrfs_compress_pages(
 			compress_type | (fs_info->compress_level << 4),
-					   inode->i_mapping, start,
+					   inode->vfs_inode.i_mapping, start,
 					   pages,
 					   &nr_pages,
 					   &total_in,
@@ -795,12 +794,12 @@ static noinline int compress_file_range(struct async_chunk *async_chunk)
 			/* we didn't compress the entire range, try
 			 * to make an uncompressed inline extent.
 			 */
-			ret = cow_file_range_inline(BTRFS_I(inode), actual_end,
+			ret = cow_file_range_inline(inode, actual_end,
 						    0, BTRFS_COMPRESS_NONE,
 						    NULL, false);
 		} else {
 			/* try making a compressed inline extent */
-			ret = cow_file_range_inline(BTRFS_I(inode), actual_end,
+			ret = cow_file_range_inline(inode, actual_end,
 						    total_compressed,
 						    compress_type, pages,
 						    false);
@@ -823,7 +822,7 @@ static noinline int compress_file_range(struct async_chunk *async_chunk)
 			 * our outstanding extent for clearing delalloc for this
 			 * range.
 			 */
-			extent_clear_unlock_delalloc(BTRFS_I(inode), start, end,
+			extent_clear_unlock_delalloc(inode, start, end,
 						     NULL,
 						     clear_flags,
 						     PAGE_UNLOCK |
@@ -898,8 +897,8 @@ static noinline int compress_file_range(struct async_chunk *async_chunk)
 
 		/* flag the file so we don't compress in the future */
 		if (!btrfs_test_opt(fs_info, FORCE_COMPRESS) &&
-		    !(BTRFS_I(inode)->prop_compress)) {
-			BTRFS_I(inode)->flags |= BTRFS_INODE_NOCOMPRESS;
+		    !(inode->prop_compress)) {
+			inode->flags |= BTRFS_INODE_NOCOMPRESS;
 		}
 	}
 cleanup_and_bail_uncompressed:
@@ -917,7 +916,7 @@ static noinline int compress_file_range(struct async_chunk *async_chunk)
 	}
 
 	if (redirty)
-		extent_range_redirty_for_io(inode, start, end);
+		extent_range_redirty_for_io(&inode->vfs_inode, start, end);
 	add_async_extent(async_chunk, start, end - start + 1, 0, NULL, 0,
 			 BTRFS_COMPRESS_NONE);
 	compressed_extents++;
-- 
2.37.3


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 39/40] btrfs: use btrfs_inode inside btrfs_verify_data_csum
  2022-11-01 20:11 [PATCH 00/40] Parameter and type changes to btrfs_inode David Sterba
                   ` (37 preceding siblings ...)
  2022-11-01 20:13 ` [PATCH 38/40] btrfs: use btrfs_inode inside compress_file_range David Sterba
@ 2022-11-01 20:13 ` David Sterba
  2022-11-01 20:13 ` [PATCH 40/40] btrfs: pass btrfs_inode to btrfs_add_delayed_iput David Sterba
  2022-11-03 14:45 ` [PATCH 00/40] Parameter and type changes to btrfs_inode Anand Jain
  40 siblings, 0 replies; 46+ messages in thread
From: David Sterba @ 2022-11-01 20:13 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

The function is mostly using internal interfaces so we should use the
btrfs_inode.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/inode.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index c55ffb856ae7..9d4e97eb5651 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -3529,10 +3529,10 @@ unsigned int btrfs_verify_data_csum(struct btrfs_bio *bbio,
 				    u32 bio_offset, struct page *page,
 				    u64 start, u64 end)
 {
-	struct inode *inode = page->mapping->host;
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
-	struct extent_io_tree *io_tree = &BTRFS_I(inode)->io_tree;
-	struct btrfs_root *root = BTRFS_I(inode)->root;
+	struct btrfs_inode *inode = BTRFS_I(page->mapping->host);
+	struct btrfs_root *root = inode->root;
+	struct btrfs_fs_info *fs_info = root->fs_info;
+	struct extent_io_tree *io_tree = &inode->io_tree;
 	const u32 sectorsize = root->fs_info->sectorsize;
 	u32 pg_off;
 	unsigned int result = 0;
@@ -3545,7 +3545,7 @@ unsigned int btrfs_verify_data_csum(struct btrfs_bio *bbio,
 	if (bbio->csum == NULL)
 		return 0;
 
-	if (BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM)
+	if (inode->flags & BTRFS_INODE_NODATASUM)
 		return 0;
 
 	if (unlikely(test_bit(BTRFS_FS_STATE_NO_CSUMS, &fs_info->fs_state)))
@@ -3569,7 +3569,7 @@ unsigned int btrfs_verify_data_csum(struct btrfs_bio *bbio,
 					  EXTENT_NODATASUM);
 			continue;
 		}
-		ret = btrfs_check_data_csum(BTRFS_I(inode), bbio, bio_offset, page, pg_off);
+		ret = btrfs_check_data_csum(inode, bbio, bio_offset, page, pg_off);
 		if (ret < 0) {
 			const int nr_bit = (pg_off - offset_in_page(start)) >>
 				     root->fs_info->sectorsize_bits;
-- 
2.37.3


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 40/40] btrfs: pass btrfs_inode to btrfs_add_delayed_iput
  2022-11-01 20:11 [PATCH 00/40] Parameter and type changes to btrfs_inode David Sterba
                   ` (38 preceding siblings ...)
  2022-11-01 20:13 ` [PATCH 39/40] btrfs: use btrfs_inode inside btrfs_verify_data_csum David Sterba
@ 2022-11-01 20:13 ` David Sterba
  2022-11-03 14:45 ` [PATCH 00/40] Parameter and type changes to btrfs_inode Anand Jain
  40 siblings, 0 replies; 46+ messages in thread
From: David Sterba @ 2022-11-01 20:13 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

The function is for internal interfaces so we should use the
btrfs_inode.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/btrfs_inode.h      |  2 +-
 fs/btrfs/extent_io.c        |  2 +-
 fs/btrfs/free-space-cache.c |  4 ++--
 fs/btrfs/inode.c            | 19 +++++++++----------
 fs/btrfs/ordered-data.c     |  2 +-
 fs/btrfs/relocation.c       |  4 ++--
 fs/btrfs/tree-log.c         | 24 ++++++++++++------------
 7 files changed, 28 insertions(+), 29 deletions(-)

diff --git a/fs/btrfs/btrfs_inode.h b/fs/btrfs/btrfs_inode.h
index 9e31dc8b0285..195c09e20609 100644
--- a/fs/btrfs/btrfs_inode.h
+++ b/fs/btrfs/btrfs_inode.h
@@ -501,7 +501,7 @@ int btrfs_update_inode_fallback(struct btrfs_trans_handle *trans,
 int btrfs_orphan_add(struct btrfs_trans_handle *trans, struct btrfs_inode *inode);
 int btrfs_orphan_cleanup(struct btrfs_root *root);
 int btrfs_cont_expand(struct btrfs_inode *inode, loff_t oldsize, loff_t size);
-void btrfs_add_delayed_iput(struct inode *inode);
+void btrfs_add_delayed_iput(struct btrfs_inode *inode);
 void btrfs_run_delayed_iputs(struct btrfs_fs_info *fs_info);
 int btrfs_wait_on_delayed_iputs(struct btrfs_fs_info *fs_info);
 int btrfs_prealloc_file_range(struct inode *inode, int mode,
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 05768f7f7872..859a41624c31 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -3228,7 +3228,7 @@ static int extent_write_cache_pages(struct address_space *mapping,
 	if (wbc->range_cyclic || (wbc->nr_to_write > 0 && range_whole))
 		mapping->writeback_index = done_index;
 
-	btrfs_add_delayed_iput(inode);
+	btrfs_add_delayed_iput(BTRFS_I(inode));
 	return ret;
 }
 
diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
index 627bd6120368..0d250d052487 100644
--- a/fs/btrfs/free-space-cache.c
+++ b/fs/btrfs/free-space-cache.c
@@ -260,7 +260,7 @@ int btrfs_remove_free_space_inode(struct btrfs_trans_handle *trans,
 	}
 	ret = btrfs_orphan_add(trans, BTRFS_I(inode));
 	if (ret) {
-		btrfs_add_delayed_iput(inode);
+		btrfs_add_delayed_iput(BTRFS_I(inode));
 		goto out;
 	}
 	clear_nlink(inode);
@@ -274,7 +274,7 @@ int btrfs_remove_free_space_inode(struct btrfs_trans_handle *trans,
 		spin_unlock(&block_group->lock);
 	}
 	/* One for the lookup ref */
-	btrfs_add_delayed_iput(inode);
+	btrfs_add_delayed_iput(BTRFS_I(inode));
 
 	key.objectid = BTRFS_FREE_SPACE_OBJECTID;
 	key.type = 0;
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 9d4e97eb5651..c6af4843ddaf 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -1493,7 +1493,7 @@ static noinline void async_cow_start(struct btrfs_work *work)
 
 	compressed_extents = compress_file_range(async_chunk);
 	if (compressed_extents == 0) {
-		btrfs_add_delayed_iput(&async_chunk->inode->vfs_inode);
+		btrfs_add_delayed_iput(async_chunk->inode);
 		async_chunk->inode = NULL;
 	}
 }
@@ -1533,7 +1533,7 @@ static noinline void async_cow_free(struct btrfs_work *work)
 
 	async_chunk = container_of(work, struct async_chunk, work);
 	if (async_chunk->inode)
-		btrfs_add_delayed_iput(&async_chunk->inode->vfs_inode);
+		btrfs_add_delayed_iput(async_chunk->inode);
 	if (async_chunk->blkcg_css)
 		css_put(async_chunk->blkcg_css);
 
@@ -3016,7 +3016,7 @@ static void btrfs_writepage_fixup_worker(struct btrfs_work *work)
 	 * that could need flushing space. Recursing back to fixup worker would
 	 * deadlock.
 	 */
-	btrfs_add_delayed_iput(&inode->vfs_inode);
+	btrfs_add_delayed_iput(inode);
 }
 
 /*
@@ -3590,18 +3590,17 @@ unsigned int btrfs_verify_data_csum(struct btrfs_bio *bbio,
  * the inode to the delayed iput machinery. Delayed iputs are processed at
  * transaction commit time/superblock commit/cleaner kthread.
  */
-void btrfs_add_delayed_iput(struct inode *inode)
+void btrfs_add_delayed_iput(struct btrfs_inode *inode)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
-	struct btrfs_inode *binode = BTRFS_I(inode);
+	struct btrfs_fs_info *fs_info = inode->root->fs_info;
 
-	if (atomic_add_unless(&inode->i_count, -1, 1))
+	if (atomic_add_unless(&inode->vfs_inode.i_count, -1, 1))
 		return;
 
 	atomic_inc(&fs_info->nr_delayed_iputs);
 	spin_lock(&fs_info->delayed_iput_lock);
-	ASSERT(list_empty(&binode->delayed_iput));
-	list_add_tail(&binode->delayed_iput, &fs_info->delayed_iputs);
+	ASSERT(list_empty(&inode->delayed_iput));
+	list_add_tail(&inode->delayed_iput, &fs_info->delayed_iputs);
 	spin_unlock(&fs_info->delayed_iput_lock);
 	if (!test_bit(BTRFS_FS_CLEANER_RUNNING, &fs_info->flags))
 		wake_up_process(fs_info->cleaner_kthread);
@@ -9660,7 +9659,7 @@ static int start_delalloc_inodes(struct btrfs_root *root,
 					 &work->work);
 		} else {
 			ret = filemap_fdatawrite_wbc(inode->i_mapping, wbc);
-			btrfs_add_delayed_iput(inode);
+			btrfs_add_delayed_iput(BTRFS_I(inode));
 			if (ret || wbc->nr_to_write <= 0)
 				goto out;
 		}
diff --git a/fs/btrfs/ordered-data.c b/fs/btrfs/ordered-data.c
index 8fda1949b71b..4bed0839b640 100644
--- a/fs/btrfs/ordered-data.c
+++ b/fs/btrfs/ordered-data.c
@@ -504,7 +504,7 @@ void btrfs_put_ordered_extent(struct btrfs_ordered_extent *entry)
 		ASSERT(list_empty(&entry->log_list));
 		ASSERT(RB_EMPTY_NODE(&entry->rb_node));
 		if (entry->inode)
-			btrfs_add_delayed_iput(entry->inode);
+			btrfs_add_delayed_iput(BTRFS_I(entry->inode));
 		while (!list_empty(&entry->list)) {
 			cur = entry->list.next;
 			sum = list_entry(cur, struct btrfs_ordered_sum, list);
diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index bdf845077002..6452f4faaa04 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -1117,7 +1117,7 @@ int replace_file_extents(struct btrfs_trans_handle *trans,
 				inode = find_next_inode(root, key.objectid);
 				first = 0;
 			} else if (inode && btrfs_ino(BTRFS_I(inode)) < key.objectid) {
-				btrfs_add_delayed_iput(inode);
+				btrfs_add_delayed_iput(BTRFS_I(inode));
 				inode = find_next_inode(root, key.objectid);
 			}
 			if (inode && btrfs_ino(BTRFS_I(inode)) == key.objectid) {
@@ -1181,7 +1181,7 @@ int replace_file_extents(struct btrfs_trans_handle *trans,
 	if (dirty)
 		btrfs_mark_buffer_dirty(leaf);
 	if (inode)
-		btrfs_add_delayed_iput(inode);
+		btrfs_add_delayed_iput(BTRFS_I(inode));
 	return ret;
 }
 
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index 8d559b076405..8fcfaf015a70 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -5422,7 +5422,7 @@ static int log_new_dir_dentries(struct btrfs_trans_handle *trans,
 			}
 
 			if (!need_log_inode(trans, BTRFS_I(di_inode))) {
-				btrfs_add_delayed_iput(di_inode);
+				btrfs_add_delayed_iput(BTRFS_I(di_inode));
 				break;
 			}
 
@@ -5431,7 +5431,7 @@ static int log_new_dir_dentries(struct btrfs_trans_handle *trans,
 				log_mode = LOG_INODE_ALL;
 			ret = btrfs_log_inode(trans, BTRFS_I(di_inode),
 					      log_mode, ctx);
-			btrfs_add_delayed_iput(di_inode);
+			btrfs_add_delayed_iput(BTRFS_I(di_inode));
 			if (ret)
 				goto out;
 			if (ctx->log_new_dentries) {
@@ -5625,11 +5625,11 @@ static int add_conflicting_inode(struct btrfs_trans_handle *trans,
 	 * so that the log ends up with the new name and without the old name.
 	 */
 	if (!need_log_inode(trans, BTRFS_I(inode))) {
-		btrfs_add_delayed_iput(inode);
+		btrfs_add_delayed_iput(BTRFS_I(inode));
 		return 0;
 	}
 
-	btrfs_add_delayed_iput(inode);
+	btrfs_add_delayed_iput(BTRFS_I(inode));
 
 	ino_elem = kmalloc(sizeof(*ino_elem), GFP_NOFS);
 	if (!ino_elem)
@@ -5704,7 +5704,7 @@ static int log_conflicting_inodes(struct btrfs_trans_handle *trans,
 			 */
 			ret = btrfs_log_inode(trans, BTRFS_I(inode),
 					      LOG_INODE_ALL, ctx);
-			btrfs_add_delayed_iput(inode);
+			btrfs_add_delayed_iput(BTRFS_I(inode));
 			if (ret)
 				break;
 			continue;
@@ -5721,7 +5721,7 @@ static int log_conflicting_inodes(struct btrfs_trans_handle *trans,
 		 * that, we can avoid doing it again.
 		 */
 		if (!need_log_inode(trans, BTRFS_I(inode))) {
-			btrfs_add_delayed_iput(inode);
+			btrfs_add_delayed_iput(BTRFS_I(inode));
 			continue;
 		}
 
@@ -5733,7 +5733,7 @@ static int log_conflicting_inodes(struct btrfs_trans_handle *trans,
 		 * log with the new name before we unpin it.
 		 */
 		ret = btrfs_log_inode(trans, BTRFS_I(inode), LOG_INODE_EXISTS, ctx);
-		btrfs_add_delayed_iput(inode);
+		btrfs_add_delayed_iput(BTRFS_I(inode));
 		if (ret)
 			break;
 	}
@@ -6243,7 +6243,7 @@ static int log_new_delayed_dentries(struct btrfs_trans_handle *trans,
 		}
 
 		if (!need_log_inode(trans, BTRFS_I(di_inode))) {
-			btrfs_add_delayed_iput(di_inode);
+			btrfs_add_delayed_iput(BTRFS_I(di_inode));
 			continue;
 		}
 
@@ -6256,7 +6256,7 @@ static int log_new_delayed_dentries(struct btrfs_trans_handle *trans,
 		if (!ret && ctx->log_new_dentries)
 			ret = log_new_dir_dentries(trans, BTRFS_I(di_inode), ctx);
 
-		btrfs_add_delayed_iput(di_inode);
+		btrfs_add_delayed_iput(BTRFS_I(di_inode));
 
 		if (ret)
 			break;
@@ -6717,7 +6717,7 @@ static int btrfs_log_all_parents(struct btrfs_trans_handle *trans,
 			}
 
 			if (!need_log_inode(trans, BTRFS_I(dir_inode))) {
-				btrfs_add_delayed_iput(dir_inode);
+				btrfs_add_delayed_iput(BTRFS_I(dir_inode));
 				continue;
 			}
 
@@ -6727,7 +6727,7 @@ static int btrfs_log_all_parents(struct btrfs_trans_handle *trans,
 			if (!ret && ctx->log_new_dentries)
 				ret = log_new_dir_dentries(trans,
 						   BTRFS_I(dir_inode), ctx);
-			btrfs_add_delayed_iput(dir_inode);
+			btrfs_add_delayed_iput(BTRFS_I(dir_inode));
 			if (ret)
 				goto out;
 		}
@@ -6772,7 +6772,7 @@ static int log_new_ancestors(struct btrfs_trans_handle *trans,
 		    need_log_inode(trans, BTRFS_I(inode)))
 			ret = btrfs_log_inode(trans, BTRFS_I(inode),
 					      LOG_INODE_EXISTS, ctx);
-		btrfs_add_delayed_iput(inode);
+		btrfs_add_delayed_iput(BTRFS_I(inode));
 		if (ret)
 			return ret;
 
-- 
2.37.3


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* Re: [PATCH 04/40] btrfs: simplify btree_submit_bio_start and btrfs_submit_bio_start parameters
  2022-11-01 20:11 ` [PATCH 04/40] btrfs: simplify btree_submit_bio_start and btrfs_submit_bio_start parameters David Sterba
@ 2022-11-02  0:12   ` Anand Jain
  2022-11-03 13:28     ` David Sterba
  0 siblings, 1 reply; 46+ messages in thread
From: Anand Jain @ 2022-11-02  0:12 UTC (permalink / raw)
  To: David Sterba, linux-btrfs




> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
> index 962e39b4f7cb..2a61b610e02b 100644
> --- a/fs/btrfs/inode.c
> +++ b/fs/btrfs/inode.c
> @@ -2550,8 +2550,7 @@ void btrfs_clear_delalloc_extent(struct inode *vfs_inode,
>    * At IO completion time the cums attached on the ordered extent record
>    * are inserted into the btree
>    */
> -blk_status_t btrfs_submit_bio_start(struct inode *inode, struct bio *bio,
> -				    u64 dio_file_offset)

> +blk_status_t btrfs_submit_bio_start(struct inode *inode, struct bio *bio);
  Remove the semicolon at the end of the function declaration.

>   {
>   	return btrfs_csum_one_bio(BTRFS_I(inode), bio, (u64)-1, false);
>   }


^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: [PATCH 04/40] btrfs: simplify btree_submit_bio_start and btrfs_submit_bio_start parameters
  2022-11-02  0:12   ` Anand Jain
@ 2022-11-03 13:28     ` David Sterba
  2022-11-03 14:34       ` Anand Jain
  0 siblings, 1 reply; 46+ messages in thread
From: David Sterba @ 2022-11-03 13:28 UTC (permalink / raw)
  To: Anand Jain; +Cc: David Sterba, linux-btrfs

On Wed, Nov 02, 2022 at 08:12:06AM +0800, Anand Jain wrote:
> > diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
> > index 962e39b4f7cb..2a61b610e02b 100644
> > --- a/fs/btrfs/inode.c
> > +++ b/fs/btrfs/inode.c
> > @@ -2550,8 +2550,7 @@ void btrfs_clear_delalloc_extent(struct inode *vfs_inode,
> >    * At IO completion time the cums attached on the ordered extent record
> >    * are inserted into the btree
> >    */
> > -blk_status_t btrfs_submit_bio_start(struct inode *inode, struct bio *bio,
> > -				    u64 dio_file_offset)
> 
> > +blk_status_t btrfs_submit_bio_start(struct inode *inode, struct bio *bio);
>   Remove the semicolon at the end of the function declaration.

Right, thanks. It gets removed in the next patch so the whole series
compiles, I don't think it needs to be resent.

^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: [PATCH 04/40] btrfs: simplify btree_submit_bio_start and btrfs_submit_bio_start parameters
  2022-11-03 13:28     ` David Sterba
@ 2022-11-03 14:34       ` Anand Jain
  0 siblings, 0 replies; 46+ messages in thread
From: Anand Jain @ 2022-11-03 14:34 UTC (permalink / raw)
  To: dsterba; +Cc: David Sterba, linux-btrfs

On 03/11/2022 21:28, David Sterba wrote:
> On Wed, Nov 02, 2022 at 08:12:06AM +0800, Anand Jain wrote:
>>> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
>>> index 962e39b4f7cb..2a61b610e02b 100644
>>> --- a/fs/btrfs/inode.c
>>> +++ b/fs/btrfs/inode.c
>>> @@ -2550,8 +2550,7 @@ void btrfs_clear_delalloc_extent(struct inode *vfs_inode,
>>>     * At IO completion time the cums attached on the ordered extent record
>>>     * are inserted into the btree
>>>     */
>>> -blk_status_t btrfs_submit_bio_start(struct inode *inode, struct bio *bio,
>>> -				    u64 dio_file_offset)
>>
>>> +blk_status_t btrfs_submit_bio_start(struct inode *inode, struct bio *bio);
>>    Remove the semicolon at the end of the function declaration.
> 
> Right, thanks. It gets removed in the next patch so the whole series
> compiles,


> I don't think it needs to be resent.

  Yes, of course, no resend is required. I am fine.

^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: [PATCH 00/40] Parameter and type changes to btrfs_inode
  2022-11-01 20:11 [PATCH 00/40] Parameter and type changes to btrfs_inode David Sterba
                   ` (39 preceding siblings ...)
  2022-11-01 20:13 ` [PATCH 40/40] btrfs: pass btrfs_inode to btrfs_add_delayed_iput David Sterba
@ 2022-11-03 14:45 ` Anand Jain
  2022-11-11 15:40   ` David Sterba
  40 siblings, 1 reply; 46+ messages in thread
From: Anand Jain @ 2022-11-03 14:45 UTC (permalink / raw)
  To: David Sterba, linux-btrfs

On 02/11/2022 04:11, David Sterba wrote:
> Many patches but also quite short, switching struct inode to struct
> btrfs_node for structures and related functions in the io path, removing
> some indirect function calls and typedefs.
> 
> David Sterba (40):
>    btrfs: change how repair action is passed to btrfs_repair_one_sector
>    btrfs: drop parameter compression_type from
>      btrfs_submit_dio_repair_bio
>    btrfs: change how submit bio callback is passed to btrfs_wq_submit_bio

[patch 04/40]
>    btrfs: simplify btree_submit_bio_start and btrfs_submit_bio_start
>      parameters

>    btrfs: switch async_submit_bio::inode to btrfs_inode
>    btrfs: pass btrfs_inode to btrfs_submit_bio_start
>    btrfs: pass btrfs_inode to btrfs_submit_bio_start_direct_io
>    btrfs: pass btrfs_inode to btrfs_wq_submit_bio
>    btrfs: pass btrfs_inode to btrfs_submit_metadata_bio
>    btrfs: pass btrfs_inode to btrfs_submit_data_write_bio
>    btrfs: pass btrfs_inode to btrfs_submit_data_read_bio
>    btrfs: pass btrfs_inode to btrfs_submit_dio_repair_bio
>    btrfs: pass btrfs_inode to submit_one_bio
>    btrfs: pass btrfs_inode to btrfs_repair_one_sector
>    btrfs: switch btrfs_dio_private::inode to btrfs_inode
>    btrfs: pass btrfs_inode to btrfs_submit_dio_bio
>    btrfs: pass btrfs_inode to btrfs_truncate
>    btrfs: pass btrfs_inode to btrfs_inode_lock
>    btrfs: pass btrfs_inode to btrfs_inode_unlock
>    btrfs: pass btrfs_inode to btrfs_dirty_inode
>    btrfs: pass btrfs_inode to btrfs_add_delalloc_inodes
>    btrfs: switch btrfs_writepage_fixup::inode to btrfs_inode
>    btrfs: pass btrfs_inode to btrfs_check_data_csum
>    btrfs: pass btrfs_inode to __unlink_start_trans
>    btrfs: pass btrfs_inode to btrfs_delete_subvolume
>    btrfs: drop private_data parameter from extent_io_tree_init
>    btrfs: switch extent_io_tree::private_data to btrfs_inode and rename
>    btrfs: pass btrfs_inode to btrfs_merge_delalloc_extent
>    btrfs: pass btrfs_inode to btrfs_set_delalloc_extent
>    btrfs: pass btrfs_inode to btrfs_split_delalloc_extent
>    btrfs: pass btrfs_inode to btrfs_clear_delalloc_extent
>    btrfs: pass btrfs_inode to btrfs_unlink_subvol
>    btrfs: pass btrfs_inode to btrfs_inode_by_name
>    btrfs: pass btrfs_inode to fixup_tree_root_location
>    btrfs: pass btrfs_inode to inode_tree_add
>    btrfs: pass btrfs_inode to btrfs_inherit_iflags
>    btrfs: switch async_chunk::inode to btrfs_inode
>    btrfs: use btrfs_inode inside compress_file_range
>    btrfs: use btrfs_inode inside btrfs_verify_data_csum
>    btrfs: pass btrfs_inode to btrfs_add_delayed_iput


  With patch 04/40 fixed.

  Reviewed-by: Anand Jain <anand.jain@oracle.com>

  For the series.

  Just a note, the naming convention for the local variables... as inode
  represents struct btrfs_inode, we shouldn't use the same name for
  struct inode. Instead, vfs_inode is better. And binode is gone.

Thanks, Anand

>   fs/btrfs/btrfs_inode.h           |  29 +-
>   fs/btrfs/compression.c           |   6 +-
>   fs/btrfs/defrag.c                |  12 +-
>   fs/btrfs/delayed-inode.c         |   4 +-
>   fs/btrfs/disk-io.c               |  52 ++--
>   fs/btrfs/disk-io.h               |  15 +-
>   fs/btrfs/extent-io-tree.c        |  35 ++-
>   fs/btrfs/extent-io-tree.h        |   6 +-
>   fs/btrfs/extent_io.c             |  35 +--
>   fs/btrfs/extent_io.h             |  11 +-
>   fs/btrfs/file.c                  |  48 ++--
>   fs/btrfs/free-space-cache.c      |   4 +-
>   fs/btrfs/inode.c                 | 445 +++++++++++++++----------------
>   fs/btrfs/ioctl.c                 |  10 +-
>   fs/btrfs/ordered-data.c          |   2 +-
>   fs/btrfs/reflink.c               |   4 +-
>   fs/btrfs/relocation.c            |  11 +-
>   fs/btrfs/tests/btrfs-tests.c     |   2 +-
>   fs/btrfs/tests/extent-io-tests.c |   4 +-
>   fs/btrfs/transaction.c           |   4 +-
>   fs/btrfs/tree-log.c              |  24 +-
>   fs/btrfs/volumes.c               |   3 +-
>   include/trace/events/btrfs.h     |  27 +-
>   23 files changed, 393 insertions(+), 400 deletions(-)
> 


^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: [PATCH 00/40] Parameter and type changes to btrfs_inode
  2022-11-03 14:45 ` [PATCH 00/40] Parameter and type changes to btrfs_inode Anand Jain
@ 2022-11-11 15:40   ` David Sterba
  0 siblings, 0 replies; 46+ messages in thread
From: David Sterba @ 2022-11-11 15:40 UTC (permalink / raw)
  To: Anand Jain; +Cc: David Sterba, linux-btrfs

On Thu, Nov 03, 2022 at 10:45:11PM +0800, Anand Jain wrote:
> On 02/11/2022 04:11, David Sterba wrote:
>   For the series.
> 
>   Just a note, the naming convention for the local variables... as inode
>   represents struct btrfs_inode, we shouldn't use the same name for
>   struct inode. Instead, vfs_inode is better. And binode is gone.

Yeah the naming could be done like that. Some functions interact only
with inode so I won't mind using that name but in case there are both it
would be better to use the vfs_ prefix.

^ permalink raw reply	[flat|nested] 46+ messages in thread

end of thread, other threads:[~2022-11-11 15:40 UTC | newest]

Thread overview: 46+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-01 20:11 [PATCH 00/40] Parameter and type changes to btrfs_inode David Sterba
2022-11-01 20:11 ` [PATCH 01/40] btrfs: change how repair action is passed to btrfs_repair_one_sector David Sterba
2022-11-01 20:11 ` [PATCH 02/40] btrfs: drop parameter compression_type from btrfs_submit_dio_repair_bio David Sterba
2022-11-01 20:11 ` [PATCH 03/40] btrfs: change how submit bio callback is passed to btrfs_wq_submit_bio David Sterba
2022-11-01 20:11 ` [PATCH 04/40] btrfs: simplify btree_submit_bio_start and btrfs_submit_bio_start parameters David Sterba
2022-11-02  0:12   ` Anand Jain
2022-11-03 13:28     ` David Sterba
2022-11-03 14:34       ` Anand Jain
2022-11-01 20:11 ` [PATCH 05/40] btrfs: switch async_submit_bio::inode to btrfs_inode David Sterba
2022-11-01 20:11 ` [PATCH 06/40] btrfs: pass btrfs_inode to btrfs_submit_bio_start David Sterba
2022-11-01 20:11 ` [PATCH 07/40] btrfs: pass btrfs_inode to btrfs_submit_bio_start_direct_io David Sterba
2022-11-01 20:11 ` [PATCH 08/40] btrfs: pass btrfs_inode to btrfs_wq_submit_bio David Sterba
2022-11-01 20:11 ` [PATCH 09/40] btrfs: pass btrfs_inode to btrfs_submit_metadata_bio David Sterba
2022-11-01 20:12 ` [PATCH 10/40] btrfs: pass btrfs_inode to btrfs_submit_data_write_bio David Sterba
2022-11-01 20:12 ` [PATCH 11/40] btrfs: pass btrfs_inode to btrfs_submit_data_read_bio David Sterba
2022-11-01 20:12 ` [PATCH 12/40] btrfs: pass btrfs_inode to btrfs_submit_dio_repair_bio David Sterba
2022-11-01 20:12 ` [PATCH 13/40] btrfs: pass btrfs_inode to submit_one_bio David Sterba
2022-11-01 20:12 ` [PATCH 14/40] btrfs: pass btrfs_inode to btrfs_repair_one_sector David Sterba
2022-11-01 20:12 ` [PATCH 15/40] btrfs: switch btrfs_dio_private::inode to btrfs_inode David Sterba
2022-11-01 20:12 ` [PATCH 16/40] btrfs: pass btrfs_inode to btrfs_submit_dio_bio David Sterba
2022-11-01 20:12 ` [PATCH 17/40] btrfs: pass btrfs_inode to btrfs_truncate David Sterba
2022-11-01 20:12 ` [PATCH 18/40] btrfs: pass btrfs_inode to btrfs_inode_lock David Sterba
2022-11-01 20:12 ` [PATCH 19/40] btrfs: pass btrfs_inode to btrfs_inode_unlock David Sterba
2022-11-01 20:12 ` [PATCH 20/40] btrfs: pass btrfs_inode to btrfs_dirty_inode David Sterba
2022-11-01 20:12 ` [PATCH 21/40] btrfs: pass btrfs_inode to btrfs_add_delalloc_inodes David Sterba
2022-11-01 20:12 ` [PATCH 22/40] btrfs: switch btrfs_writepage_fixup::inode to btrfs_inode David Sterba
2022-11-01 20:12 ` [PATCH 23/40] btrfs: pass btrfs_inode to btrfs_check_data_csum David Sterba
2022-11-01 20:12 ` [PATCH 24/40] btrfs: pass btrfs_inode to __unlink_start_trans David Sterba
2022-11-01 20:12 ` [PATCH 25/40] btrfs: pass btrfs_inode to btrfs_delete_subvolume David Sterba
2022-11-01 20:12 ` [PATCH 26/40] btrfs: drop private_data parameter from extent_io_tree_init David Sterba
2022-11-01 20:12 ` [PATCH 27/40] btrfs: switch extent_io_tree::private_data to btrfs_inode and rename David Sterba
2022-11-01 20:12 ` [PATCH 28/40] btrfs: pass btrfs_inode to btrfs_merge_delalloc_extent David Sterba
2022-11-01 20:12 ` [PATCH 29/40] btrfs: pass btrfs_inode to btrfs_set_delalloc_extent David Sterba
2022-11-01 20:12 ` [PATCH 30/40] btrfs: pass btrfs_inode to btrfs_split_delalloc_extent David Sterba
2022-11-01 20:12 ` [PATCH 31/40] btrfs: pass btrfs_inode to btrfs_clear_delalloc_extent David Sterba
2022-11-01 20:12 ` [PATCH 32/40] btrfs: pass btrfs_inode to btrfs_unlink_subvol David Sterba
2022-11-01 20:12 ` [PATCH 33/40] btrfs: pass btrfs_inode to btrfs_inode_by_name David Sterba
2022-11-01 20:12 ` [PATCH 34/40] btrfs: pass btrfs_inode to fixup_tree_root_location David Sterba
2022-11-01 20:12 ` [PATCH 35/40] btrfs: pass btrfs_inode to inode_tree_add David Sterba
2022-11-01 20:12 ` [PATCH 36/40] btrfs: pass btrfs_inode to btrfs_inherit_iflags David Sterba
2022-11-01 20:13 ` [PATCH 37/40] btrfs: switch async_chunk::inode to btrfs_inode David Sterba
2022-11-01 20:13 ` [PATCH 38/40] btrfs: use btrfs_inode inside compress_file_range David Sterba
2022-11-01 20:13 ` [PATCH 39/40] btrfs: use btrfs_inode inside btrfs_verify_data_csum David Sterba
2022-11-01 20:13 ` [PATCH 40/40] btrfs: pass btrfs_inode to btrfs_add_delayed_iput David Sterba
2022-11-03 14:45 ` [PATCH 00/40] Parameter and type changes to btrfs_inode Anand Jain
2022-11-11 15:40   ` David Sterba

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).