aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/fs/btrfs/send.c
diff options
context:
space:
mode:
authorFilipe Manana <fdmanana@suse.com>2025-02-12 11:49:47 +0000
committerDavid Sterba <dsterba@suse.com>2025-03-18 20:35:45 +0100
commitec666c84deba56f714505b53556a97565f72db86 (patch)
tree5e5dd2cfd22f935ddf2bf7c8a8d3a022ab094c06 /fs/btrfs/send.c
parentbtrfs: send: only use boolean variables at process_recorded_refs() (diff)
downloadwireguard-linux-ec666c84deba56f714505b53556a97565f72db86.tar.xz
wireguard-linux-ec666c84deba56f714505b53556a97565f72db86.zip
btrfs: send: add and use helper to rename current inode when processing refs
Extract the logic to rename the current inode at process_recorded_refs() into a helper function and use it, therefore removing duplicated logic and making it easier for an upcoming patch by avoiding yet more duplicated logic. Signed-off-by: Filipe Manana <fdmanana@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/send.c')
-rw-r--r--fs/btrfs/send.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
index 6e27a7d77b25..653e0b9a94ca 100644
--- a/fs/btrfs/send.c
+++ b/fs/btrfs/send.c
@@ -4133,6 +4133,19 @@ out:
return ret;
}
+static int rename_current_inode(struct send_ctx *sctx,
+ struct fs_path *current_path,
+ struct fs_path *new_path)
+{
+ int ret;
+
+ ret = send_rename(sctx, current_path, new_path);
+ if (ret < 0)
+ return ret;
+
+ return fs_path_copy(current_path, new_path);
+}
+
/*
* This does all the move/link/unlink/rmdir magic.
*/
@@ -4418,13 +4431,10 @@ static int process_recorded_refs(struct send_ctx *sctx, int *pending_move)
* it depending on the inode mode.
*/
if (is_orphan && can_rename) {
- ret = send_rename(sctx, valid_path, cur->full_path);
+ ret = rename_current_inode(sctx, valid_path, cur->full_path);
if (ret < 0)
goto out;
is_orphan = false;
- ret = fs_path_copy(valid_path, cur->full_path);
- if (ret < 0)
- goto out;
} else if (can_rename) {
if (S_ISDIR(sctx->cur_inode_mode)) {
/*
@@ -4432,10 +4442,7 @@ static int process_recorded_refs(struct send_ctx *sctx, int *pending_move)
* dirs, we always have one new and one deleted
* ref. The deleted ref is ignored later.
*/
- ret = send_rename(sctx, valid_path,
- cur->full_path);
- if (!ret)
- ret = fs_path_copy(valid_path,
+ ret = rename_current_inode(sctx, valid_path,
cur->full_path);
if (ret < 0)
goto out;