linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nikolay Borisov <n.borisov.lkml@gmail.com>
To: dsterba@suse.com
Cc: linux-btrfs@vger.kernel.org,
	Nikolay Borisov <n.borisov.lkml@gmail.com>,
	Nikolay Borisov <nborisov@suse.com>
Subject: [PATCH 09/38] btrfs: Make calc_csum_metadata_size take btrfs_inode
Date: Fri, 17 Feb 2017 16:43:00 +0200	[thread overview]
Message-ID: <1487342609-20652-10-git-send-email-nborisov@suse.com> (raw)
In-Reply-To: <1487342609-20652-1-git-send-email-nborisov@suse.com>

From: Nikolay Borisov <n.borisov.lkml@gmail.com>

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
 fs/btrfs/extent-tree.c | 27 ++++++++++++---------------
 1 file changed, 12 insertions(+), 15 deletions(-)

diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 74bfaf222973..781dfdf5556e 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -5893,24 +5893,21 @@ static unsigned drop_outstanding_extent(struct btrfs_inode *inode, u64 num_bytes
  *
  * This must be called with BTRFS_I(inode)->lock held.
  */
-static u64 calc_csum_metadata_size(struct inode *inode, u64 num_bytes,
+static u64 calc_csum_metadata_size(struct btrfs_inode *inode, u64 num_bytes,
 				   int reserve)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode->vfs_inode.i_sb);
 	u64 old_csums, num_csums;
 
-	if (BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM &&
-	    BTRFS_I(inode)->csum_bytes == 0)
+	if (inode->flags & BTRFS_INODE_NODATASUM && inode->csum_bytes == 0)
 		return 0;
 
-	old_csums = btrfs_csum_bytes_to_leaves(fs_info,
-					       BTRFS_I(inode)->csum_bytes);
+	old_csums = btrfs_csum_bytes_to_leaves(fs_info, inode->csum_bytes);
 	if (reserve)
-		BTRFS_I(inode)->csum_bytes += num_bytes;
+		inode->csum_bytes += num_bytes;
 	else
-		BTRFS_I(inode)->csum_bytes -= num_bytes;
-	num_csums = btrfs_csum_bytes_to_leaves(fs_info,
-					       BTRFS_I(inode)->csum_bytes);
+		inode->csum_bytes -= num_bytes;
+	num_csums = btrfs_csum_bytes_to_leaves(fs_info, inode->csum_bytes);
 
 	/* No change, no need to reserve more */
 	if (old_csums == num_csums)
@@ -5974,7 +5971,7 @@ int btrfs_delalloc_reserve_metadata(struct inode *inode, u64 num_bytes)
 
 	/* We always want to reserve a slot for updating the inode. */
 	to_reserve = btrfs_calc_trans_metadata_size(fs_info, nr_extents + 1);
-	to_reserve += calc_csum_metadata_size(inode, num_bytes, 1);
+	to_reserve += calc_csum_metadata_size(BTRFS_I(inode), num_bytes, 1);
 	csum_bytes = BTRFS_I(inode)->csum_bytes;
 	spin_unlock(&BTRFS_I(inode)->lock);
 
@@ -6021,7 +6018,7 @@ int btrfs_delalloc_reserve_metadata(struct inode *inode, u64 num_bytes)
 	 * so we can just reduce our inodes csum bytes and carry on.
 	 */
 	if (BTRFS_I(inode)->csum_bytes == csum_bytes) {
-		calc_csum_metadata_size(inode, num_bytes, 0);
+		calc_csum_metadata_size(BTRFS_I(inode), num_bytes, 0);
 	} else {
 		u64 orig_csum_bytes = BTRFS_I(inode)->csum_bytes;
 		u64 bytes;
@@ -6036,7 +6033,7 @@ int btrfs_delalloc_reserve_metadata(struct inode *inode, u64 num_bytes)
 		 */
 		bytes = csum_bytes - BTRFS_I(inode)->csum_bytes;
 		BTRFS_I(inode)->csum_bytes = csum_bytes;
-		to_free = calc_csum_metadata_size(inode, bytes, 0);
+		to_free = calc_csum_metadata_size(BTRFS_I(inode), bytes, 0);
 
 
 		/*
@@ -6046,7 +6043,7 @@ int btrfs_delalloc_reserve_metadata(struct inode *inode, u64 num_bytes)
 		 */
 		BTRFS_I(inode)->csum_bytes = csum_bytes - num_bytes;
 		bytes = csum_bytes - orig_csum_bytes;
-		bytes = calc_csum_metadata_size(inode, bytes, 0);
+		bytes = calc_csum_metadata_size(BTRFS_I(inode), bytes, 0);
 
 		/*
 		 * Now reset ->csum_bytes to what it should be.  If bytes is
@@ -6096,7 +6093,7 @@ void btrfs_delalloc_release_metadata(struct inode *inode, u64 num_bytes)
 	dropped = drop_outstanding_extent(BTRFS_I(inode), num_bytes);
 
 	if (num_bytes)
-		to_free = calc_csum_metadata_size(inode, num_bytes, 0);
+		to_free = calc_csum_metadata_size(BTRFS_I(inode), num_bytes, 0);
 	spin_unlock(&BTRFS_I(inode)->lock);
 	if (dropped > 0)
 		to_free += btrfs_calc_trans_metadata_size(fs_info, dropped);
-- 
2.7.4


  parent reply	other threads:[~2017-02-17 14:43 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-17 14:42 [PATCH 00/38] More btrfs_inode cleanups Nikolay Borisov
2017-02-17 14:42 ` [PATCH 01/38] btrfs: Make btrfs_log_all_parents take btrfs_inode Nikolay Borisov
2017-02-17 14:42 ` [PATCH 02/38] btrfs: Make btrfs_insert_dir_item " Nikolay Borisov
2017-02-17 14:42 ` [PATCH 03/38] btrfs: make btrfs_set_inode_index_count " Nikolay Borisov
2017-02-17 14:42 ` [PATCH 04/38] btrfs: Make btrfs_set_inode_index " Nikolay Borisov
2017-02-17 14:42 ` [PATCH 05/38] btrfs: Make btrfs_i_size_write " Nikolay Borisov
2017-02-17 14:42 ` [PATCH 06/38] btrfs: make btrfs_is_free_space_inode " Nikolay Borisov
2017-02-17 14:42 ` [PATCH 07/38] btrfs: make btrfs_alloc_data_chunk_ondemand " Nikolay Borisov
2017-02-17 14:42 ` [PATCH 08/38] btrfs: Make drop_outstanding_extent " Nikolay Borisov
2017-02-17 14:43 ` Nikolay Borisov [this message]
2017-02-17 14:43 ` [PATCH 10/38] btrfs: Make btrfs_orphan_reserve_metadata " Nikolay Borisov
2017-02-17 14:43 ` [PATCH 11/38] btrfs: Make btrfs_orphan_release_metadata " Nikolay Borisov
2017-02-17 14:43 ` [PATCH 12/38] btrfs: Make btrfs_delalloc_reserve_metadata " Nikolay Borisov
2017-02-17 14:43 ` [PATCH 13/38] btrfs: ale btrfs_delalloc_release_metadata " Nikolay Borisov
2017-02-17 14:43 ` [PATCH 14/38] btrfs: Make (__)btrfs_add_inode_defrag " Nikolay Borisov
2017-02-17 14:43 ` [PATCH 15/38] btrfs: Make btrfs_requeue_inode_defrag " Nikolay Borisov
2017-02-17 14:43 ` [PATCH 16/38] btrfs: Make btrfs_drop_extent_cache " Nikolay Borisov
2017-02-17 16:47   ` kbuild test robot
2017-02-17 17:03   ` kbuild test robot
2017-02-17 14:43 ` [PATCH 17/38] btrfs: Make hole_mergeable " Nikolay Borisov
2017-02-17 14:43 ` [PATCH 18/38] btrfs: Make fille_holes " Nikolay Borisov
2017-02-17 14:43 ` [PATCH 19/38] btrfs: Make btrfs_mark_extent_written " Nikolay Borisov
2017-02-17 14:43 ` [PATCH 20/38] btrfs: Make btrfs_lookup_ordered_range " Nikolay Borisov
2017-02-17 14:43 ` [PATCH 21/38] btrfs: Make check_can_nocow " Nikolay Borisov
2017-02-17 14:43 ` [PATCH 22/38] btrfs: Make lock_and_cleanup_extent_if_need " Nikolay Borisov
2017-02-17 14:43 ` [PATCH 23/38] btrfs: make free_io_failure " Nikolay Borisov
2017-02-17 14:43 ` [PATCH 24/38] btrfs: make btrfs_print_data_csum_error " Nikolay Borisov
2017-02-17 14:43 ` [PATCH 25/38] btrfs: make check_compressed_csum " Nikolay Borisov
2017-02-17 14:43 ` [PATCH 26/38] btrfs: make repair_io_failure " Nikolay Borisov
2017-02-17 14:43 ` [PATCH 27/38] btrfs: make clean_io_failure " Nikolay Borisov
2017-02-17 14:43 ` [PATCH 28/38] btrfs: make btrfs_free_io_failure_record " Nikolay Borisov
2017-02-17 14:43 ` [PATCH 29/38] btrfs: make btrfs_orphan_del " Nikolay Borisov
2017-02-17 14:43 ` [PATCH 30/38] btrfs: Make btrfs_orphan_add " Nikolay Borisov
2017-02-17 14:43 ` [PATCH 31/38] btrfs: Make check_parent_dirs_for_sync " Nikolay Borisov
2017-02-17 14:43 ` [PATCH 32/38] btrfs: make btrfs_log_inode_parent " Nikolay Borisov
2017-02-17 14:43 ` [PATCH 33/38] btrfs: Make btrfs_extent_item_to_extent_map " Nikolay Borisov
2017-02-17 14:43 ` [PATCH 34/38] btrfs: Make btrfs_clear_bit_hook " Nikolay Borisov
2017-02-17 14:43 ` [PATCH 35/38] btrfs: Make clone_update_extent_map " Nikolay Borisov
2017-02-17 14:43 ` [PATCH 36/38] btrfs: Make check_extent_to_block " Nikolay Borisov
2017-02-17 14:43 ` [PATCH 37/38] btrfs: Make get_extent_t " Nikolay Borisov
2017-02-17 17:14   ` kbuild test robot
2017-02-17 17:26   ` kbuild test robot
2017-02-17 14:43 ` [PATCH 38/38] btrfs: Make btrfs_del_delalloc_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=1487342609-20652-10-git-send-email-nborisov@suse.com \
    --to=n.borisov.lkml@gmail.com \
    --cc=dsterba@suse.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=nborisov@suse.com \
    /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 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).