Skip to contentSkip to conversation

btrfs: cleanups for a couple log tree functions

PATCH In review [email protected] 4 participants 6 messages Nov 19, 2025 – Nov 20, 2025 Btrfs file system

lore
Share & tools
lore
#0 lore raw

cover btrfs: cleanups for a couple log tree functions

From: Filipe Manana <[email protected]>

A couple of trivial cleanups for the argument list of two log tree functions.

Filipe Manana (2):
btrfs: remove root argument from btrfs_del_dir_entries_in_log()
btrfs: reduce arguments to btrfs_del_inode_ref_in_log()

 fs/btrfs/inode.c    |  4 ++--
 fs/btrfs/tree-log.c | 12 ++++++------
 fs/btrfs/tree-log.h |  5 ++---
 3 files changed, 10 insertions(+), 11 deletions(-)
Signature · 1 line
2.47.2
#1 lore raw

PATCH 1/2 btrfs: remove root argument from btrfs_del_dir_entries_in_log()

From: Filipe Manana <[email protected]>

There's no need to pass the root as we can extract it from the directory inode, so remove it.

---
 fs/btrfs/inode.c    | 2 +-
 fs/btrfs/tree-log.c | 2 +-
 fs/btrfs/tree-log.h | 1 -
 3 files changed, 2 insertions(+), 3 deletions(-)
fs/btrfs/inode.c +1 -1
index f71a5f7f55b9..16d416fe536b 100644
@@ -4359,7 +4359,7 @@ static int __btrfs_unlink_inode(struct btrfs_trans_handle *trans,
 	 */
 	if (!rename_ctx) {
 		btrfs_del_inode_ref_in_log(trans, root, name, inode, dir_ino);
-		btrfs_del_dir_entries_in_log(trans, root, name, dir, index);
+		btrfs_del_dir_entries_in_log(trans, name, dir, index);
 	}
 
 	/*
fs/btrfs/tree-log.c +1 -1
index cc27f87c4904..c2e45e64ab6c 100644
@@ -3900,10 +3900,10 @@ static int del_logged_dentry(struct btrfs_trans_handle *trans,
  * or the entire directory.
  */
 void btrfs_del_dir_entries_in_log(struct btrfs_trans_handle *trans,
-				  struct btrfs_root *root,
 				  const struct fscrypt_str *name,
 				  struct btrfs_inode *dir, u64 index)
 {
+	struct btrfs_root *root = dir->root;
 	BTRFS_PATH_AUTO_FREE(path);
 	int ret;
 
fs/btrfs/tree-log.h +0 -1
index 4f149d7d4fde..a0aeec2448c0 100644
@@ -79,7 +79,6 @@ int btrfs_log_dentry_safe(struct btrfs_trans_handle *trans,
 			  struct dentry *dentry,
 			  struct btrfs_log_ctx *ctx);
 void btrfs_del_dir_entries_in_log(struct btrfs_trans_handle *trans,
-				  struct btrfs_root *root,
 				  const struct fscrypt_str *name,
 				  struct btrfs_inode *dir, u64 index);
 void btrfs_del_inode_ref_in_log(struct btrfs_trans_handle *trans,
Signature · 1 line
2.47.2
#2 lore raw

PATCH 2/2 btrfs: reduce arguments to btrfs_del_inode_ref_in_log()

In reply to [email protected]

From: Filipe Manana <[email protected]>

Instead of passing a root and the objectid of the parent directory, just pass the directory inode, as like that we can extract both the root and the objectid, reducing the number of arguments by one. It also makes the function more consistent with other log tree functions in the sense that we pass the inode and not only its objectid.

---
 fs/btrfs/inode.c    |  2 +-
 fs/btrfs/tree-log.c | 10 +++++-----
 fs/btrfs/tree-log.h |  4 ++--
 3 files changed, 8 insertions(+), 8 deletions(-)
fs/btrfs/inode.c +1 -1
index 16d416fe536b..8ace17f3eb42 100644
@@ -4358,7 +4358,7 @@ static int __btrfs_unlink_inode(struct btrfs_trans_handle *trans,
 	 * operations on the log tree, increasing latency for applications.
 	 */
 	if (!rename_ctx) {
-		btrfs_del_inode_ref_in_log(trans, root, name, inode, dir_ino);
+		btrfs_del_inode_ref_in_log(trans, name, inode, dir);
 		btrfs_del_dir_entries_in_log(trans, name, dir, index);
 	}
 
fs/btrfs/tree-log.c +5 -5
index c2e45e64ab6c..42c9327e0c12 100644
@@ -3938,11 +3938,11 @@ void btrfs_del_dir_entries_in_log(struct btrfs_trans_handle *trans,
 
 /* see comments for btrfs_del_dir_entries_in_log */
 void btrfs_del_inode_ref_in_log(struct btrfs_trans_handle *trans,
-				struct btrfs_root *root,
 				const struct fscrypt_str *name,
-				struct btrfs_inode *inode, u64 dirid)
+				struct btrfs_inode *inode,
+				struct btrfs_inode *dir)
 {
-	struct btrfs_root *log;
+	struct btrfs_root *root = dir->root;
 	int ret;
 
 	ret = inode_logged(trans, inode, NULL);
@@ -3957,10 +3957,10 @@ void btrfs_del_inode_ref_in_log(struct btrfs_trans_handle *trans,
 	ASSERT(ret == 0, "join_running_log_trans() ret=%d", ret);
 	if (WARN_ON(ret))
 		return;
-	log = root->log_root;
 	mutex_lock(&inode->log_mutex);
 
-	ret = btrfs_del_inode_ref(trans, log, name, btrfs_ino(inode), dirid, NULL);
+	ret = btrfs_del_inode_ref(trans, root->log_root, name, btrfs_ino(inode),
+				  btrfs_ino(dir), NULL);
 	mutex_unlock(&inode->log_mutex);
 	if (ret < 0 && ret != -ENOENT)
 		btrfs_set_log_full_commit(trans);
fs/btrfs/tree-log.h +2 -2
index a0aeec2448c0..41e47fda036d 100644
@@ -82,9 +82,9 @@ void btrfs_del_dir_entries_in_log(struct btrfs_trans_handle *trans,
 				  const struct fscrypt_str *name,
 				  struct btrfs_inode *dir, u64 index);
 void btrfs_del_inode_ref_in_log(struct btrfs_trans_handle *trans,
-				struct btrfs_root *root,
 				const struct fscrypt_str *name,
-				struct btrfs_inode *inode, u64 dirid);
+				struct btrfs_inode *inode,
+				struct btrfs_inode *dir);
 void btrfs_end_log_trans(struct btrfs_root *root);
 void btrfs_pin_log_trans(struct btrfs_root *root);
 void btrfs_record_unlink_dir(struct btrfs_trans_handle *trans,
Signature · 1 line
2.47.2
Reviewed-by on the v1 series
#3 lore raw
In reply to [email protected]
Quoted 4 lines · 在 2025/11/19 23:49, [email protected] 写道:

From: Filipe Manana <[email protected]>

A couple of trivial cleanups for the argument list of two log tree functions.

Thanks,
Qu

Quoted 10 lines

Filipe Manana (2):
btrfs: remove root argument from btrfs_del_dir_entries_in_log()
btrfs: reduce arguments to btrfs_del_inode_ref_in_log()

  fs/btrfs/inode.c    |  4 ++--
  fs/btrfs/tree-log.c | 12 ++++++------
  fs/btrfs/tree-log.h |  5 ++---
  3 files changed, 10 insertions(+), 11 deletions(-)