* [PATCH 0/8] btrfs: some cleanups around inode update and helpers
@ 2023-09-22 10:37 fdmanana
2023-09-22 10:37 ` [PATCH 1/8] btrfs: simplify error check condition at btrfs_dirty_inode() fdmanana
` (8 more replies)
0 siblings, 9 replies; 17+ messages in thread
From: fdmanana @ 2023-09-22 10:37 UTC (permalink / raw)
To: linux-btrfs
From: Filipe Manana <fdmanana@suse.com>
Some cleanups mostly around btrfs_update_inode(), its helpers and some
callers, mostly to remove the redundant root argument, which can be taken
from the given inode. More details in the changelogs.
Filipe Manana (8):
btrfs: simplify error check condition at btrfs_dirty_inode()
btrfs: remove noline from btrfs_update_inode()
btrfs: remove redundant root argument from btrfs_update_inode_fallback()
btrfs: remove redundant root argument from btrfs_update_inode()
btrfs: remove redundant root argument from btrfs_update_inode_item()
btrfs: remove redundant root argument from btrfs_delayed_update_inode()
btrfs: remove redundant root argument from maybe_insert_hole()
btrfs: remove redundant root argument from fixup_inode_link_count()
fs/btrfs/block-group.c | 3 +-
fs/btrfs/btrfs_inode.h | 4 +--
fs/btrfs/delayed-inode.c | 2 +-
fs/btrfs/delayed-inode.h | 1 -
fs/btrfs/file.c | 8 ++---
fs/btrfs/free-space-cache.c | 13 ++++----
fs/btrfs/inode.c | 66 ++++++++++++++++++-------------------
fs/btrfs/ioctl.c | 2 +-
fs/btrfs/reflink.c | 3 +-
fs/btrfs/transaction.c | 2 +-
fs/btrfs/tree-log.c | 32 +++++++++---------
fs/btrfs/verity.c | 4 +--
fs/btrfs/xattr.c | 4 +--
13 files changed, 68 insertions(+), 76 deletions(-)
--
2.40.1
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH 1/8] btrfs: simplify error check condition at btrfs_dirty_inode()
2023-09-22 10:37 [PATCH 0/8] btrfs: some cleanups around inode update and helpers fdmanana
@ 2023-09-22 10:37 ` fdmanana
2023-09-22 22:00 ` Qu Wenruo
2023-09-22 10:37 ` [PATCH 2/8] btrfs: remove noline from btrfs_update_inode() fdmanana
` (7 subsequent siblings)
8 siblings, 1 reply; 17+ messages in thread
From: fdmanana @ 2023-09-22 10:37 UTC (permalink / raw)
To: linux-btrfs
From: Filipe Manana <fdmanana@suse.com>
The following condition at btrfs_dirty_inode() is redundant:
if (ret && (ret == -ENOSPC || ret == -EDQUOT))
The first check for a non-zero 'ret' value is pointless, we can simplify
this to simply:
if (ret == -ENOSPC || ret == -EDQUOT)
Not only this makes it easier to read, it also slightly reduces the text
size of the btrfs kernel module:
$ size fs/btrfs/btrfs.ko.before
text data bss dec hex filename
1641400 168265 16864 1826529 1bdee1 fs/btrfs/btrfs.ko.before
$ size fs/btrfs/btrfs.ko.after
text data bss dec hex filename
1641224 168181 16864 1826269 1bdddd fs/btrfs/btrfs.ko.after
Signed-off-by: Filipe Manana <fdmanana@suse.com>
---
fs/btrfs/inode.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 514d2e8a4f52..f16dfeabeaf0 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -6011,7 +6011,7 @@ static int btrfs_dirty_inode(struct btrfs_inode *inode)
return PTR_ERR(trans);
ret = btrfs_update_inode(trans, root, inode);
- if (ret && (ret == -ENOSPC || ret == -EDQUOT)) {
+ if (ret == -ENOSPC || ret == -EDQUOT) {
/* whoops, lets try again with the full transaction */
btrfs_end_transaction(trans);
trans = btrfs_start_transaction(root, 1);
--
2.40.1
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH 2/8] btrfs: remove noline from btrfs_update_inode()
2023-09-22 10:37 [PATCH 0/8] btrfs: some cleanups around inode update and helpers fdmanana
2023-09-22 10:37 ` [PATCH 1/8] btrfs: simplify error check condition at btrfs_dirty_inode() fdmanana
@ 2023-09-22 10:37 ` fdmanana
2023-09-22 22:00 ` Qu Wenruo
2023-09-22 10:37 ` [PATCH 3/8] btrfs: remove redundant root argument from btrfs_update_inode_fallback() fdmanana
` (6 subsequent siblings)
8 siblings, 1 reply; 17+ messages in thread
From: fdmanana @ 2023-09-22 10:37 UTC (permalink / raw)
To: linux-btrfs
From: Filipe Manana <fdmanana@suse.com>
The noinline attribute of btrfs_update_inode() is pointless as the
function is exported and widely used, so remove it.
Signed-off-by: Filipe Manana <fdmanana@suse.com>
---
fs/btrfs/inode.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index f16dfeabeaf0..fb7d7d0077f0 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -4001,9 +4001,9 @@ static noinline int btrfs_update_inode_item(struct btrfs_trans_handle *trans,
/*
* copy everything in the in-memory inode into the btree.
*/
-noinline int btrfs_update_inode(struct btrfs_trans_handle *trans,
- struct btrfs_root *root,
- struct btrfs_inode *inode)
+int btrfs_update_inode(struct btrfs_trans_handle *trans,
+ struct btrfs_root *root,
+ struct btrfs_inode *inode)
{
struct btrfs_fs_info *fs_info = root->fs_info;
int ret;
--
2.40.1
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH 3/8] btrfs: remove redundant root argument from btrfs_update_inode_fallback()
2023-09-22 10:37 [PATCH 0/8] btrfs: some cleanups around inode update and helpers fdmanana
2023-09-22 10:37 ` [PATCH 1/8] btrfs: simplify error check condition at btrfs_dirty_inode() fdmanana
2023-09-22 10:37 ` [PATCH 2/8] btrfs: remove noline from btrfs_update_inode() fdmanana
@ 2023-09-22 10:37 ` fdmanana
2023-09-22 10:37 ` [PATCH 4/8] btrfs: remove redundant root argument from btrfs_update_inode() fdmanana
` (5 subsequent siblings)
8 siblings, 0 replies; 17+ messages in thread
From: fdmanana @ 2023-09-22 10:37 UTC (permalink / raw)
To: linux-btrfs
From: Filipe Manana <fdmanana@suse.com>
The root argument for btrfs_update_inode_fallback() always matches the
root of the given inode, so remove the root argument and get it from the
inode argument.
Signed-off-by: Filipe Manana <fdmanana@suse.com>
---
fs/btrfs/btrfs_inode.h | 2 +-
fs/btrfs/inode.c | 12 ++++++------
fs/btrfs/transaction.c | 2 +-
3 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/fs/btrfs/btrfs_inode.h b/fs/btrfs/btrfs_inode.h
index 4311ac9ca0ae..d12556627cce 100644
--- a/fs/btrfs/btrfs_inode.h
+++ b/fs/btrfs/btrfs_inode.h
@@ -484,7 +484,7 @@ struct extent_map *btrfs_get_extent(struct btrfs_inode *inode,
int btrfs_update_inode(struct btrfs_trans_handle *trans,
struct btrfs_root *root, struct btrfs_inode *inode);
int btrfs_update_inode_fallback(struct btrfs_trans_handle *trans,
- struct btrfs_root *root, struct btrfs_inode *inode);
+ struct btrfs_inode *inode);
int btrfs_orphan_add(struct btrfs_trans_handle *trans, struct btrfs_inode *inode);
int btrfs_orphan_cleanup(struct btrfs_root *root);
int btrfs_cont_expand(struct btrfs_inode *inode, loff_t oldsize, loff_t size);
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index fb7d7d0077f0..44836d1f99a9 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -3074,7 +3074,7 @@ int btrfs_finish_one_ordered(struct btrfs_ordered_extent *ordered_extent)
goto out;
}
trans->block_rsv = &inode->block_rsv;
- ret = btrfs_update_inode_fallback(trans, root, inode);
+ ret = btrfs_update_inode_fallback(trans, inode);
if (ret) /* -ENOMEM or corruption */
btrfs_abort_transaction(trans, ret);
goto out;
@@ -3144,7 +3144,7 @@ int btrfs_finish_one_ordered(struct btrfs_ordered_extent *ordered_extent)
&cached_state);
btrfs_inode_safe_disk_i_size_write(inode, 0);
- ret = btrfs_update_inode_fallback(trans, root, inode);
+ ret = btrfs_update_inode_fallback(trans, inode);
if (ret) { /* -ENOMEM or corruption */
btrfs_abort_transaction(trans, ret);
goto out;
@@ -4030,13 +4030,13 @@ int btrfs_update_inode(struct btrfs_trans_handle *trans,
}
int btrfs_update_inode_fallback(struct btrfs_trans_handle *trans,
- struct btrfs_root *root, struct btrfs_inode *inode)
+ struct btrfs_inode *inode)
{
int ret;
- ret = btrfs_update_inode(trans, root, inode);
+ ret = btrfs_update_inode(trans, inode->root, inode);
if (ret == -ENOSPC)
- return btrfs_update_inode_item(trans, root, inode);
+ return btrfs_update_inode_item(trans, inode->root, inode);
return ret;
}
@@ -4316,7 +4316,7 @@ static int btrfs_unlink_subvol(struct btrfs_trans_handle *trans,
btrfs_i_size_write(dir, dir->vfs_inode.i_size - fname.disk_name.len * 2);
inode_inc_iversion(&dir->vfs_inode);
dir->vfs_inode.i_mtime = inode_set_ctime_current(&dir->vfs_inode);
- ret = btrfs_update_inode_fallback(trans, root, dir);
+ ret = btrfs_update_inode_fallback(trans, dir);
if (ret)
btrfs_abort_transaction(trans, ret);
out:
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index 3f9f933039c6..240dad25fa16 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -1942,7 +1942,7 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
btrfs_i_size_write(BTRFS_I(parent_inode), parent_inode->i_size +
fname.disk_name.len * 2);
parent_inode->i_mtime = inode_set_ctime_current(parent_inode);
- ret = btrfs_update_inode_fallback(trans, parent_root, BTRFS_I(parent_inode));
+ ret = btrfs_update_inode_fallback(trans, BTRFS_I(parent_inode));
if (ret) {
btrfs_abort_transaction(trans, ret);
goto fail;
--
2.40.1
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH 4/8] btrfs: remove redundant root argument from btrfs_update_inode()
2023-09-22 10:37 [PATCH 0/8] btrfs: some cleanups around inode update and helpers fdmanana
` (2 preceding siblings ...)
2023-09-22 10:37 ` [PATCH 3/8] btrfs: remove redundant root argument from btrfs_update_inode_fallback() fdmanana
@ 2023-09-22 10:37 ` fdmanana
2023-09-22 22:04 ` Qu Wenruo
2023-09-22 10:37 ` [PATCH 5/8] btrfs: remove redundant root argument from btrfs_update_inode_item() fdmanana
` (4 subsequent siblings)
8 siblings, 1 reply; 17+ messages in thread
From: fdmanana @ 2023-09-22 10:37 UTC (permalink / raw)
To: linux-btrfs
From: Filipe Manana <fdmanana@suse.com>
The root argument for btrfs_update_inode() always matches the root of the
given inode, so remove the root argument and get it from the inode
argument.
Signed-off-by: Filipe Manana <fdmanana@suse.com>
---
fs/btrfs/block-group.c | 3 +--
fs/btrfs/btrfs_inode.h | 2 +-
fs/btrfs/file.c | 8 ++++----
fs/btrfs/free-space-cache.c | 13 ++++++-------
fs/btrfs/inode.c | 34 +++++++++++++++++-----------------
fs/btrfs/ioctl.c | 2 +-
fs/btrfs/reflink.c | 3 +--
fs/btrfs/tree-log.c | 12 ++++++------
fs/btrfs/verity.c | 4 ++--
fs/btrfs/xattr.c | 4 ++--
10 files changed, 41 insertions(+), 44 deletions(-)
diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c
index 2b9aaeefaf76..6e2a4000bfe0 100644
--- a/fs/btrfs/block-group.c
+++ b/fs/btrfs/block-group.c
@@ -3051,7 +3051,6 @@ static int cache_save_setup(struct btrfs_block_group *block_group,
struct btrfs_path *path)
{
struct btrfs_fs_info *fs_info = block_group->fs_info;
- struct btrfs_root *root = fs_info->tree_root;
struct inode *inode = NULL;
struct extent_changeset *data_reserved = NULL;
u64 alloc_hint = 0;
@@ -3103,7 +3102,7 @@ static int cache_save_setup(struct btrfs_block_group *block_group,
* time.
*/
BTRFS_I(inode)->generation = 0;
- ret = btrfs_update_inode(trans, root, BTRFS_I(inode));
+ ret = btrfs_update_inode(trans, BTRFS_I(inode));
if (ret) {
/*
* So theoretically we could recover from this, simply set the
diff --git a/fs/btrfs/btrfs_inode.h b/fs/btrfs/btrfs_inode.h
index d12556627cce..f2c928345d53 100644
--- a/fs/btrfs/btrfs_inode.h
+++ b/fs/btrfs/btrfs_inode.h
@@ -482,7 +482,7 @@ struct extent_map *btrfs_get_extent(struct btrfs_inode *inode,
struct page *page, size_t pg_offset,
u64 start, u64 end);
int btrfs_update_inode(struct btrfs_trans_handle *trans,
- struct btrfs_root *root, struct btrfs_inode *inode);
+ struct btrfs_inode *inode);
int btrfs_update_inode_fallback(struct btrfs_trans_handle *trans,
struct btrfs_inode *inode);
int btrfs_orphan_add(struct btrfs_trans_handle *trans, struct btrfs_inode *inode);
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index 7d6652941210..e847043defce 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -2460,7 +2460,7 @@ int btrfs_replace_file_extents(struct btrfs_inode *inode,
if (!extent_info || extent_info->update_times)
inode->vfs_inode.i_mtime = inode_set_ctime_current(&inode->vfs_inode);
- ret = btrfs_update_inode(trans, root, inode);
+ ret = btrfs_update_inode(trans, inode);
if (ret)
break;
@@ -2700,7 +2700,7 @@ static int btrfs_punch_hole(struct file *file, loff_t offset, loff_t len)
ASSERT(trans != NULL);
inode_inc_iversion(inode);
inode->i_mtime = inode_set_ctime_current(inode);
- ret = btrfs_update_inode(trans, root, BTRFS_I(inode));
+ ret = btrfs_update_inode(trans, BTRFS_I(inode));
updated_inode = true;
btrfs_end_transaction(trans);
btrfs_btree_balance_dirty(fs_info);
@@ -2726,7 +2726,7 @@ static int btrfs_punch_hole(struct file *file, loff_t offset, loff_t len)
} else {
int ret2;
- ret = btrfs_update_inode(trans, root, BTRFS_I(inode));
+ ret = btrfs_update_inode(trans, BTRFS_I(inode));
ret2 = btrfs_end_transaction(trans);
if (!ret)
ret = ret2;
@@ -2793,7 +2793,7 @@ static int btrfs_fallocate_update_isize(struct inode *inode,
inode_set_ctime_current(inode);
i_size_write(inode, end);
btrfs_inode_safe_disk_i_size_write(BTRFS_I(inode), 0);
- ret = btrfs_update_inode(trans, root, BTRFS_I(inode));
+ ret = btrfs_update_inode(trans, BTRFS_I(inode));
ret2 = btrfs_end_transaction(trans);
return ret ? ret : ret2;
diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
index acb8ef3dd6b0..6f93c9a2c3e3 100644
--- a/fs/btrfs/free-space-cache.c
+++ b/fs/btrfs/free-space-cache.c
@@ -359,7 +359,7 @@ int btrfs_truncate_free_space_cache(struct btrfs_trans_handle *trans,
if (ret)
goto fail;
- ret = btrfs_update_inode(trans, root, inode);
+ ret = btrfs_update_inode(trans, inode);
fail:
if (locked)
@@ -1326,7 +1326,7 @@ static int __btrfs_wait_cache_io(struct btrfs_root *root,
"failed to write free space cache for block group %llu error %d",
block_group->start, ret);
}
- btrfs_update_inode(trans, root, BTRFS_I(inode));
+ btrfs_update_inode(trans, BTRFS_I(inode));
if (block_group) {
/* the dirty list is protected by the dirty_bgs_lock */
@@ -1367,7 +1367,6 @@ int btrfs_wait_cache_io(struct btrfs_trans_handle *trans,
/*
* Write out cached info to an inode.
*
- * @root: root the inode belongs to
* @inode: freespace inode we are writing out
* @ctl: free space cache we are going to write out
* @block_group: block_group for this cache if it belongs to a block_group
@@ -1378,7 +1377,7 @@ int btrfs_wait_cache_io(struct btrfs_trans_handle *trans,
* on mount. This will return 0 if it was successful in writing the cache out,
* or an errno if it was not.
*/
-static int __btrfs_write_out_cache(struct btrfs_root *root, struct inode *inode,
+static int __btrfs_write_out_cache(struct inode *inode,
struct btrfs_free_space_ctl *ctl,
struct btrfs_block_group *block_group,
struct btrfs_io_ctl *io_ctl,
@@ -1511,7 +1510,7 @@ static int __btrfs_write_out_cache(struct btrfs_root *root, struct inode *inode,
invalidate_inode_pages2(inode->i_mapping);
BTRFS_I(inode)->generation = 0;
}
- btrfs_update_inode(trans, root, BTRFS_I(inode));
+ btrfs_update_inode(trans, BTRFS_I(inode));
if (must_iput)
iput(inode);
return ret;
@@ -1537,8 +1536,8 @@ int btrfs_write_out_cache(struct btrfs_trans_handle *trans,
if (IS_ERR(inode))
return 0;
- ret = __btrfs_write_out_cache(fs_info->tree_root, inode, ctl,
- block_group, &block_group->io_ctl, trans);
+ ret = __btrfs_write_out_cache(inode, ctl, block_group,
+ &block_group->io_ctl, trans);
if (ret) {
btrfs_debug(fs_info,
"failed to write free space cache for block group %llu error %d",
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 44836d1f99a9..13a97d3ce34a 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -671,7 +671,7 @@ static noinline int cow_file_range_inline(struct btrfs_inode *inode, u64 size,
}
btrfs_update_inode_bytes(inode, size, drop_args.bytes_found);
- ret = btrfs_update_inode(trans, root, inode);
+ ret = btrfs_update_inode(trans, inode);
if (ret && ret != -ENOSPC) {
btrfs_abort_transaction(trans, ret);
goto out;
@@ -4002,9 +4002,9 @@ static noinline int btrfs_update_inode_item(struct btrfs_trans_handle *trans,
* copy everything in the in-memory inode into the btree.
*/
int btrfs_update_inode(struct btrfs_trans_handle *trans,
- struct btrfs_root *root,
struct btrfs_inode *inode)
{
+ struct btrfs_root *root = inode->root;
struct btrfs_fs_info *fs_info = root->fs_info;
int ret;
@@ -4034,7 +4034,7 @@ int btrfs_update_inode_fallback(struct btrfs_trans_handle *trans,
{
int ret;
- ret = btrfs_update_inode(trans, inode->root, inode);
+ ret = btrfs_update_inode(trans, inode);
if (ret == -ENOSPC)
return btrfs_update_inode_item(trans, inode->root, inode);
return ret;
@@ -4143,7 +4143,7 @@ static int __btrfs_unlink_inode(struct btrfs_trans_handle *trans,
inode_inc_iversion(&dir->vfs_inode);
inode_set_ctime_current(&inode->vfs_inode);
dir->vfs_inode.i_mtime = inode_set_ctime_current(&dir->vfs_inode);
- ret = btrfs_update_inode(trans, root, dir);
+ ret = btrfs_update_inode(trans, dir);
out:
return ret;
}
@@ -4157,7 +4157,7 @@ int btrfs_unlink_inode(struct btrfs_trans_handle *trans,
ret = __btrfs_unlink_inode(trans, dir, inode, name, NULL);
if (!ret) {
drop_nlink(&inode->vfs_inode);
- ret = btrfs_update_inode(trans, inode->root, inode);
+ ret = btrfs_update_inode(trans, inode);
}
return ret;
}
@@ -4843,7 +4843,7 @@ static int maybe_insert_hole(struct btrfs_root *root, struct btrfs_inode *inode,
btrfs_abort_transaction(trans, ret);
} else {
btrfs_update_inode_bytes(inode, 0, drop_args.bytes_found);
- btrfs_update_inode(trans, root, inode);
+ btrfs_update_inode(trans, inode);
}
btrfs_end_transaction(trans);
return ret;
@@ -4994,7 +4994,7 @@ static int btrfs_setsize(struct inode *inode, struct iattr *attr)
i_size_write(inode, newsize);
btrfs_inode_safe_disk_i_size_write(BTRFS_I(inode), 0);
pagecache_isize_extended(inode, oldsize, newsize);
- ret = btrfs_update_inode(trans, root, BTRFS_I(inode));
+ ret = btrfs_update_inode(trans, BTRFS_I(inode));
btrfs_drew_write_unlock(&root->snapshot_lock);
btrfs_end_transaction(trans);
} else {
@@ -6010,7 +6010,7 @@ static int btrfs_dirty_inode(struct btrfs_inode *inode)
if (IS_ERR(trans))
return PTR_ERR(trans);
- ret = btrfs_update_inode(trans, root, inode);
+ ret = btrfs_update_inode(trans, inode);
if (ret == -ENOSPC || ret == -EDQUOT) {
/* whoops, lets try again with the full transaction */
btrfs_end_transaction(trans);
@@ -6018,7 +6018,7 @@ static int btrfs_dirty_inode(struct btrfs_inode *inode)
if (IS_ERR(trans))
return PTR_ERR(trans);
- ret = btrfs_update_inode(trans, root, inode);
+ ret = btrfs_update_inode(trans, inode);
}
btrfs_end_transaction(trans);
if (inode->delayed_node)
@@ -6457,7 +6457,7 @@ int btrfs_add_link(struct btrfs_trans_handle *trans,
parent_inode->vfs_inode.i_mtime =
inode_set_ctime_current(&parent_inode->vfs_inode);
- ret = btrfs_update_inode(trans, root, parent_inode);
+ ret = btrfs_update_inode(trans, parent_inode);
if (ret)
btrfs_abort_transaction(trans, ret);
return ret;
@@ -6608,7 +6608,7 @@ static int btrfs_link(struct dentry *old_dentry, struct inode *dir,
} else {
struct dentry *parent = dentry->d_parent;
- err = btrfs_update_inode(trans, root, BTRFS_I(inode));
+ err = btrfs_update_inode(trans, BTRFS_I(inode));
if (err)
goto fail;
if (inode->i_nlink == 1) {
@@ -8349,7 +8349,7 @@ static int btrfs_truncate(struct btrfs_inode *inode, bool skip_writeback)
if (ret != -ENOSPC && ret != -EAGAIN)
break;
- ret = btrfs_update_inode(trans, root, inode);
+ ret = btrfs_update_inode(trans, inode);
if (ret)
break;
@@ -8402,7 +8402,7 @@ static int btrfs_truncate(struct btrfs_inode *inode, bool skip_writeback)
int ret2;
trans->block_rsv = &fs_info->trans_block_rsv;
- ret2 = btrfs_update_inode(trans, root, inode);
+ ret2 = btrfs_update_inode(trans, inode);
if (ret2 && !ret)
ret = ret2;
@@ -8833,7 +8833,7 @@ static int btrfs_rename_exchange(struct inode *old_dir,
BTRFS_I(old_dentry->d_inode),
old_name, &old_rename_ctx);
if (!ret)
- ret = btrfs_update_inode(trans, root, BTRFS_I(old_inode));
+ ret = btrfs_update_inode(trans, BTRFS_I(old_inode));
}
if (ret) {
btrfs_abort_transaction(trans, ret);
@@ -8848,7 +8848,7 @@ static int btrfs_rename_exchange(struct inode *old_dir,
BTRFS_I(new_dentry->d_inode),
new_name, &new_rename_ctx);
if (!ret)
- ret = btrfs_update_inode(trans, dest, BTRFS_I(new_inode));
+ ret = btrfs_update_inode(trans, BTRFS_I(new_inode));
}
if (ret) {
btrfs_abort_transaction(trans, ret);
@@ -9093,7 +9093,7 @@ static int btrfs_rename(struct mnt_idmap *idmap,
BTRFS_I(d_inode(old_dentry)),
&old_fname.disk_name, &rename_ctx);
if (!ret)
- ret = btrfs_update_inode(trans, root, BTRFS_I(old_inode));
+ ret = btrfs_update_inode(trans, BTRFS_I(old_inode));
}
if (ret) {
btrfs_abort_transaction(trans, ret);
@@ -9649,7 +9649,7 @@ static int __btrfs_prealloc_file_range(struct inode *inode, int mode,
btrfs_inode_safe_disk_i_size_write(BTRFS_I(inode), 0);
}
- ret = btrfs_update_inode(trans, root, BTRFS_I(inode));
+ ret = btrfs_update_inode(trans, BTRFS_I(inode));
if (ret) {
btrfs_abort_transaction(trans, ret);
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 018ea98b239a..24eae7c2b3ae 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -385,7 +385,7 @@ int btrfs_fileattr_set(struct mnt_idmap *idmap,
btrfs_sync_inode_flags_to_i_flags(inode);
inode_inc_iversion(inode);
inode_set_ctime_current(inode);
- ret = btrfs_update_inode(trans, root, BTRFS_I(inode));
+ ret = btrfs_update_inode(trans, BTRFS_I(inode));
out_end_trans:
btrfs_end_transaction(trans);
diff --git a/fs/btrfs/reflink.c b/fs/btrfs/reflink.c
index 65d2bd6910f2..fabd856e5079 100644
--- a/fs/btrfs/reflink.c
+++ b/fs/btrfs/reflink.c
@@ -25,7 +25,6 @@ static int clone_finish_inode_update(struct btrfs_trans_handle *trans,
const u64 olen,
int no_time_update)
{
- struct btrfs_root *root = BTRFS_I(inode)->root;
int ret;
inode_inc_iversion(inode);
@@ -43,7 +42,7 @@ static int clone_finish_inode_update(struct btrfs_trans_handle *trans,
btrfs_inode_safe_disk_i_size_write(BTRFS_I(inode), 0);
}
- ret = btrfs_update_inode(trans, root, BTRFS_I(inode));
+ ret = btrfs_update_inode(trans, BTRFS_I(inode));
if (ret) {
btrfs_abort_transaction(trans, ret);
btrfs_end_transaction(trans);
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index 595982434216..a7bba3d61e55 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -889,7 +889,7 @@ static noinline int replay_one_extent(struct btrfs_trans_handle *trans,
update_inode:
btrfs_update_inode_bytes(BTRFS_I(inode), nbytes, drop_args.bytes_found);
- ret = btrfs_update_inode(trans, root, BTRFS_I(inode));
+ ret = btrfs_update_inode(trans, BTRFS_I(inode));
out:
iput(inode);
return ret;
@@ -1444,7 +1444,7 @@ static noinline int add_inode_ref(struct btrfs_trans_handle *trans,
if (ret)
goto out;
- ret = btrfs_update_inode(trans, root, BTRFS_I(inode));
+ ret = btrfs_update_inode(trans, BTRFS_I(inode));
if (ret)
goto out;
}
@@ -1622,7 +1622,7 @@ static noinline int fixup_inode_link_count(struct btrfs_trans_handle *trans,
if (nlink != inode->i_nlink) {
set_nlink(inode, nlink);
- ret = btrfs_update_inode(trans, root, BTRFS_I(inode));
+ ret = btrfs_update_inode(trans, BTRFS_I(inode));
if (ret)
goto out;
}
@@ -1731,7 +1731,7 @@ static noinline int link_to_fixup_dir(struct btrfs_trans_handle *trans,
set_nlink(inode, 1);
else
inc_nlink(inode);
- ret = btrfs_update_inode(trans, root, BTRFS_I(inode));
+ ret = btrfs_update_inode(trans, BTRFS_I(inode));
} else if (ret == -EEXIST) {
ret = 0;
}
@@ -1938,7 +1938,7 @@ static noinline int replay_one_name(struct btrfs_trans_handle *trans,
out:
if (!ret && update_size) {
btrfs_i_size_write(BTRFS_I(dir), dir->i_size + name.len * 2);
- ret = btrfs_update_inode(trans, root, BTRFS_I(dir));
+ ret = btrfs_update_inode(trans, BTRFS_I(dir));
}
kfree(name.name);
iput(dir);
@@ -2482,7 +2482,7 @@ static int replay_one_buffer(struct btrfs_root *log, struct extent_buffer *eb,
drop_args.bytes_found);
/* Update the inode's nbytes. */
ret = btrfs_update_inode(wc->trans,
- root, BTRFS_I(inode));
+ BTRFS_I(inode));
}
iput(inode);
if (ret)
diff --git a/fs/btrfs/verity.c b/fs/btrfs/verity.c
index 744f4f4d4c68..66e2270b0dae 100644
--- a/fs/btrfs/verity.c
+++ b/fs/btrfs/verity.c
@@ -487,7 +487,7 @@ static int rollback_verity(struct btrfs_inode *inode)
}
inode->ro_flags &= ~BTRFS_INODE_RO_VERITY;
btrfs_sync_inode_flags_to_i_flags(&inode->vfs_inode);
- ret = btrfs_update_inode(trans, root, inode);
+ ret = btrfs_update_inode(trans, inode);
if (ret) {
btrfs_abort_transaction(trans, ret);
goto out;
@@ -554,7 +554,7 @@ static int finish_verity(struct btrfs_inode *inode, const void *desc,
}
inode->ro_flags |= BTRFS_INODE_RO_VERITY;
btrfs_sync_inode_flags_to_i_flags(&inode->vfs_inode);
- ret = btrfs_update_inode(trans, root, inode);
+ ret = btrfs_update_inode(trans, inode);
if (ret)
goto end_trans;
ret = del_orphan(trans, inode);
diff --git a/fs/btrfs/xattr.c b/fs/btrfs/xattr.c
index b906f809650e..76ff93b3eb27 100644
--- a/fs/btrfs/xattr.c
+++ b/fs/btrfs/xattr.c
@@ -265,7 +265,7 @@ int btrfs_setxattr_trans(struct inode *inode, const char *name,
inode_inc_iversion(inode);
inode_set_ctime_current(inode);
- ret = btrfs_update_inode(trans, root, BTRFS_I(inode));
+ ret = btrfs_update_inode(trans, BTRFS_I(inode));
if (ret)
btrfs_abort_transaction(trans, ret);
out:
@@ -408,7 +408,7 @@ static int btrfs_xattr_handler_set_prop(const struct xattr_handler *handler,
if (!ret) {
inode_inc_iversion(inode);
inode_set_ctime_current(inode);
- ret = btrfs_update_inode(trans, root, BTRFS_I(inode));
+ ret = btrfs_update_inode(trans, BTRFS_I(inode));
if (ret)
btrfs_abort_transaction(trans, ret);
}
--
2.40.1
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH 5/8] btrfs: remove redundant root argument from btrfs_update_inode_item()
2023-09-22 10:37 [PATCH 0/8] btrfs: some cleanups around inode update and helpers fdmanana
` (3 preceding siblings ...)
2023-09-22 10:37 ` [PATCH 4/8] btrfs: remove redundant root argument from btrfs_update_inode() fdmanana
@ 2023-09-22 10:37 ` fdmanana
2023-09-22 22:06 ` Qu Wenruo
2023-09-22 10:37 ` [PATCH 6/8] btrfs: remove redundant root argument from btrfs_delayed_update_inode() fdmanana
` (3 subsequent siblings)
8 siblings, 1 reply; 17+ messages in thread
From: fdmanana @ 2023-09-22 10:37 UTC (permalink / raw)
To: linux-btrfs
From: Filipe Manana <fdmanana@suse.com>
The root argument for btrfs_update_inode_item() always matches the root of
the given inode, so remove the root argument and get it from the inode
argument.
Signed-off-by: Filipe Manana <fdmanana@suse.com>
---
fs/btrfs/inode.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 13a97d3ce34a..c4b5d4047c5d 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -3966,8 +3966,7 @@ static void fill_inode_item(struct btrfs_trans_handle *trans,
* copy everything in the in-memory inode into the btree.
*/
static noinline int btrfs_update_inode_item(struct btrfs_trans_handle *trans,
- struct btrfs_root *root,
- struct btrfs_inode *inode)
+ struct btrfs_inode *inode)
{
struct btrfs_inode_item *inode_item;
struct btrfs_path *path;
@@ -3978,7 +3977,7 @@ static noinline int btrfs_update_inode_item(struct btrfs_trans_handle *trans,
if (!path)
return -ENOMEM;
- ret = btrfs_lookup_inode(trans, root, path, &inode->location, 1);
+ ret = btrfs_lookup_inode(trans, inode->root, path, &inode->location, 1);
if (ret) {
if (ret > 0)
ret = -ENOENT;
@@ -4026,7 +4025,7 @@ int btrfs_update_inode(struct btrfs_trans_handle *trans,
return ret;
}
- return btrfs_update_inode_item(trans, root, inode);
+ return btrfs_update_inode_item(trans, inode);
}
int btrfs_update_inode_fallback(struct btrfs_trans_handle *trans,
@@ -4036,7 +4035,7 @@ int btrfs_update_inode_fallback(struct btrfs_trans_handle *trans,
ret = btrfs_update_inode(trans, inode);
if (ret == -ENOSPC)
- return btrfs_update_inode_item(trans, inode->root, inode);
+ return btrfs_update_inode_item(trans, inode);
return ret;
}
--
2.40.1
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH 6/8] btrfs: remove redundant root argument from btrfs_delayed_update_inode()
2023-09-22 10:37 [PATCH 0/8] btrfs: some cleanups around inode update and helpers fdmanana
` (4 preceding siblings ...)
2023-09-22 10:37 ` [PATCH 5/8] btrfs: remove redundant root argument from btrfs_update_inode_item() fdmanana
@ 2023-09-22 10:37 ` fdmanana
2023-09-22 22:08 ` Qu Wenruo
2023-09-22 10:37 ` [PATCH 7/8] btrfs: remove redundant root argument from maybe_insert_hole() fdmanana
` (2 subsequent siblings)
8 siblings, 1 reply; 17+ messages in thread
From: fdmanana @ 2023-09-22 10:37 UTC (permalink / raw)
To: linux-btrfs
From: Filipe Manana <fdmanana@suse.com>
The root argument for btrfs_delayed_update_inode() always matches the root
of the given inode, so remove the root argument and get it from the inode
argument.
Signed-off-by: Filipe Manana <fdmanana@suse.com>
---
fs/btrfs/delayed-inode.c | 2 +-
fs/btrfs/delayed-inode.h | 1 -
fs/btrfs/inode.c | 2 +-
3 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
index 8ba045ae1d75..35d7616615c1 100644
--- a/fs/btrfs/delayed-inode.c
+++ b/fs/btrfs/delayed-inode.c
@@ -1913,9 +1913,9 @@ int btrfs_fill_inode(struct inode *inode, u32 *rdev)
}
int btrfs_delayed_update_inode(struct btrfs_trans_handle *trans,
- struct btrfs_root *root,
struct btrfs_inode *inode)
{
+ struct btrfs_root *root = inode->root;
struct btrfs_delayed_node *delayed_node;
int ret = 0;
diff --git a/fs/btrfs/delayed-inode.h b/fs/btrfs/delayed-inode.h
index dc1085b2a397..d050e572c7f9 100644
--- a/fs/btrfs/delayed-inode.h
+++ b/fs/btrfs/delayed-inode.h
@@ -135,7 +135,6 @@ int btrfs_commit_inode_delayed_inode(struct btrfs_inode *inode);
int btrfs_delayed_update_inode(struct btrfs_trans_handle *trans,
- struct btrfs_root *root,
struct btrfs_inode *inode);
int btrfs_fill_inode(struct inode *inode, u32 *rdev);
int btrfs_delayed_delete_inode_ref(struct btrfs_inode *inode);
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index c4b5d4047c5d..54647b7fb600 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -4019,7 +4019,7 @@ int btrfs_update_inode(struct btrfs_trans_handle *trans,
&& !test_bit(BTRFS_FS_LOG_RECOVERING, &fs_info->flags)) {
btrfs_update_root_times(trans, root);
- ret = btrfs_delayed_update_inode(trans, root, inode);
+ ret = btrfs_delayed_update_inode(trans, inode);
if (!ret)
btrfs_set_inode_last_trans(trans, inode);
return ret;
--
2.40.1
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH 7/8] btrfs: remove redundant root argument from maybe_insert_hole()
2023-09-22 10:37 [PATCH 0/8] btrfs: some cleanups around inode update and helpers fdmanana
` (5 preceding siblings ...)
2023-09-22 10:37 ` [PATCH 6/8] btrfs: remove redundant root argument from btrfs_delayed_update_inode() fdmanana
@ 2023-09-22 10:37 ` fdmanana
2023-09-22 22:09 ` Qu Wenruo
2023-09-22 10:37 ` [PATCH 8/8] btrfs: remove redundant root argument from fixup_inode_link_count() fdmanana
2023-09-22 13:48 ` [PATCH 0/8] btrfs: some cleanups around inode update and helpers David Sterba
8 siblings, 1 reply; 17+ messages in thread
From: fdmanana @ 2023-09-22 10:37 UTC (permalink / raw)
To: linux-btrfs
From: Filipe Manana <fdmanana@suse.com>
The root argument for maybe_insert_hole() always matches the root of the
given inode, so remove the root argument and get it from the inode
argument.
Signed-off-by: Filipe Manana <fdmanana@suse.com>
---
fs/btrfs/inode.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 54647b7fb600..52576deda654 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -4800,9 +4800,9 @@ int btrfs_truncate_block(struct btrfs_inode *inode, loff_t from, loff_t len,
return ret;
}
-static int maybe_insert_hole(struct btrfs_root *root, struct btrfs_inode *inode,
- u64 offset, u64 len)
+static int maybe_insert_hole(struct btrfs_inode *inode, u64 offset, u64 len)
{
+ struct btrfs_root *root = inode->root;
struct btrfs_fs_info *fs_info = root->fs_info;
struct btrfs_trans_handle *trans;
struct btrfs_drop_extents_args drop_args = { 0 };
@@ -4898,8 +4898,7 @@ int btrfs_cont_expand(struct btrfs_inode *inode, loff_t oldsize, loff_t size)
if (!test_bit(EXTENT_FLAG_PREALLOC, &em->flags)) {
struct extent_map *hole_em;
- err = maybe_insert_hole(root, inode, cur_offset,
- hole_size);
+ err = maybe_insert_hole(inode, cur_offset, hole_size);
if (err)
break;
--
2.40.1
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH 8/8] btrfs: remove redundant root argument from fixup_inode_link_count()
2023-09-22 10:37 [PATCH 0/8] btrfs: some cleanups around inode update and helpers fdmanana
` (6 preceding siblings ...)
2023-09-22 10:37 ` [PATCH 7/8] btrfs: remove redundant root argument from maybe_insert_hole() fdmanana
@ 2023-09-22 10:37 ` fdmanana
2023-09-22 22:11 ` Qu Wenruo
2023-09-22 13:48 ` [PATCH 0/8] btrfs: some cleanups around inode update and helpers David Sterba
8 siblings, 1 reply; 17+ messages in thread
From: fdmanana @ 2023-09-22 10:37 UTC (permalink / raw)
To: linux-btrfs
From: Filipe Manana <fdmanana@suse.com>
The root argument for fixup_inode_link_count() always matches the root of
the given inode, so remove the root argument and get it from the inode
argument. This also applies to the helpers count_inode_extrefs() and
count_inode_refs() used by fixup_inode_link_count() - they don't need the
root argument, as it always matches the root of the inode passed to them.
Signed-off-by: Filipe Manana <fdmanana@suse.com>
---
fs/btrfs/tree-log.c | 20 +++++++++-----------
1 file changed, 9 insertions(+), 11 deletions(-)
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index a7bba3d61e55..f4257be56bd3 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -1482,8 +1482,7 @@ static noinline int add_inode_ref(struct btrfs_trans_handle *trans,
return ret;
}
-static int count_inode_extrefs(struct btrfs_root *root,
- struct btrfs_inode *inode, struct btrfs_path *path)
+static int count_inode_extrefs(struct btrfs_inode *inode, struct btrfs_path *path)
{
int ret = 0;
int name_len;
@@ -1497,8 +1496,8 @@ static int count_inode_extrefs(struct btrfs_root *root,
struct extent_buffer *leaf;
while (1) {
- ret = btrfs_find_one_extref(root, inode_objectid, offset, path,
- &extref, &offset);
+ ret = btrfs_find_one_extref(inode->root, inode_objectid, offset,
+ path, &extref, &offset);
if (ret)
break;
@@ -1526,8 +1525,7 @@ static int count_inode_extrefs(struct btrfs_root *root,
return nlink;
}
-static int count_inode_refs(struct btrfs_root *root,
- struct btrfs_inode *inode, struct btrfs_path *path)
+static int count_inode_refs(struct btrfs_inode *inode, struct btrfs_path *path)
{
int ret;
struct btrfs_key key;
@@ -1542,7 +1540,7 @@ static int count_inode_refs(struct btrfs_root *root,
key.offset = (u64)-1;
while (1) {
- ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
+ ret = btrfs_search_slot(NULL, inode->root, &key, path, 0, 0);
if (ret < 0)
break;
if (ret > 0) {
@@ -1594,9 +1592,9 @@ static int count_inode_refs(struct btrfs_root *root,
* will free the inode.
*/
static noinline int fixup_inode_link_count(struct btrfs_trans_handle *trans,
- struct btrfs_root *root,
struct inode *inode)
{
+ struct btrfs_root *root = BTRFS_I(inode)->root;
struct btrfs_path *path;
int ret;
u64 nlink = 0;
@@ -1606,13 +1604,13 @@ static noinline int fixup_inode_link_count(struct btrfs_trans_handle *trans,
if (!path)
return -ENOMEM;
- ret = count_inode_refs(root, BTRFS_I(inode), path);
+ ret = count_inode_refs(BTRFS_I(inode), path);
if (ret < 0)
goto out;
nlink = ret;
- ret = count_inode_extrefs(root, BTRFS_I(inode), path);
+ ret = count_inode_extrefs(BTRFS_I(inode), path);
if (ret < 0)
goto out;
@@ -1684,7 +1682,7 @@ static noinline int fixup_inode_link_counts(struct btrfs_trans_handle *trans,
break;
}
- ret = fixup_inode_link_count(trans, root, inode);
+ ret = fixup_inode_link_count(trans, inode);
iput(inode);
if (ret)
break;
--
2.40.1
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH 0/8] btrfs: some cleanups around inode update and helpers
2023-09-22 10:37 [PATCH 0/8] btrfs: some cleanups around inode update and helpers fdmanana
` (7 preceding siblings ...)
2023-09-22 10:37 ` [PATCH 8/8] btrfs: remove redundant root argument from fixup_inode_link_count() fdmanana
@ 2023-09-22 13:48 ` David Sterba
8 siblings, 0 replies; 17+ messages in thread
From: David Sterba @ 2023-09-22 13:48 UTC (permalink / raw)
To: fdmanana; +Cc: linux-btrfs
On Fri, Sep 22, 2023 at 11:37:18AM +0100, fdmanana@kernel.org wrote:
> From: Filipe Manana <fdmanana@suse.com>
>
> Some cleanups mostly around btrfs_update_inode(), its helpers and some
> callers, mostly to remove the redundant root argument, which can be taken
> from the given inode. More details in the changelogs.
>
> Filipe Manana (8):
> btrfs: simplify error check condition at btrfs_dirty_inode()
> btrfs: remove noline from btrfs_update_inode()
> btrfs: remove redundant root argument from btrfs_update_inode_fallback()
> btrfs: remove redundant root argument from btrfs_update_inode()
> btrfs: remove redundant root argument from btrfs_update_inode_item()
> btrfs: remove redundant root argument from btrfs_delayed_update_inode()
> btrfs: remove redundant root argument from maybe_insert_hole()
> btrfs: remove redundant root argument from fixup_inode_link_count()
Added to misc-next, thanks. The effects of removed parameters:
btrfs_finish_one_ordered -8 (208 -> 200)
btrfs_update_inode -8 (48 -> 40)
clone_finish_inode_update -8 (72 -> 64)
btrfs_cont_expand -8 (184 -> 176)
btrfs_xattr_handler_set_prop -8 (64 -> 56)
btrfs_fallocate_update_isize -8 (40 -> 32)
btrfs_add_link +8 (120 -> 128)
btrfs_update_inode_fallback -8 (32 -> 24)
btrfs_write_out_cache -8 (144 -> 136)
btrfs_setxattr_trans -8 (72 -> 64)
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 1/8] btrfs: simplify error check condition at btrfs_dirty_inode()
2023-09-22 10:37 ` [PATCH 1/8] btrfs: simplify error check condition at btrfs_dirty_inode() fdmanana
@ 2023-09-22 22:00 ` Qu Wenruo
0 siblings, 0 replies; 17+ messages in thread
From: Qu Wenruo @ 2023-09-22 22:00 UTC (permalink / raw)
To: fdmanana, linux-btrfs
On 2023/9/22 20:07, fdmanana@kernel.org wrote:
> From: Filipe Manana <fdmanana@suse.com>
>
> The following condition at btrfs_dirty_inode() is redundant:
>
> if (ret && (ret == -ENOSPC || ret == -EDQUOT))
>
> The first check for a non-zero 'ret' value is pointless, we can simplify
> this to simply:
>
> if (ret == -ENOSPC || ret == -EDQUOT)
>
> Not only this makes it easier to read, it also slightly reduces the text
> size of the btrfs kernel module:
>
> $ size fs/btrfs/btrfs.ko.before
> text data bss dec hex filename
> 1641400 168265 16864 1826529 1bdee1 fs/btrfs/btrfs.ko.before
>
> $ size fs/btrfs/btrfs.ko.after
> text data bss dec hex filename
> 1641224 168181 16864 1826269 1bdddd fs/btrfs/btrfs.ko.after
>
> Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
A little surprised that compiler didn't optimize it out.
Thanks,
Qu
> ---
> fs/btrfs/inode.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
> index 514d2e8a4f52..f16dfeabeaf0 100644
> --- a/fs/btrfs/inode.c
> +++ b/fs/btrfs/inode.c
> @@ -6011,7 +6011,7 @@ static int btrfs_dirty_inode(struct btrfs_inode *inode)
> return PTR_ERR(trans);
>
> ret = btrfs_update_inode(trans, root, inode);
> - if (ret && (ret == -ENOSPC || ret == -EDQUOT)) {
> + if (ret == -ENOSPC || ret == -EDQUOT) {
> /* whoops, lets try again with the full transaction */
> btrfs_end_transaction(trans);
> trans = btrfs_start_transaction(root, 1);
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 2/8] btrfs: remove noline from btrfs_update_inode()
2023-09-22 10:37 ` [PATCH 2/8] btrfs: remove noline from btrfs_update_inode() fdmanana
@ 2023-09-22 22:00 ` Qu Wenruo
0 siblings, 0 replies; 17+ messages in thread
From: Qu Wenruo @ 2023-09-22 22:00 UTC (permalink / raw)
To: fdmanana, linux-btrfs
On 2023/9/22 20:07, fdmanana@kernel.org wrote:
> From: Filipe Manana <fdmanana@suse.com>
>
> The noinline attribute of btrfs_update_inode() is pointless as the
> function is exported and widely used, so remove it.
>
> Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Thanks,
Qu
> ---
> fs/btrfs/inode.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
> index f16dfeabeaf0..fb7d7d0077f0 100644
> --- a/fs/btrfs/inode.c
> +++ b/fs/btrfs/inode.c
> @@ -4001,9 +4001,9 @@ static noinline int btrfs_update_inode_item(struct btrfs_trans_handle *trans,
> /*
> * copy everything in the in-memory inode into the btree.
> */
> -noinline int btrfs_update_inode(struct btrfs_trans_handle *trans,
> - struct btrfs_root *root,
> - struct btrfs_inode *inode)
> +int btrfs_update_inode(struct btrfs_trans_handle *trans,
> + struct btrfs_root *root,
> + struct btrfs_inode *inode)
> {
> struct btrfs_fs_info *fs_info = root->fs_info;
> int ret;
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 4/8] btrfs: remove redundant root argument from btrfs_update_inode()
2023-09-22 10:37 ` [PATCH 4/8] btrfs: remove redundant root argument from btrfs_update_inode() fdmanana
@ 2023-09-22 22:04 ` Qu Wenruo
0 siblings, 0 replies; 17+ messages in thread
From: Qu Wenruo @ 2023-09-22 22:04 UTC (permalink / raw)
To: fdmanana, linux-btrfs
On 2023/9/22 20:07, fdmanana@kernel.org wrote:
> From: Filipe Manana <fdmanana@suse.com>
>
> The root argument for btrfs_update_inode() always matches the root of the
> given inode, so remove the root argument and get it from the inode
> argument.
>
> Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Thanks,
Qu
> ---
> fs/btrfs/block-group.c | 3 +--
> fs/btrfs/btrfs_inode.h | 2 +-
> fs/btrfs/file.c | 8 ++++----
> fs/btrfs/free-space-cache.c | 13 ++++++-------
> fs/btrfs/inode.c | 34 +++++++++++++++++-----------------
> fs/btrfs/ioctl.c | 2 +-
> fs/btrfs/reflink.c | 3 +--
> fs/btrfs/tree-log.c | 12 ++++++------
> fs/btrfs/verity.c | 4 ++--
> fs/btrfs/xattr.c | 4 ++--
> 10 files changed, 41 insertions(+), 44 deletions(-)
>
> diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c
> index 2b9aaeefaf76..6e2a4000bfe0 100644
> --- a/fs/btrfs/block-group.c
> +++ b/fs/btrfs/block-group.c
> @@ -3051,7 +3051,6 @@ static int cache_save_setup(struct btrfs_block_group *block_group,
> struct btrfs_path *path)
> {
> struct btrfs_fs_info *fs_info = block_group->fs_info;
> - struct btrfs_root *root = fs_info->tree_root;
> struct inode *inode = NULL;
> struct extent_changeset *data_reserved = NULL;
> u64 alloc_hint = 0;
> @@ -3103,7 +3102,7 @@ static int cache_save_setup(struct btrfs_block_group *block_group,
> * time.
> */
> BTRFS_I(inode)->generation = 0;
> - ret = btrfs_update_inode(trans, root, BTRFS_I(inode));
> + ret = btrfs_update_inode(trans, BTRFS_I(inode));
> if (ret) {
> /*
> * So theoretically we could recover from this, simply set the
> diff --git a/fs/btrfs/btrfs_inode.h b/fs/btrfs/btrfs_inode.h
> index d12556627cce..f2c928345d53 100644
> --- a/fs/btrfs/btrfs_inode.h
> +++ b/fs/btrfs/btrfs_inode.h
> @@ -482,7 +482,7 @@ struct extent_map *btrfs_get_extent(struct btrfs_inode *inode,
> struct page *page, size_t pg_offset,
> u64 start, u64 end);
> int btrfs_update_inode(struct btrfs_trans_handle *trans,
> - struct btrfs_root *root, struct btrfs_inode *inode);
> + struct btrfs_inode *inode);
> int btrfs_update_inode_fallback(struct btrfs_trans_handle *trans,
> struct btrfs_inode *inode);
> int btrfs_orphan_add(struct btrfs_trans_handle *trans, struct btrfs_inode *inode);
> diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
> index 7d6652941210..e847043defce 100644
> --- a/fs/btrfs/file.c
> +++ b/fs/btrfs/file.c
> @@ -2460,7 +2460,7 @@ int btrfs_replace_file_extents(struct btrfs_inode *inode,
> if (!extent_info || extent_info->update_times)
> inode->vfs_inode.i_mtime = inode_set_ctime_current(&inode->vfs_inode);
>
> - ret = btrfs_update_inode(trans, root, inode);
> + ret = btrfs_update_inode(trans, inode);
> if (ret)
> break;
>
> @@ -2700,7 +2700,7 @@ static int btrfs_punch_hole(struct file *file, loff_t offset, loff_t len)
> ASSERT(trans != NULL);
> inode_inc_iversion(inode);
> inode->i_mtime = inode_set_ctime_current(inode);
> - ret = btrfs_update_inode(trans, root, BTRFS_I(inode));
> + ret = btrfs_update_inode(trans, BTRFS_I(inode));
> updated_inode = true;
> btrfs_end_transaction(trans);
> btrfs_btree_balance_dirty(fs_info);
> @@ -2726,7 +2726,7 @@ static int btrfs_punch_hole(struct file *file, loff_t offset, loff_t len)
> } else {
> int ret2;
>
> - ret = btrfs_update_inode(trans, root, BTRFS_I(inode));
> + ret = btrfs_update_inode(trans, BTRFS_I(inode));
> ret2 = btrfs_end_transaction(trans);
> if (!ret)
> ret = ret2;
> @@ -2793,7 +2793,7 @@ static int btrfs_fallocate_update_isize(struct inode *inode,
> inode_set_ctime_current(inode);
> i_size_write(inode, end);
> btrfs_inode_safe_disk_i_size_write(BTRFS_I(inode), 0);
> - ret = btrfs_update_inode(trans, root, BTRFS_I(inode));
> + ret = btrfs_update_inode(trans, BTRFS_I(inode));
> ret2 = btrfs_end_transaction(trans);
>
> return ret ? ret : ret2;
> diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
> index acb8ef3dd6b0..6f93c9a2c3e3 100644
> --- a/fs/btrfs/free-space-cache.c
> +++ b/fs/btrfs/free-space-cache.c
> @@ -359,7 +359,7 @@ int btrfs_truncate_free_space_cache(struct btrfs_trans_handle *trans,
> if (ret)
> goto fail;
>
> - ret = btrfs_update_inode(trans, root, inode);
> + ret = btrfs_update_inode(trans, inode);
>
> fail:
> if (locked)
> @@ -1326,7 +1326,7 @@ static int __btrfs_wait_cache_io(struct btrfs_root *root,
> "failed to write free space cache for block group %llu error %d",
> block_group->start, ret);
> }
> - btrfs_update_inode(trans, root, BTRFS_I(inode));
> + btrfs_update_inode(trans, BTRFS_I(inode));
>
> if (block_group) {
> /* the dirty list is protected by the dirty_bgs_lock */
> @@ -1367,7 +1367,6 @@ int btrfs_wait_cache_io(struct btrfs_trans_handle *trans,
> /*
> * Write out cached info to an inode.
> *
> - * @root: root the inode belongs to
> * @inode: freespace inode we are writing out
> * @ctl: free space cache we are going to write out
> * @block_group: block_group for this cache if it belongs to a block_group
> @@ -1378,7 +1377,7 @@ int btrfs_wait_cache_io(struct btrfs_trans_handle *trans,
> * on mount. This will return 0 if it was successful in writing the cache out,
> * or an errno if it was not.
> */
> -static int __btrfs_write_out_cache(struct btrfs_root *root, struct inode *inode,
> +static int __btrfs_write_out_cache(struct inode *inode,
> struct btrfs_free_space_ctl *ctl,
> struct btrfs_block_group *block_group,
> struct btrfs_io_ctl *io_ctl,
> @@ -1511,7 +1510,7 @@ static int __btrfs_write_out_cache(struct btrfs_root *root, struct inode *inode,
> invalidate_inode_pages2(inode->i_mapping);
> BTRFS_I(inode)->generation = 0;
> }
> - btrfs_update_inode(trans, root, BTRFS_I(inode));
> + btrfs_update_inode(trans, BTRFS_I(inode));
> if (must_iput)
> iput(inode);
> return ret;
> @@ -1537,8 +1536,8 @@ int btrfs_write_out_cache(struct btrfs_trans_handle *trans,
> if (IS_ERR(inode))
> return 0;
>
> - ret = __btrfs_write_out_cache(fs_info->tree_root, inode, ctl,
> - block_group, &block_group->io_ctl, trans);
> + ret = __btrfs_write_out_cache(inode, ctl, block_group,
> + &block_group->io_ctl, trans);
> if (ret) {
> btrfs_debug(fs_info,
> "failed to write free space cache for block group %llu error %d",
> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
> index 44836d1f99a9..13a97d3ce34a 100644
> --- a/fs/btrfs/inode.c
> +++ b/fs/btrfs/inode.c
> @@ -671,7 +671,7 @@ static noinline int cow_file_range_inline(struct btrfs_inode *inode, u64 size,
> }
>
> btrfs_update_inode_bytes(inode, size, drop_args.bytes_found);
> - ret = btrfs_update_inode(trans, root, inode);
> + ret = btrfs_update_inode(trans, inode);
> if (ret && ret != -ENOSPC) {
> btrfs_abort_transaction(trans, ret);
> goto out;
> @@ -4002,9 +4002,9 @@ static noinline int btrfs_update_inode_item(struct btrfs_trans_handle *trans,
> * copy everything in the in-memory inode into the btree.
> */
> int btrfs_update_inode(struct btrfs_trans_handle *trans,
> - struct btrfs_root *root,
> struct btrfs_inode *inode)
> {
> + struct btrfs_root *root = inode->root;
> struct btrfs_fs_info *fs_info = root->fs_info;
> int ret;
>
> @@ -4034,7 +4034,7 @@ int btrfs_update_inode_fallback(struct btrfs_trans_handle *trans,
> {
> int ret;
>
> - ret = btrfs_update_inode(trans, inode->root, inode);
> + ret = btrfs_update_inode(trans, inode);
> if (ret == -ENOSPC)
> return btrfs_update_inode_item(trans, inode->root, inode);
> return ret;
> @@ -4143,7 +4143,7 @@ static int __btrfs_unlink_inode(struct btrfs_trans_handle *trans,
> inode_inc_iversion(&dir->vfs_inode);
> inode_set_ctime_current(&inode->vfs_inode);
> dir->vfs_inode.i_mtime = inode_set_ctime_current(&dir->vfs_inode);
> - ret = btrfs_update_inode(trans, root, dir);
> + ret = btrfs_update_inode(trans, dir);
> out:
> return ret;
> }
> @@ -4157,7 +4157,7 @@ int btrfs_unlink_inode(struct btrfs_trans_handle *trans,
> ret = __btrfs_unlink_inode(trans, dir, inode, name, NULL);
> if (!ret) {
> drop_nlink(&inode->vfs_inode);
> - ret = btrfs_update_inode(trans, inode->root, inode);
> + ret = btrfs_update_inode(trans, inode);
> }
> return ret;
> }
> @@ -4843,7 +4843,7 @@ static int maybe_insert_hole(struct btrfs_root *root, struct btrfs_inode *inode,
> btrfs_abort_transaction(trans, ret);
> } else {
> btrfs_update_inode_bytes(inode, 0, drop_args.bytes_found);
> - btrfs_update_inode(trans, root, inode);
> + btrfs_update_inode(trans, inode);
> }
> btrfs_end_transaction(trans);
> return ret;
> @@ -4994,7 +4994,7 @@ static int btrfs_setsize(struct inode *inode, struct iattr *attr)
> i_size_write(inode, newsize);
> btrfs_inode_safe_disk_i_size_write(BTRFS_I(inode), 0);
> pagecache_isize_extended(inode, oldsize, newsize);
> - ret = btrfs_update_inode(trans, root, BTRFS_I(inode));
> + ret = btrfs_update_inode(trans, BTRFS_I(inode));
> btrfs_drew_write_unlock(&root->snapshot_lock);
> btrfs_end_transaction(trans);
> } else {
> @@ -6010,7 +6010,7 @@ static int btrfs_dirty_inode(struct btrfs_inode *inode)
> if (IS_ERR(trans))
> return PTR_ERR(trans);
>
> - ret = btrfs_update_inode(trans, root, inode);
> + ret = btrfs_update_inode(trans, inode);
> if (ret == -ENOSPC || ret == -EDQUOT) {
> /* whoops, lets try again with the full transaction */
> btrfs_end_transaction(trans);
> @@ -6018,7 +6018,7 @@ static int btrfs_dirty_inode(struct btrfs_inode *inode)
> if (IS_ERR(trans))
> return PTR_ERR(trans);
>
> - ret = btrfs_update_inode(trans, root, inode);
> + ret = btrfs_update_inode(trans, inode);
> }
> btrfs_end_transaction(trans);
> if (inode->delayed_node)
> @@ -6457,7 +6457,7 @@ int btrfs_add_link(struct btrfs_trans_handle *trans,
> parent_inode->vfs_inode.i_mtime =
> inode_set_ctime_current(&parent_inode->vfs_inode);
>
> - ret = btrfs_update_inode(trans, root, parent_inode);
> + ret = btrfs_update_inode(trans, parent_inode);
> if (ret)
> btrfs_abort_transaction(trans, ret);
> return ret;
> @@ -6608,7 +6608,7 @@ static int btrfs_link(struct dentry *old_dentry, struct inode *dir,
> } else {
> struct dentry *parent = dentry->d_parent;
>
> - err = btrfs_update_inode(trans, root, BTRFS_I(inode));
> + err = btrfs_update_inode(trans, BTRFS_I(inode));
> if (err)
> goto fail;
> if (inode->i_nlink == 1) {
> @@ -8349,7 +8349,7 @@ static int btrfs_truncate(struct btrfs_inode *inode, bool skip_writeback)
> if (ret != -ENOSPC && ret != -EAGAIN)
> break;
>
> - ret = btrfs_update_inode(trans, root, inode);
> + ret = btrfs_update_inode(trans, inode);
> if (ret)
> break;
>
> @@ -8402,7 +8402,7 @@ static int btrfs_truncate(struct btrfs_inode *inode, bool skip_writeback)
> int ret2;
>
> trans->block_rsv = &fs_info->trans_block_rsv;
> - ret2 = btrfs_update_inode(trans, root, inode);
> + ret2 = btrfs_update_inode(trans, inode);
> if (ret2 && !ret)
> ret = ret2;
>
> @@ -8833,7 +8833,7 @@ static int btrfs_rename_exchange(struct inode *old_dir,
> BTRFS_I(old_dentry->d_inode),
> old_name, &old_rename_ctx);
> if (!ret)
> - ret = btrfs_update_inode(trans, root, BTRFS_I(old_inode));
> + ret = btrfs_update_inode(trans, BTRFS_I(old_inode));
> }
> if (ret) {
> btrfs_abort_transaction(trans, ret);
> @@ -8848,7 +8848,7 @@ static int btrfs_rename_exchange(struct inode *old_dir,
> BTRFS_I(new_dentry->d_inode),
> new_name, &new_rename_ctx);
> if (!ret)
> - ret = btrfs_update_inode(trans, dest, BTRFS_I(new_inode));
> + ret = btrfs_update_inode(trans, BTRFS_I(new_inode));
> }
> if (ret) {
> btrfs_abort_transaction(trans, ret);
> @@ -9093,7 +9093,7 @@ static int btrfs_rename(struct mnt_idmap *idmap,
> BTRFS_I(d_inode(old_dentry)),
> &old_fname.disk_name, &rename_ctx);
> if (!ret)
> - ret = btrfs_update_inode(trans, root, BTRFS_I(old_inode));
> + ret = btrfs_update_inode(trans, BTRFS_I(old_inode));
> }
> if (ret) {
> btrfs_abort_transaction(trans, ret);
> @@ -9649,7 +9649,7 @@ static int __btrfs_prealloc_file_range(struct inode *inode, int mode,
> btrfs_inode_safe_disk_i_size_write(BTRFS_I(inode), 0);
> }
>
> - ret = btrfs_update_inode(trans, root, BTRFS_I(inode));
> + ret = btrfs_update_inode(trans, BTRFS_I(inode));
>
> if (ret) {
> btrfs_abort_transaction(trans, ret);
> diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
> index 018ea98b239a..24eae7c2b3ae 100644
> --- a/fs/btrfs/ioctl.c
> +++ b/fs/btrfs/ioctl.c
> @@ -385,7 +385,7 @@ int btrfs_fileattr_set(struct mnt_idmap *idmap,
> btrfs_sync_inode_flags_to_i_flags(inode);
> inode_inc_iversion(inode);
> inode_set_ctime_current(inode);
> - ret = btrfs_update_inode(trans, root, BTRFS_I(inode));
> + ret = btrfs_update_inode(trans, BTRFS_I(inode));
>
> out_end_trans:
> btrfs_end_transaction(trans);
> diff --git a/fs/btrfs/reflink.c b/fs/btrfs/reflink.c
> index 65d2bd6910f2..fabd856e5079 100644
> --- a/fs/btrfs/reflink.c
> +++ b/fs/btrfs/reflink.c
> @@ -25,7 +25,6 @@ static int clone_finish_inode_update(struct btrfs_trans_handle *trans,
> const u64 olen,
> int no_time_update)
> {
> - struct btrfs_root *root = BTRFS_I(inode)->root;
> int ret;
>
> inode_inc_iversion(inode);
> @@ -43,7 +42,7 @@ static int clone_finish_inode_update(struct btrfs_trans_handle *trans,
> btrfs_inode_safe_disk_i_size_write(BTRFS_I(inode), 0);
> }
>
> - ret = btrfs_update_inode(trans, root, BTRFS_I(inode));
> + ret = btrfs_update_inode(trans, BTRFS_I(inode));
> if (ret) {
> btrfs_abort_transaction(trans, ret);
> btrfs_end_transaction(trans);
> diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
> index 595982434216..a7bba3d61e55 100644
> --- a/fs/btrfs/tree-log.c
> +++ b/fs/btrfs/tree-log.c
> @@ -889,7 +889,7 @@ static noinline int replay_one_extent(struct btrfs_trans_handle *trans,
>
> update_inode:
> btrfs_update_inode_bytes(BTRFS_I(inode), nbytes, drop_args.bytes_found);
> - ret = btrfs_update_inode(trans, root, BTRFS_I(inode));
> + ret = btrfs_update_inode(trans, BTRFS_I(inode));
> out:
> iput(inode);
> return ret;
> @@ -1444,7 +1444,7 @@ static noinline int add_inode_ref(struct btrfs_trans_handle *trans,
> if (ret)
> goto out;
>
> - ret = btrfs_update_inode(trans, root, BTRFS_I(inode));
> + ret = btrfs_update_inode(trans, BTRFS_I(inode));
> if (ret)
> goto out;
> }
> @@ -1622,7 +1622,7 @@ static noinline int fixup_inode_link_count(struct btrfs_trans_handle *trans,
>
> if (nlink != inode->i_nlink) {
> set_nlink(inode, nlink);
> - ret = btrfs_update_inode(trans, root, BTRFS_I(inode));
> + ret = btrfs_update_inode(trans, BTRFS_I(inode));
> if (ret)
> goto out;
> }
> @@ -1731,7 +1731,7 @@ static noinline int link_to_fixup_dir(struct btrfs_trans_handle *trans,
> set_nlink(inode, 1);
> else
> inc_nlink(inode);
> - ret = btrfs_update_inode(trans, root, BTRFS_I(inode));
> + ret = btrfs_update_inode(trans, BTRFS_I(inode));
> } else if (ret == -EEXIST) {
> ret = 0;
> }
> @@ -1938,7 +1938,7 @@ static noinline int replay_one_name(struct btrfs_trans_handle *trans,
> out:
> if (!ret && update_size) {
> btrfs_i_size_write(BTRFS_I(dir), dir->i_size + name.len * 2);
> - ret = btrfs_update_inode(trans, root, BTRFS_I(dir));
> + ret = btrfs_update_inode(trans, BTRFS_I(dir));
> }
> kfree(name.name);
> iput(dir);
> @@ -2482,7 +2482,7 @@ static int replay_one_buffer(struct btrfs_root *log, struct extent_buffer *eb,
> drop_args.bytes_found);
> /* Update the inode's nbytes. */
> ret = btrfs_update_inode(wc->trans,
> - root, BTRFS_I(inode));
> + BTRFS_I(inode));
> }
> iput(inode);
> if (ret)
> diff --git a/fs/btrfs/verity.c b/fs/btrfs/verity.c
> index 744f4f4d4c68..66e2270b0dae 100644
> --- a/fs/btrfs/verity.c
> +++ b/fs/btrfs/verity.c
> @@ -487,7 +487,7 @@ static int rollback_verity(struct btrfs_inode *inode)
> }
> inode->ro_flags &= ~BTRFS_INODE_RO_VERITY;
> btrfs_sync_inode_flags_to_i_flags(&inode->vfs_inode);
> - ret = btrfs_update_inode(trans, root, inode);
> + ret = btrfs_update_inode(trans, inode);
> if (ret) {
> btrfs_abort_transaction(trans, ret);
> goto out;
> @@ -554,7 +554,7 @@ static int finish_verity(struct btrfs_inode *inode, const void *desc,
> }
> inode->ro_flags |= BTRFS_INODE_RO_VERITY;
> btrfs_sync_inode_flags_to_i_flags(&inode->vfs_inode);
> - ret = btrfs_update_inode(trans, root, inode);
> + ret = btrfs_update_inode(trans, inode);
> if (ret)
> goto end_trans;
> ret = del_orphan(trans, inode);
> diff --git a/fs/btrfs/xattr.c b/fs/btrfs/xattr.c
> index b906f809650e..76ff93b3eb27 100644
> --- a/fs/btrfs/xattr.c
> +++ b/fs/btrfs/xattr.c
> @@ -265,7 +265,7 @@ int btrfs_setxattr_trans(struct inode *inode, const char *name,
>
> inode_inc_iversion(inode);
> inode_set_ctime_current(inode);
> - ret = btrfs_update_inode(trans, root, BTRFS_I(inode));
> + ret = btrfs_update_inode(trans, BTRFS_I(inode));
> if (ret)
> btrfs_abort_transaction(trans, ret);
> out:
> @@ -408,7 +408,7 @@ static int btrfs_xattr_handler_set_prop(const struct xattr_handler *handler,
> if (!ret) {
> inode_inc_iversion(inode);
> inode_set_ctime_current(inode);
> - ret = btrfs_update_inode(trans, root, BTRFS_I(inode));
> + ret = btrfs_update_inode(trans, BTRFS_I(inode));
> if (ret)
> btrfs_abort_transaction(trans, ret);
> }
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 5/8] btrfs: remove redundant root argument from btrfs_update_inode_item()
2023-09-22 10:37 ` [PATCH 5/8] btrfs: remove redundant root argument from btrfs_update_inode_item() fdmanana
@ 2023-09-22 22:06 ` Qu Wenruo
0 siblings, 0 replies; 17+ messages in thread
From: Qu Wenruo @ 2023-09-22 22:06 UTC (permalink / raw)
To: fdmanana, linux-btrfs
On 2023/9/22 20:07, fdmanana@kernel.org wrote:
> From: Filipe Manana <fdmanana@suse.com>
>
> The root argument for btrfs_update_inode_item() always matches the root of
> the given inode, so remove the root argument and get it from the inode
> argument.
>
> Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Thanks,
Qu
> ---
> fs/btrfs/inode.c | 9 ++++-----
> 1 file changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
> index 13a97d3ce34a..c4b5d4047c5d 100644
> --- a/fs/btrfs/inode.c
> +++ b/fs/btrfs/inode.c
> @@ -3966,8 +3966,7 @@ static void fill_inode_item(struct btrfs_trans_handle *trans,
> * copy everything in the in-memory inode into the btree.
> */
> static noinline int btrfs_update_inode_item(struct btrfs_trans_handle *trans,
> - struct btrfs_root *root,
> - struct btrfs_inode *inode)
> + struct btrfs_inode *inode)
> {
> struct btrfs_inode_item *inode_item;
> struct btrfs_path *path;
> @@ -3978,7 +3977,7 @@ static noinline int btrfs_update_inode_item(struct btrfs_trans_handle *trans,
> if (!path)
> return -ENOMEM;
>
> - ret = btrfs_lookup_inode(trans, root, path, &inode->location, 1);
> + ret = btrfs_lookup_inode(trans, inode->root, path, &inode->location, 1);
> if (ret) {
> if (ret > 0)
> ret = -ENOENT;
> @@ -4026,7 +4025,7 @@ int btrfs_update_inode(struct btrfs_trans_handle *trans,
> return ret;
> }
>
> - return btrfs_update_inode_item(trans, root, inode);
> + return btrfs_update_inode_item(trans, inode);
> }
>
> int btrfs_update_inode_fallback(struct btrfs_trans_handle *trans,
> @@ -4036,7 +4035,7 @@ int btrfs_update_inode_fallback(struct btrfs_trans_handle *trans,
>
> ret = btrfs_update_inode(trans, inode);
> if (ret == -ENOSPC)
> - return btrfs_update_inode_item(trans, inode->root, inode);
> + return btrfs_update_inode_item(trans, inode);
> return ret;
> }
>
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 6/8] btrfs: remove redundant root argument from btrfs_delayed_update_inode()
2023-09-22 10:37 ` [PATCH 6/8] btrfs: remove redundant root argument from btrfs_delayed_update_inode() fdmanana
@ 2023-09-22 22:08 ` Qu Wenruo
0 siblings, 0 replies; 17+ messages in thread
From: Qu Wenruo @ 2023-09-22 22:08 UTC (permalink / raw)
To: fdmanana, linux-btrfs
On 2023/9/22 20:07, fdmanana@kernel.org wrote:
> From: Filipe Manana <fdmanana@suse.com>
>
> The root argument for btrfs_delayed_update_inode() always matches the root
> of the given inode, so remove the root argument and get it from the inode
> argument.
>
> Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Thanks,
Qu
> ---
> fs/btrfs/delayed-inode.c | 2 +-
> fs/btrfs/delayed-inode.h | 1 -
> fs/btrfs/inode.c | 2 +-
> 3 files changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
> index 8ba045ae1d75..35d7616615c1 100644
> --- a/fs/btrfs/delayed-inode.c
> +++ b/fs/btrfs/delayed-inode.c
> @@ -1913,9 +1913,9 @@ int btrfs_fill_inode(struct inode *inode, u32 *rdev)
> }
>
> int btrfs_delayed_update_inode(struct btrfs_trans_handle *trans,
> - struct btrfs_root *root,
> struct btrfs_inode *inode)
> {
> + struct btrfs_root *root = inode->root;
> struct btrfs_delayed_node *delayed_node;
> int ret = 0;
>
> diff --git a/fs/btrfs/delayed-inode.h b/fs/btrfs/delayed-inode.h
> index dc1085b2a397..d050e572c7f9 100644
> --- a/fs/btrfs/delayed-inode.h
> +++ b/fs/btrfs/delayed-inode.h
> @@ -135,7 +135,6 @@ int btrfs_commit_inode_delayed_inode(struct btrfs_inode *inode);
>
>
> int btrfs_delayed_update_inode(struct btrfs_trans_handle *trans,
> - struct btrfs_root *root,
> struct btrfs_inode *inode);
> int btrfs_fill_inode(struct inode *inode, u32 *rdev);
> int btrfs_delayed_delete_inode_ref(struct btrfs_inode *inode);
> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
> index c4b5d4047c5d..54647b7fb600 100644
> --- a/fs/btrfs/inode.c
> +++ b/fs/btrfs/inode.c
> @@ -4019,7 +4019,7 @@ int btrfs_update_inode(struct btrfs_trans_handle *trans,
> && !test_bit(BTRFS_FS_LOG_RECOVERING, &fs_info->flags)) {
> btrfs_update_root_times(trans, root);
>
> - ret = btrfs_delayed_update_inode(trans, root, inode);
> + ret = btrfs_delayed_update_inode(trans, inode);
> if (!ret)
> btrfs_set_inode_last_trans(trans, inode);
> return ret;
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 7/8] btrfs: remove redundant root argument from maybe_insert_hole()
2023-09-22 10:37 ` [PATCH 7/8] btrfs: remove redundant root argument from maybe_insert_hole() fdmanana
@ 2023-09-22 22:09 ` Qu Wenruo
0 siblings, 0 replies; 17+ messages in thread
From: Qu Wenruo @ 2023-09-22 22:09 UTC (permalink / raw)
To: fdmanana, linux-btrfs
On 2023/9/22 20:07, fdmanana@kernel.org wrote:
> From: Filipe Manana <fdmanana@suse.com>
>
> The root argument for maybe_insert_hole() always matches the root of the
> given inode, so remove the root argument and get it from the inode
> argument.
>
> Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Thanks,
Qu
> ---
> fs/btrfs/inode.c | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
> index 54647b7fb600..52576deda654 100644
> --- a/fs/btrfs/inode.c
> +++ b/fs/btrfs/inode.c
> @@ -4800,9 +4800,9 @@ int btrfs_truncate_block(struct btrfs_inode *inode, loff_t from, loff_t len,
> return ret;
> }
>
> -static int maybe_insert_hole(struct btrfs_root *root, struct btrfs_inode *inode,
> - u64 offset, u64 len)
> +static int maybe_insert_hole(struct btrfs_inode *inode, u64 offset, u64 len)
> {
> + struct btrfs_root *root = inode->root;
> struct btrfs_fs_info *fs_info = root->fs_info;
> struct btrfs_trans_handle *trans;
> struct btrfs_drop_extents_args drop_args = { 0 };
> @@ -4898,8 +4898,7 @@ int btrfs_cont_expand(struct btrfs_inode *inode, loff_t oldsize, loff_t size)
> if (!test_bit(EXTENT_FLAG_PREALLOC, &em->flags)) {
> struct extent_map *hole_em;
>
> - err = maybe_insert_hole(root, inode, cur_offset,
> - hole_size);
> + err = maybe_insert_hole(inode, cur_offset, hole_size);
> if (err)
> break;
>
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 8/8] btrfs: remove redundant root argument from fixup_inode_link_count()
2023-09-22 10:37 ` [PATCH 8/8] btrfs: remove redundant root argument from fixup_inode_link_count() fdmanana
@ 2023-09-22 22:11 ` Qu Wenruo
0 siblings, 0 replies; 17+ messages in thread
From: Qu Wenruo @ 2023-09-22 22:11 UTC (permalink / raw)
To: fdmanana, linux-btrfs
On 2023/9/22 20:07, fdmanana@kernel.org wrote:
> From: Filipe Manana <fdmanana@suse.com>
>
> The root argument for fixup_inode_link_count() always matches the root of
> the given inode, so remove the root argument and get it from the inode
> argument. This also applies to the helpers count_inode_extrefs() and
> count_inode_refs() used by fixup_inode_link_count() - they don't need the
> root argument, as it always matches the root of the inode passed to them.
>
> Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Thanks,
Qu
> ---
> fs/btrfs/tree-log.c | 20 +++++++++-----------
> 1 file changed, 9 insertions(+), 11 deletions(-)
>
> diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
> index a7bba3d61e55..f4257be56bd3 100644
> --- a/fs/btrfs/tree-log.c
> +++ b/fs/btrfs/tree-log.c
> @@ -1482,8 +1482,7 @@ static noinline int add_inode_ref(struct btrfs_trans_handle *trans,
> return ret;
> }
>
> -static int count_inode_extrefs(struct btrfs_root *root,
> - struct btrfs_inode *inode, struct btrfs_path *path)
> +static int count_inode_extrefs(struct btrfs_inode *inode, struct btrfs_path *path)
> {
> int ret = 0;
> int name_len;
> @@ -1497,8 +1496,8 @@ static int count_inode_extrefs(struct btrfs_root *root,
> struct extent_buffer *leaf;
>
> while (1) {
> - ret = btrfs_find_one_extref(root, inode_objectid, offset, path,
> - &extref, &offset);
> + ret = btrfs_find_one_extref(inode->root, inode_objectid, offset,
> + path, &extref, &offset);
> if (ret)
> break;
>
> @@ -1526,8 +1525,7 @@ static int count_inode_extrefs(struct btrfs_root *root,
> return nlink;
> }
>
> -static int count_inode_refs(struct btrfs_root *root,
> - struct btrfs_inode *inode, struct btrfs_path *path)
> +static int count_inode_refs(struct btrfs_inode *inode, struct btrfs_path *path)
> {
> int ret;
> struct btrfs_key key;
> @@ -1542,7 +1540,7 @@ static int count_inode_refs(struct btrfs_root *root,
> key.offset = (u64)-1;
>
> while (1) {
> - ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
> + ret = btrfs_search_slot(NULL, inode->root, &key, path, 0, 0);
> if (ret < 0)
> break;
> if (ret > 0) {
> @@ -1594,9 +1592,9 @@ static int count_inode_refs(struct btrfs_root *root,
> * will free the inode.
> */
> static noinline int fixup_inode_link_count(struct btrfs_trans_handle *trans,
> - struct btrfs_root *root,
> struct inode *inode)
> {
> + struct btrfs_root *root = BTRFS_I(inode)->root;
> struct btrfs_path *path;
> int ret;
> u64 nlink = 0;
> @@ -1606,13 +1604,13 @@ static noinline int fixup_inode_link_count(struct btrfs_trans_handle *trans,
> if (!path)
> return -ENOMEM;
>
> - ret = count_inode_refs(root, BTRFS_I(inode), path);
> + ret = count_inode_refs(BTRFS_I(inode), path);
> if (ret < 0)
> goto out;
>
> nlink = ret;
>
> - ret = count_inode_extrefs(root, BTRFS_I(inode), path);
> + ret = count_inode_extrefs(BTRFS_I(inode), path);
> if (ret < 0)
> goto out;
>
> @@ -1684,7 +1682,7 @@ static noinline int fixup_inode_link_counts(struct btrfs_trans_handle *trans,
> break;
> }
>
> - ret = fixup_inode_link_count(trans, root, inode);
> + ret = fixup_inode_link_count(trans, inode);
> iput(inode);
> if (ret)
> break;
^ permalink raw reply [flat|nested] 17+ messages in thread
end of thread, other threads:[~2023-09-22 22:11 UTC | newest]
Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-22 10:37 [PATCH 0/8] btrfs: some cleanups around inode update and helpers fdmanana
2023-09-22 10:37 ` [PATCH 1/8] btrfs: simplify error check condition at btrfs_dirty_inode() fdmanana
2023-09-22 22:00 ` Qu Wenruo
2023-09-22 10:37 ` [PATCH 2/8] btrfs: remove noline from btrfs_update_inode() fdmanana
2023-09-22 22:00 ` Qu Wenruo
2023-09-22 10:37 ` [PATCH 3/8] btrfs: remove redundant root argument from btrfs_update_inode_fallback() fdmanana
2023-09-22 10:37 ` [PATCH 4/8] btrfs: remove redundant root argument from btrfs_update_inode() fdmanana
2023-09-22 22:04 ` Qu Wenruo
2023-09-22 10:37 ` [PATCH 5/8] btrfs: remove redundant root argument from btrfs_update_inode_item() fdmanana
2023-09-22 22:06 ` Qu Wenruo
2023-09-22 10:37 ` [PATCH 6/8] btrfs: remove redundant root argument from btrfs_delayed_update_inode() fdmanana
2023-09-22 22:08 ` Qu Wenruo
2023-09-22 10:37 ` [PATCH 7/8] btrfs: remove redundant root argument from maybe_insert_hole() fdmanana
2023-09-22 22:09 ` Qu Wenruo
2023-09-22 10:37 ` [PATCH 8/8] btrfs: remove redundant root argument from fixup_inode_link_count() fdmanana
2023-09-22 22:11 ` Qu Wenruo
2023-09-22 13:48 ` [PATCH 0/8] btrfs: some cleanups around inode update and helpers David Sterba
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.