Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.com>
To: linux-btrfs@vger.kernel.org
Cc: David Sterba <dsterba@suse.com>
Subject: [PATCH 3/8] btrfs: add assertions for tree == inode->io_tree to extent IO helpers
Date: Wed,  5 Feb 2020 19:09:30 +0100	[thread overview]
Message-ID: <d1acc29c9c15139a988add159de8dbfe2129a36f.1580925977.git.dsterba@suse.com> (raw)
In-Reply-To: <cover.1580925977.git.dsterba@suse.com>

Add assertions to all helpers that get tree as argument and verify that
it's the same that can be obtained from the inode or from its pages. In
followup patches the redundant arguments and assertions will be removed
one by one.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/extent_io.c    | 10 ++++++++++
 fs/btrfs/ordered-data.c |  2 ++
 2 files changed, 12 insertions(+)

diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 6640336dd9ba..e9d116ecf5a1 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -3097,6 +3097,8 @@ static int __do_readpage(struct extent_io_tree *tree,
 	size_t blocksize = inode->i_sb->s_blocksize;
 	unsigned long this_bio_flag = 0;
 
+	ASSERT(tree == &BTRFS_I(inode)->io_tree);
+
 	set_page_extent_mapped(page);
 
 	if (!PageUptodate(page)) {
@@ -3290,6 +3292,8 @@ static inline void contiguous_readpages(struct extent_io_tree *tree,
 	struct btrfs_inode *inode = BTRFS_I(pages[0]->mapping->host);
 	int index;
 
+	ASSERT(tree == &inode->io_tree);
+
 	btrfs_lock_and_flush_ordered_range(tree, inode, start, end, NULL);
 
 	for (index = 0; index < nr_pages; index++) {
@@ -3311,6 +3315,8 @@ static int __extent_read_full_page(struct extent_io_tree *tree,
 	u64 end = start + PAGE_SIZE - 1;
 	int ret;
 
+	ASSERT(tree == &inode->io_tree);
+
 	btrfs_lock_and_flush_ordered_range(tree, inode, start, end, NULL);
 
 	ret = __do_readpage(tree, page, get_extent, NULL, bio, mirror_num,
@@ -3325,6 +3331,8 @@ int extent_read_full_page(struct extent_io_tree *tree, struct page *page,
 	unsigned long bio_flags = 0;
 	int ret;
 
+	ASSERT(tree == &BTRFS_I(page->mapping->host)->io_tree);
+
 	ret = __extent_read_full_page(tree, page, get_extent, &bio, mirror_num,
 				      &bio_flags, 0);
 	if (bio)
@@ -5413,6 +5421,8 @@ int read_extent_buffer_pages(struct extent_buffer *eb, int wait, int mirror_num)
 	if (test_bit(EXTENT_BUFFER_UPTODATE, &eb->bflags))
 		return 0;
 
+	ASSERT(tree == &BTRFS_I(eb->pages[0]->mapping->host)->io_tree);
+
 	num_pages = num_extent_pages(eb);
 	for (i = 0; i < num_pages; i++) {
 		page = eb->pages[i];
diff --git a/fs/btrfs/ordered-data.c b/fs/btrfs/ordered-data.c
index 45048e5f76b0..ad471a2fba93 100644
--- a/fs/btrfs/ordered-data.c
+++ b/fs/btrfs/ordered-data.c
@@ -849,6 +849,8 @@ void btrfs_lock_and_flush_ordered_range(struct extent_io_tree *tree,
 	struct extent_state *cache = NULL;
 	struct extent_state **cachedp = &cache;
 
+	ASSERT(tree == &inode->io_tree);
+
 	if (cached_state)
 		cachedp = cached_state;
 
-- 
2.25.0


  parent reply	other threads:[~2020-02-05 18:09 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-05 18:09 [PATCH 0/8] Cleanup io_tree arguments in extent read/write path David Sterba
2020-02-05 18:09 ` [PATCH 1/8] btrfs: remove extent_page_data::tree David Sterba
2020-02-06  8:34   ` Anand Jain
2020-02-06 13:32   ` Johannes Thumshirn
2020-02-05 18:09 ` [PATCH 2/8] btrfs: drop argument tree from submit_extent_page David Sterba
2020-02-06  5:58   ` Anand Jain
2020-02-06 13:47     ` David Sterba
2020-02-11  5:00       ` Anand Jain
2020-02-06 13:33   ` Johannes Thumshirn
2020-02-05 18:09 ` David Sterba [this message]
2020-02-06 13:34   ` [PATCH 3/8] btrfs: add assertions for tree == inode->io_tree to extent IO helpers Johannes Thumshirn
2020-02-05 18:09 ` [PATCH 4/8] btrfs: drop argument tree from btrfs_lock_and_flush_ordered_range David Sterba
2020-02-06 13:38   ` Johannes Thumshirn
2020-02-05 18:09 ` [PATCH 5/8] btrfs: sink argument tree to extent_read_full_page David Sterba
2020-02-06 13:40   ` Johannes Thumshirn
2020-02-05 18:09 ` [PATCH 6/8] btrfs: sink argument tree to __extent_read_full_page David Sterba
2020-02-06 13:40   ` Johannes Thumshirn
2020-02-05 18:09 ` [PATCH 7/8] btrfs: sink arugment tree to contiguous_readpages David Sterba
2020-02-06 13:42   ` Johannes Thumshirn
2020-02-05 18:09 ` [PATCH 8/8] btrfs: sink argument tree to __do_readpage David Sterba
2020-02-06 13:43   ` Johannes Thumshirn
2020-02-06 13:24 ` [PATCH 0/8] Cleanup io_tree arguments in extent read/write path 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=d1acc29c9c15139a988add159de8dbfe2129a36f.1580925977.git.dsterba@suse.com \
    --to=dsterba@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox