All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nikolay Borisov <nborisov@suse.com>
To: linux-btrfs@vger.kernel.org
Cc: Nikolay Borisov <nborisov@suse.com>
Subject: [PATCH 14/46] btrfs: Make cow_file_range take btrfs_inode
Date: Wed,  3 Jun 2020 08:55:14 +0300	[thread overview]
Message-ID: <20200603055546.3889-15-nborisov@suse.com> (raw)
In-Reply-To: <20200603055546.3889-1-nborisov@suse.com>

All its children functions take btrfs_inode so convert it to
taking btrfs_inode.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
 fs/btrfs/inode.c | 52 ++++++++++++++++++++++--------------------------
 1 file changed, 24 insertions(+), 28 deletions(-)

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index b04e27306058..2ec372c4499c 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -79,7 +79,7 @@ struct kmem_cache *btrfs_free_space_bitmap_cachep;
 static int btrfs_setsize(struct inode *inode, struct iattr *attr);
 static int btrfs_truncate(struct inode *inode, bool skip_writeback);
 static int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent);
-static noinline int cow_file_range(struct inode *inode,
+static noinline int cow_file_range(struct btrfs_inode *inode,
 				   struct page *locked_page,
 				   u64 start, u64 end, int *page_started,
 				   unsigned long *nr_written, int unlock);
@@ -788,7 +788,8 @@ static noinline void submit_compressed_extents(struct async_chunk *async_chunk)
 			unsigned long nr_written = 0;

 			/* allocate blocks */
-			ret = cow_file_range(inode, async_chunk->locked_page,
+			ret = cow_file_range(BTRFS_I(inode),
+					     async_chunk->locked_page,
 					     async_extent->start,
 					     async_extent->start +
 					     async_extent->ram_size - 1,
@@ -975,13 +976,13 @@ static u64 get_extent_allocation_hint(struct btrfs_inode *inode, u64 start,
  * required to start IO on it.  It may be clean and already done with
  * IO when we return.
  */
-static noinline int cow_file_range(struct inode *inode,
+static noinline int cow_file_range(struct btrfs_inode *inode,
 				   struct page *locked_page,
 				   u64 start, u64 end, int *page_started,
 				   unsigned long *nr_written, int unlock)
 {
-	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;
 	u64 alloc_hint = 0;
 	u64 num_bytes;
 	unsigned long ram_size;
@@ -994,7 +995,7 @@ static noinline int cow_file_range(struct inode *inode,
 	bool extent_reserved = false;
 	int ret = 0;

-	if (btrfs_is_free_space_inode(BTRFS_I(inode))) {
+	if (btrfs_is_free_space_inode(inode)) {
 		WARN_ON_ONCE(1);
 		ret = -EINVAL;
 		goto out_unlock;
@@ -1004,11 +1005,11 @@ static noinline int cow_file_range(struct inode *inode,
 	num_bytes = max(blocksize,  num_bytes);
 	ASSERT(num_bytes <= btrfs_super_total_bytes(fs_info->super_copy));

-	inode_should_defrag(BTRFS_I(inode), start, end, num_bytes, SZ_64K);
+	inode_should_defrag(inode, start, end, num_bytes, SZ_64K);

 	if (start == 0) {
 		/* lets try to make an inline extent */
-		ret = cow_file_range_inline(BTRFS_I(inode), start, end, 0,
+		ret = cow_file_range_inline(inode, start, end, 0,
 					    BTRFS_COMPRESS_NONE, NULL);
 		if (ret == 0) {
 			/*
@@ -1017,8 +1018,7 @@ static noinline int cow_file_range(struct inode *inode,
 			 * our outstanding extent for clearing delalloc for this
 			 * range.
 			 */
-			extent_clear_unlock_delalloc(BTRFS_I(inode), start, end,
-				     NULL,
+			extent_clear_unlock_delalloc(inode, start, end, NULL,
 				     EXTENT_LOCKED | EXTENT_DELALLOC |
 				     EXTENT_DELALLOC_NEW | EXTENT_DEFRAG |
 				     EXTENT_DO_ACCOUNTING, PAGE_UNLOCK |
@@ -1033,10 +1033,8 @@ static noinline int cow_file_range(struct inode *inode,
 		}
 	}

-	alloc_hint = get_extent_allocation_hint(BTRFS_I(inode), start,
-						num_bytes);
-	btrfs_drop_extent_cache(BTRFS_I(inode), start,
-			start + num_bytes - 1, 0);
+	alloc_hint = get_extent_allocation_hint(inode, start, num_bytes);
+	btrfs_drop_extent_cache(inode, start, start + num_bytes - 1, 0);

 	while (num_bytes > 0) {
 		cur_alloc_size = num_bytes;
@@ -1049,7 +1047,7 @@ static noinline int cow_file_range(struct inode *inode,
 		extent_reserved = true;

 		ram_size = ins.offset;
-		em = create_io_em(BTRFS_I(inode), start, ins.offset, /* len */
+		em = create_io_em(inode, start, ins.offset, /* len */
 				  start, /* orig_start */
 				  ins.objectid, /* block_start */
 				  ins.offset, /* block_len */
@@ -1063,15 +1061,14 @@ static noinline int cow_file_range(struct inode *inode,
 		}
 		free_extent_map(em);

-		ret = btrfs_add_ordered_extent(BTRFS_I(inode), start,
-					       ins.objectid, ram_size,
-					       cur_alloc_size, 0);
+		ret = btrfs_add_ordered_extent(inode, start, ins.objectid,
+					       ram_size, cur_alloc_size, 0);
 		if (ret)
 			goto out_drop_extent_cache;

 		if (root->root_key.objectid ==
 		    BTRFS_DATA_RELOC_TREE_OBJECTID) {
-			ret = btrfs_reloc_clone_csums(BTRFS_I(inode), start,
+			ret = btrfs_reloc_clone_csums(inode, start,
 						      cur_alloc_size);
 			/*
 			 * Only drop cache here, and process as normal.
@@ -1085,7 +1082,7 @@ static noinline int cow_file_range(struct inode *inode,
 			 * skip current ordered extent.
 			 */
 			if (ret)
-				btrfs_drop_extent_cache(BTRFS_I(inode), start,
+				btrfs_drop_extent_cache(inode, start,
 						start + ram_size - 1, 0);
 		}

@@ -1101,8 +1098,7 @@ static noinline int cow_file_range(struct inode *inode,
 		page_ops = unlock ? PAGE_UNLOCK : 0;
 		page_ops |= PAGE_SET_PRIVATE2;

-		extent_clear_unlock_delalloc(BTRFS_I(inode), start,
-					     start + ram_size - 1,
+		extent_clear_unlock_delalloc(inode, start, start + ram_size - 1,
 					     locked_page,
 					     EXTENT_LOCKED | EXTENT_DELALLOC,
 					     page_ops);
@@ -1126,7 +1122,7 @@ static noinline int cow_file_range(struct inode *inode,
 	return ret;

 out_drop_extent_cache:
-	btrfs_drop_extent_cache(BTRFS_I(inode), start, start + ram_size - 1, 0);
+	btrfs_drop_extent_cache(inode, start, start + ram_size - 1, 0);
 out_reserve:
 	btrfs_dec_block_group_reservations(fs_info, ins.objectid);
 	btrfs_free_reserved_extent(fs_info, ins.objectid, ins.offset, 1);
@@ -1146,7 +1142,7 @@ static noinline int cow_file_range(struct inode *inode,
 	 * it the flag EXTENT_CLEAR_DATA_RESV.
 	 */
 	if (extent_reserved) {
-		extent_clear_unlock_delalloc(BTRFS_I(inode), start,
+		extent_clear_unlock_delalloc(inode, start,
 					     start + cur_alloc_size - 1,
 					     locked_page,
 					     clear_bits,
@@ -1155,7 +1151,7 @@ static noinline int cow_file_range(struct inode *inode,
 		if (start >= end)
 			goto out;
 	}
-	extent_clear_unlock_delalloc(BTRFS_I(inode), start, end, locked_page,
+	extent_clear_unlock_delalloc(inode, start, end, locked_page,
 				     clear_bits | EXTENT_CLEAR_DATA_RESV,
 				     page_ops);
 	goto out;
@@ -1416,8 +1412,8 @@ static int fallback_to_cow(struct inode *inode, struct page *locked_page,
 					 0, 0, NULL);
 	}

-	return cow_file_range(inode, locked_page, start, end, page_started,
-			      nr_written, 1);
+	return cow_file_range(BTRFS_I(inode), locked_page, start, end,
+			      page_started, nr_written, 1);
 }

 /*
@@ -1820,7 +1816,7 @@ int btrfs_run_delalloc_range(struct inode *inode, struct page *locked_page,
 					 page_started, 0, nr_written);
 	} else if (!inode_can_compress(inode) ||
 		   !inode_need_compress(inode, start, end)) {
-		ret = cow_file_range(inode, locked_page, start, end,
+		ret = cow_file_range(BTRFS_I(inode), locked_page, start, end,
 				      page_started, nr_written, 1);
 	} else {
 		set_bit(BTRFS_INODE_HAS_ASYNC_EXTENT,
--
2.17.1


  parent reply	other threads:[~2020-06-03  5:56 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-03  5:55 [PATCH v2 00/46] Trivial BTRFS_I removal Nikolay Borisov
2020-06-03  5:55 ` [PATCH 01/46] btrfs: Make __btrfs_add_ordered_extent take struct btrfs_inode Nikolay Borisov
2020-06-03  5:55 ` [PATCH 02/46] btrfs: Make get_extent_allocation_hint take btrfs_inode Nikolay Borisov
2020-06-03  5:55 ` [PATCH 03/46] btrfs: Make btrfs_lookup_ordered_extent " Nikolay Borisov
2020-06-03  5:55 ` [PATCH 04/46] btrfs: Make btrfs_reloc_clone_csums " Nikolay Borisov
2020-06-03  5:55 ` [PATCH 05/46] btrfs: Make create_io_em " Nikolay Borisov
2020-06-03  5:55 ` [PATCH 06/46] btrfs: Make extent_clear_unlock_delalloc " Nikolay Borisov
2020-06-03  5:55 ` [PATCH 07/46] btrfs: Make btrfs_csum_one_bio takae btrfs_inode Nikolay Borisov
2020-06-03  5:55 ` [PATCH 08/46] btrfs: Make __btrfs_drop_extents take btrfs_inode Nikolay Borisov
2020-06-10 11:44   ` David Sterba
2020-06-03  5:55 ` [PATCH 09/46] btrfs: Make qgroup_free_reserved_data " Nikolay Borisov
2020-06-03  5:55 ` [PATCH 10/46] btrfs: Make __btrfs_qgroup_release_data " Nikolay Borisov
2020-06-03  5:55 ` [PATCH 11/46] btrfs: Make btrfs_qgroup_free_data " Nikolay Borisov
2020-06-03  5:55 ` [PATCH 12/46] btrfs: Make cow_file_range_inline " Nikolay Borisov
2020-06-03  5:55 ` [PATCH 13/46] btrfs: Make btrfs_add_ordered_extent " Nikolay Borisov
2020-06-03  5:55 ` Nikolay Borisov [this message]
2020-06-03  5:55 ` [PATCH 15/46] btrfs: Make btrfs_add_ordered_extent_compress " Nikolay Borisov
2020-06-03  5:55 ` [PATCH 16/46] btrfs: Make btrfs_submit_compressed_write " Nikolay Borisov
2020-06-03  5:55 ` [PATCH 17/46] btrfs: Make submit_compressed_extents " Nikolay Borisov
2020-06-03  5:55 ` [PATCH 18/46] btrfs: Make btrfs_qgroup_release_data " Nikolay Borisov
2020-06-03  5:55 ` [PATCH 19/46] btrfs: Make insert_reserved_file_extent " Nikolay Borisov
2020-06-03  5:55 ` [PATCH 20/46] btrfs: Make fallback_to_cow " Nikolay Borisov
2020-06-03  5:55 ` [PATCH 21/46] btrfs: Make run_delalloc_nocow " Nikolay Borisov
2020-06-03  5:55 ` [PATCH 22/46] btrfs: Make cow_file_range_async " Nikolay Borisov
2020-06-03  5:55 ` [PATCH 23/46] btrfs: Make btrfs_dec_test_first_ordered_pending " Nikolay Borisov
2020-06-03  5:55 ` [PATCH 24/46] btrfs: Make __endio_write_update_ordered " Nikolay Borisov
2020-06-03  5:55 ` [PATCH 25/46] btrfs: Make btrfs_cleanup_ordered_extents " Nikolay Borisov
2020-06-03  5:55 ` [PATCH 26/46] btrfs: Make inode_can_compress " Nikolay Borisov
2020-06-03  5:55 ` [PATCH 27/46] btrfs: Make inode_need_compress " Nikolay Borisov
2020-06-03  5:55 ` [PATCH 28/46] btrfs: Make need_force_cow " Nikolay Borisov
2020-06-03  5:55 ` [PATCH 29/46] btrfs: Make btrfs_run_delalloc_range " Nikolay Borisov
2020-06-03  5:55 ` [PATCH 30/46] btrfs: Make btrfs_add_ordered_extent_dio " Nikolay Borisov
2020-06-03  5:55 ` [PATCH 31/46] btrfs: Make btrfs_create_dio_extent " Nikolay Borisov
2020-06-03  5:55 ` [PATCH 32/46] btrfs: Make btrfs_new_extent_direct " Nikolay Borisov
2020-06-03  5:55 ` [PATCH 33/46] btrfs: Make __extent_writepage_io " Nikolay Borisov
2020-06-03  5:55 ` [PATCH 34/46] btrfs: Make writepage_delalloc " Nikolay Borisov
2020-06-05  7:42   ` [PATCH v3 " Nikolay Borisov
2020-06-03  5:55 ` [PATCH 35/46] btrfs: Make btrfs_set_extent_delalloc " Nikolay Borisov
2020-06-03  5:55 ` [PATCH 36/46] btrfs: Make btrfs_dirty_pages " Nikolay Borisov
2020-06-03  5:55 ` [PATCH 37/46] btrfs: Make btrfs_qgroup_reserve_data " Nikolay Borisov
2020-06-03  5:55 ` [PATCH 38/46] btrfs: Make btrfs_free_reserved_data_space_noquota take btrfs_fs_info Nikolay Borisov
2020-06-03  5:55 ` [PATCH 39/46] btrfs: Make btrfs_free_reserved_data_space take btrfs_inode Nikolay Borisov
2020-06-03  5:55 ` [PATCH 40/46] btrfs: Make btrfs_delalloc_release_space " Nikolay Borisov
2020-06-03  5:55 ` [PATCH 41/46] btrfs: Make btrfs_check_data_free_space " Nikolay Borisov
2020-06-03  5:55 ` [PATCH 42/46] btrfs: Make btrfs_delalloc_reserve_space " Nikolay Borisov
2020-06-03  5:55 ` [PATCH 43/46] btrfs: Remove BTRFS_I calls in Nikolay Borisov
2020-06-05  7:51   ` [PATCH v3 43/46] btrfs: Remove BTRFS_I calls in btrfs_writepage_fixup_worker Nikolay Borisov
2020-06-03  5:55 ` [PATCH 44/46] btrfs: Make prealloc_file_extent_cluster take btrfs_inode Nikolay Borisov
2020-06-03  5:55 ` [PATCH 45/46] btrfs make btrfs_set_inode_last_trans " Nikolay Borisov
2020-06-05  7:41   ` [PATCH v3 45/46] btrfs: " Nikolay Borisov
2020-06-03  5:55 ` [PATCH 46/46] btrfs: Make btrfs_qgroup_check_reserved_leak " Nikolay Borisov
2020-06-03  6:55 ` [PATCH v2 00/46] Trivial BTRFS_I removal Johannes Thumshirn
2020-06-08 15:57 ` David Sterba
2020-06-17 11:37 ` David Sterba
2020-06-22 18:51   ` David Sterba
  -- strict thread matches above, loose matches on Subject: below --
2020-06-01 15:36 [PATCH " Nikolay Borisov
2020-06-01 15:37 ` [PATCH 14/46] btrfs: Make cow_file_range take btrfs_inode Nikolay Borisov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200603055546.3889-15-nborisov@suse.com \
    --to=nborisov@suse.com \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.