From: Nikolay Borisov <nborisov@suse.com>
To: linux-btrfs@vger.kernel.org
Cc: Nikolay Borisov <nborisov@suse.com>
Subject: [PATCH 03/14] btrfs: Make btrfs_truncate_inode_items take btrfs_inode
Date: Mon, 2 Nov 2020 16:48:55 +0200 [thread overview]
Message-ID: <20201102144906.3767963-4-nborisov@suse.com> (raw)
In-Reply-To: <20201102144906.3767963-1-nborisov@suse.com>
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
fs/btrfs/ctree.h | 2 +-
fs/btrfs/free-space-cache.c | 2 +-
fs/btrfs/inode.c | 43 ++++++++++++++++++++-----------------
fs/btrfs/tree-log.c | 5 ++---
4 files changed, 27 insertions(+), 25 deletions(-)
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index c0108a4730d1..f85a5e69614c 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -2998,7 +2998,7 @@ int btrfs_truncate_block(struct inode *inode, loff_t from, loff_t len,
int front);
int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
struct btrfs_root *root,
- struct inode *inode, u64 new_size,
+ struct btrfs_inode *inode, u64 new_size,
u32 min_type);
int btrfs_start_delalloc_snapshot(struct btrfs_root *root);
diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
index 5ea36a06e514..48f059e91518 100644
--- a/fs/btrfs/free-space-cache.c
+++ b/fs/btrfs/free-space-cache.c
@@ -267,7 +267,7 @@ int btrfs_truncate_free_space_cache(struct btrfs_trans_handle *trans,
* We skip the throttling logic for free space cache inodes, so we don't
* need to check for -EAGAIN.
*/
- ret = btrfs_truncate_inode_items(trans, root, inode,
+ ret = btrfs_truncate_inode_items(trans, root, BTRFS_I(inode),
0, BTRFS_EXTENT_DATA_KEY);
if (ret)
goto fail;
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index f31132106fad..4ec4e59ddb47 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -4130,7 +4130,7 @@ static int btrfs_rmdir(struct inode *dir, struct dentry *dentry)
*/
int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
struct btrfs_root *root,
- struct inode *inode,
+ struct btrfs_inode *inode,
u64 new_size, u32 min_type)
{
struct btrfs_fs_info *fs_info = root->fs_info;
@@ -4151,7 +4151,7 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
int pending_del_slot = 0;
int extent_type = -1;
int ret;
- u64 ino = btrfs_ino(BTRFS_I(inode));
+ u64 ino = btrfs_ino(inode);
u64 bytes_deleted = 0;
bool be_nice = false;
bool should_throttle = false;
@@ -4165,7 +4165,7 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
* off from time to time. This means all inodes in subvolume roots,
* reloc roots, and data reloc roots.
*/
- if (!btrfs_is_free_space_inode(BTRFS_I(inode)) &&
+ if (!btrfs_is_free_space_inode(inode) &&
test_bit(BTRFS_ROOT_SHAREABLE, &root->state))
be_nice = true;
@@ -4175,7 +4175,7 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
path->reada = READA_BACK;
if (root->root_key.objectid != BTRFS_TREE_LOG_OBJECTID) {
- lock_extent_bits(&BTRFS_I(inode)->io_tree, lock_start, (u64)-1,
+ lock_extent_bits(&inode->io_tree, lock_start, (u64)-1,
&cached_state);
/*
@@ -4183,7 +4183,7 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
* 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_cache(BTRFS_I(inode), ALIGN(new_size,
+ btrfs_drop_extent_cache(inode, ALIGN(new_size,
fs_info->sectorsize),
(u64)-1, 0);
}
@@ -4194,8 +4194,8 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
* it is used to drop the logged items. So we shouldn't kill the delayed
* items.
*/
- if (min_type == 0 && root == BTRFS_I(inode)->root)
- btrfs_kill_delayed_inode_items(BTRFS_I(inode));
+ if (min_type == 0 && root == inode->root)
+ btrfs_kill_delayed_inode_items(inode);
key.objectid = ino;
key.offset = (u64)-1;
@@ -4251,14 +4251,13 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
btrfs_file_extent_num_bytes(leaf, fi);
trace_btrfs_truncate_show_fi_regular(
- BTRFS_I(inode), leaf, fi,
- found_key.offset);
+ inode, leaf, fi, found_key.offset);
} else if (extent_type == BTRFS_FILE_EXTENT_INLINE) {
item_end += btrfs_file_extent_ram_bytes(leaf,
fi);
trace_btrfs_truncate_show_fi_inline(
- BTRFS_I(inode), leaf, fi, path->slots[0],
+ inode, leaf, fi, path->slots[0],
found_key.offset);
}
item_end--;
@@ -4297,7 +4296,8 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
if (test_bit(BTRFS_ROOT_SHAREABLE,
&root->state) &&
extent_start != 0)
- inode_sub_bytes(inode, num_dec);
+ inode_sub_bytes(&inode->vfs_info,
+ num_dec);
btrfs_mark_buffer_dirty(leaf);
} else {
extent_num_bytes =
@@ -4312,7 +4312,8 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
found_extent = 1;
if (test_bit(BTRFS_ROOT_SHAREABLE,
&root->state))
- inode_sub_bytes(inode, num_dec);
+ inode_sub_bytes(&inode->vfs_inode,
+ num_dec);
}
}
clear_len = num_dec;
@@ -4347,7 +4348,8 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
}
if (test_bit(BTRFS_ROOT_SHAREABLE, &root->state))
- inode_sub_bytes(inode, item_end + 1 - new_size);
+ inode_sub_bytes(&inode->vfs_inode,
+ item_end + 1 - new_size);
}
delete:
/*
@@ -4355,8 +4357,8 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
* multiple fsyncs, and in this case we don't want to clear the
* file extent range because it's just the log.
*/
- if (root == BTRFS_I(inode)->root) {
- ret = btrfs_inode_clear_file_extent_range(BTRFS_I(inode),
+ if (root == inode->root) {
+ ret = btrfs_inode_clear_file_extent_range(inode,
clear_start, clear_len);
if (ret) {
btrfs_abort_transaction(trans, ret);
@@ -4464,9 +4466,9 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
ASSERT(last_size >= new_size);
if (!ret && last_size > new_size)
last_size = new_size;
- btrfs_inode_safe_disk_i_size_write(BTRFS_I(inode), last_size);
- unlock_extent_cached(&BTRFS_I(inode)->io_tree, lock_start,
- (u64)-1, &cached_state);
+ btrfs_inode_safe_disk_i_size_write(inode, last_size);
+ unlock_extent_cached(&inode->io_tree, lock_start, (u64)-1,
+ &cached_state);
}
btrfs_free_path(path);
@@ -5093,7 +5095,8 @@ void btrfs_evict_inode(struct inode *inode)
trans->block_rsv = rsv;
- ret = btrfs_truncate_inode_items(trans, root, inode, 0, 0);
+ ret = btrfs_truncate_inode_items(trans, root, BTRFS_I(inode),
+ 0, 0);
trans->block_rsv = &fs_info->trans_block_rsv;
btrfs_end_transaction(trans);
btrfs_btree_balance_dirty(fs_info);
@@ -8456,7 +8459,7 @@ static int btrfs_truncate(struct inode *inode, bool skip_writeback)
trans->block_rsv = rsv;
while (1) {
- ret = btrfs_truncate_inode_items(trans, root, inode,
+ ret = btrfs_truncate_inode_items(trans, root, BTRFS_I(inode),
inode->i_size,
BTRFS_EXTENT_DATA_KEY);
trans->block_rsv = &fs_info->trans_block_rsv;
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index 135cb40295c1..4ea54fe23e3c 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -4365,8 +4365,7 @@ static int btrfs_log_prealloc_extents(struct btrfs_trans_handle *trans,
do {
ret = btrfs_truncate_inode_items(trans,
root->log_root,
- &inode->vfs_inode,
- truncate_offset,
+ inode, truncate_offset,
BTRFS_EXTENT_DATA_KEY);
} while (ret == -EAGAIN);
if (ret)
@@ -5293,7 +5292,7 @@ static int btrfs_log_inode(struct btrfs_trans_handle *trans,
&inode->runtime_flags);
while(1) {
ret = btrfs_truncate_inode_items(trans,
- log, &inode->vfs_inode, 0, 0);
+ log, inode, 0, 0);
if (ret != -EAGAIN)
break;
}
--
2.25.1
next prev parent reply other threads:[~2020-11-02 14:49 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-02 14:48 [PATCH 00/14] Another batch of inode vs btrfs_inode cleanups Nikolay Borisov
2020-11-02 14:48 ` [PATCH 01/14] btrfs: Make btrfs_inode_safe_disk_i_size_write take btrfs_inode Nikolay Borisov
2020-11-02 14:48 ` [PATCH 02/14] btrfs: Make insert_prealloc_file_extent " Nikolay Borisov
2020-11-02 14:48 ` Nikolay Borisov [this message]
2020-11-05 14:45 ` [PATCH 03/14] btrfs: Make btrfs_truncate_inode_items " David Sterba
2020-11-02 14:48 ` [PATCH 04/14] btrfs: Make btrfs_finish_ordered_io btrfs_inode-centric Nikolay Borisov
2020-11-02 14:48 ` [PATCH 05/14] btrfs: Make btrfs_delayed_update_inode take btrfs_inode Nikolay Borisov
2020-11-02 14:48 ` [PATCH 06/14] btrfs: Make btrfs_update_inode_item " Nikolay Borisov
2020-11-02 14:48 ` [PATCH 07/14] btrfs: Make btrfs_update_inode " Nikolay Borisov
2020-11-02 14:49 ` [PATCH 08/14] btrfs: Make maybe_insert_hole " Nikolay Borisov
2020-11-02 14:49 ` [PATCH 09/14] btrfs: Make find_first_non_hole " Nikolay Borisov
2020-11-02 14:49 ` [PATCH 10/14] btrfs: Make btrfs_insert_replace_extent " Nikolay Borisov
2020-11-02 14:49 ` [PATCH 11/14] btrfs: Make btrfs_truncate_block " Nikolay Borisov
2020-11-02 14:49 ` [PATCH 12/14] btrfs: Make btrfs_cont_expand " Nikolay Borisov
2020-11-02 14:49 ` [PATCH 13/14] btrfs: Make btrfs_drop_extents " Nikolay Borisov
2020-11-02 14:49 ` [PATCH 14/14] btrfs: Make btrfs_update_inode_fallback " Nikolay Borisov
2020-11-02 15:48 ` [PATCH 00/14] Another batch of inode vs btrfs_inode cleanups Johannes Thumshirn
2020-11-02 16:10 ` David Sterba
2020-11-02 16:25 ` Johannes Thumshirn
2020-11-05 16:21 ` David Sterba
2020-11-12 18:25 ` David Sterba
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=20201102144906.3767963-4-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 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).