From: Qu Wenruo <wqu@suse.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH] btrfs: Use struct inode* to replace extent_io_tree::private_data
Date: Mon, 25 Feb 2019 13:50:43 +0800 [thread overview]
Message-ID: <20190225055043.1621-1-wqu@suse.com> (raw)
All users of extent_io_tree::private_data are expecting struct inode*.
So just use struct inode* to replace extent_io_tree::private_data, and
this should provide better type check.
Signed-off-by: Qu Wenruo <wqu@suse.com>
---
fs/btrfs/extent_io.c | 36 +++++++++++++++++-------------------
fs/btrfs/extent_io.h | 4 ++--
fs/btrfs/inode.c | 2 +-
3 files changed, 20 insertions(+), 22 deletions(-)
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index e0a96f74e81e..2fd78b10830b 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -89,7 +89,7 @@ void btrfs_leak_debug_check(void)
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 inode *inode = tree->inode;
u64 isize;
if (!inode || !is_data_inode(inode))
@@ -201,13 +201,13 @@ void __cold extent_io_exit(void)
}
void extent_io_tree_init(struct extent_io_tree *tree,
- void *private_data)
+ struct inode *inode)
{
tree->state = RB_ROOT;
tree->ops = NULL;
tree->dirty_bytes = 0;
spin_lock_init(&tree->lock);
- tree->private_data = private_data;
+ tree->inode = inode;
}
static struct extent_state *alloc_extent_state(gfp_t mask)
@@ -376,9 +376,8 @@ static void merge_state(struct extent_io_tree *tree,
other = rb_entry(other_node, struct extent_state, rb_node);
if (other->end == state->start - 1 &&
other->state == state->state) {
- if (tree->private_data &&
- is_data_inode(tree->private_data))
- btrfs_merge_delalloc_extent(tree->private_data,
+ if (tree->inode && is_data_inode(tree->inode))
+ btrfs_merge_delalloc_extent(tree->inode,
state, other);
state->start = other->start;
rb_erase(&other->rb_node, &tree->state);
@@ -391,9 +390,8 @@ static void merge_state(struct extent_io_tree *tree,
other = rb_entry(other_node, struct extent_state, rb_node);
if (other->start == state->end + 1 &&
other->state == state->state) {
- if (tree->private_data &&
- is_data_inode(tree->private_data))
- btrfs_merge_delalloc_extent(tree->private_data,
+ if (tree->inode && is_data_inode(tree->inode))
+ btrfs_merge_delalloc_extent(tree->inode,
state, other);
state->end = other->end;
rb_erase(&other->rb_node, &tree->state);
@@ -464,8 +462,8 @@ static int split_state(struct extent_io_tree *tree, struct extent_state *orig,
{
struct rb_node *node;
- if (tree->private_data && is_data_inode(tree->private_data))
- btrfs_split_delalloc_extent(tree->private_data, orig, split);
+ if (tree->inode && is_data_inode(tree->inode))
+ btrfs_split_delalloc_extent(tree->inode, orig, split);
prealloc->start = orig->start;
prealloc->end = split - 1;
@@ -512,8 +510,8 @@ static struct extent_state *clear_state_bit(struct extent_io_tree *tree,
tree->dirty_bytes -= range;
}
- if (tree->private_data && is_data_inode(tree->private_data))
- btrfs_clear_delalloc_extent(tree->private_data, state, bits);
+ if (tree->inode && is_data_inode(tree->inode))
+ btrfs_clear_delalloc_extent(tree->inode, state, bits);
ret = add_extent_changeset(state, bits_to_clear, changeset, 0);
BUG_ON(ret < 0);
@@ -547,7 +545,7 @@ alloc_extent_state_atomic(struct extent_state *prealloc)
static void extent_io_tree_panic(struct extent_io_tree *tree, int err)
{
- struct inode *inode = tree->private_data;
+ struct inode *inode = tree->inode;
btrfs_panic(btrfs_sb(inode->i_sb), err,
"locking error: extent tree was modified by another thread while locked");
@@ -791,8 +789,8 @@ static void set_state_bits(struct extent_io_tree *tree,
unsigned bits_to_set = *bits & ~EXTENT_CTLBITS;
int ret;
- if (tree->private_data && is_data_inode(tree->private_data))
- btrfs_set_delalloc_extent(tree->private_data, state, bits);
+ if (tree->inode && is_data_inode(tree->inode))
+ btrfs_set_delalloc_extent(tree->inode, state, bits);
if ((bits_to_set & EXTENT_DIRTY) && !(state->state & EXTENT_DIRTY)) {
u64 range = state->end - state->start + 1;
@@ -2378,8 +2376,8 @@ static int bio_readpage_error(struct bio *failed_bio, u64 phy_offset,
"Repair Read Error: submitting new read[%#x] to this_mirror=%d, in_validation=%d",
read_mode, failrec->this_mirror, failrec->in_validation);
- status = tree->ops->submit_bio_hook(tree->private_data, bio, failrec->this_mirror,
- failrec->bio_flags, 0);
+ status = tree->ops->submit_bio_hook(tree->inode, bio,
+ failrec->this_mirror, failrec->bio_flags, 0);
if (status) {
free_io_failure(failure_tree, tree, failrec);
bio_put(bio);
@@ -2706,7 +2704,7 @@ static int __must_check submit_one_bio(struct bio *bio, int mirror_num,
bio->bi_private = NULL;
if (tree->ops)
- ret = tree->ops->submit_bio_hook(tree->private_data, bio,
+ ret = tree->ops->submit_bio_hook(tree->inode, bio,
mirror_num, bio_flags, start);
else
btrfsic_submit_bio(bio);
diff --git a/fs/btrfs/extent_io.h b/fs/btrfs/extent_io.h
index 9673be3f3d1f..b656d65bca83 100644
--- a/fs/btrfs/extent_io.h
+++ b/fs/btrfs/extent_io.h
@@ -109,7 +109,7 @@ struct extent_io_ops {
struct extent_io_tree {
struct rb_root state;
- void *private_data;
+ struct inode *inode;
u64 dirty_bytes;
int track_uptodate;
spinlock_t lock;
@@ -240,7 +240,7 @@ typedef struct extent_map *(get_extent_t)(struct btrfs_inode *inode,
u64 start, u64 len,
int create);
-void extent_io_tree_init(struct extent_io_tree *tree, void *private_data);
+void extent_io_tree_init(struct extent_io_tree *tree, struct inode *inode);
int try_release_extent_mapping(struct page *page, gfp_t mask);
int try_release_extent_buffer(struct page *page);
int lock_extent_bits(struct extent_io_tree *tree, u64 start, u64 end,
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 5c349667c761..4fc82f582fa5 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -10403,7 +10403,7 @@ static int btrfs_tmpfile(struct inode *dir, struct dentry *dentry, umode_t mode)
void btrfs_set_range_writeback(struct extent_io_tree *tree, u64 start, u64 end)
{
- struct inode *inode = tree->private_data;
+ struct inode *inode = tree->inode;
unsigned long index = start >> PAGE_SHIFT;
unsigned long end_index = end >> PAGE_SHIFT;
struct page *page;
--
2.20.1
next reply other threads:[~2019-02-25 5:52 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-25 5:50 Qu Wenruo [this message]
2019-02-25 10:00 ` [PATCH] btrfs: Use struct inode* to replace extent_io_tree::private_data Filipe Manana
2019-02-25 11:10 ` Johannes Thumshirn
2019-02-25 12:15 ` David Sterba
2019-02-25 12:17 ` Qu Wenruo
2019-02-25 12:26 ` David Sterba
2019-02-25 15:46 ` Josef Bacik
2019-02-26 4:07 ` Qu Wenruo
2019-02-26 13:35 ` Josef Bacik
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=20190225055043.1621-1-wqu@suse.com \
--to=wqu@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