Skip to contentSkip to conversation

btrfs: send: a couple trivial cleanups

PATCH In review [email protected] 3 participants 5 messages Mar 6, 2025 Btrfs file system

lore
Share & tools
lore
#0 lore raw

cover btrfs: send: a couple trivial cleanups

From: Filipe Manana <[email protected]>

Simple cleanups, reduce code, details in the change logs.

Filipe Manana (2):
btrfs: send: remove unnecessary inode lookup at send_encoded_inline_extent()
btrfs: send: simplify return logic from send_encoded_extent()

 fs/btrfs/send.c | 19 +++++--------------
 1 file changed, 5 insertions(+), 14 deletions(-)
Signature · 1 line
2.45.2
#1 lore raw

PATCH 1/2 btrfs: send: remove unnecessary inode lookup at send_encoded_inline_extent()

From: Filipe Manana <[email protected]>

We doing a lookup of the inode but we don't use it at all. So just remove this pointless lookup.

---
 fs/btrfs/send.c | 6 ------
 1 file changed, 6 deletions(-)
fs/btrfs/send.c +0 -6
index e225530d3ebb..41e913e01d49 100644
@@ -5523,7 +5523,6 @@ static int send_encoded_inline_extent(struct send_ctx *sctx,
 {
 	struct btrfs_root *root = sctx->send_root;
 	struct btrfs_fs_info *fs_info = root->fs_info;
-	struct inode *inode;
 	struct fs_path *fspath;
 	struct extent_buffer *leaf = path->nodes[0];
 	struct btrfs_key key;
@@ -5532,10 +5531,6 @@ static int send_encoded_inline_extent(struct send_ctx *sctx,
 	size_t inline_size;
 	int ret;
 
-	inode = btrfs_iget(sctx->cur_ino, root);
-	if (IS_ERR(inode))
-		return PTR_ERR(inode);
-
 	fspath = get_cur_inode_path(sctx);
 	if (IS_ERR(fspath)) {
 		ret = PTR_ERR(fspath);
@@ -5574,7 +5569,6 @@ static int send_encoded_inline_extent(struct send_ctx *sctx,
 
 tlv_put_failure:
 out:
-	iput(inode);
 	return ret;
 }
 
Signature · 1 line
2.45.2
#2 lore raw

PATCH 2/2 btrfs: send: simplify return logic from send_encoded_extent()

In reply to [email protected]

From: Filipe Manana <[email protected]>

The 'out' label is pointless as we don't have anything to cleanup anymore (we used to have an inode to iput), so remove it and make error paths directly return an error.

---
 fs/btrfs/send.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)
fs/btrfs/send.c +5 -8
index 41e913e01d49..31f9122eaac9 100644
@@ -5532,14 +5532,12 @@ static int send_encoded_inline_extent(struct send_ctx *sctx,
 	int ret;
 
 	fspath = get_cur_inode_path(sctx);
-	if (IS_ERR(fspath)) {
-		ret = PTR_ERR(fspath);
-		goto out;
-	}
+	if (IS_ERR(fspath))
+		return PTR_ERR(fspath);
 
 	ret = begin_cmd(sctx, BTRFS_SEND_C_ENCODED_WRITE);
 	if (ret < 0)
-		goto out;
+		return ret;
 
 	btrfs_item_key_to_cpu(leaf, &key, path->slots[0]);
 	ei = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_file_extent_item);
@@ -5555,12 +5553,12 @@ static int send_encoded_inline_extent(struct send_ctx *sctx,
 	ret = btrfs_encoded_io_compression_from_extent(fs_info,
 				btrfs_file_extent_compression(leaf, ei));
 	if (ret < 0)
-		goto out;
+		return ret;
 	TLV_PUT_U32(sctx, BTRFS_SEND_A_COMPRESSION, ret);
 
 	ret = put_data_header(sctx, inline_size);
 	if (ret < 0)
-		goto out;
+		return ret;
 	read_extent_buffer(leaf, sctx->send_buf + sctx->send_size,
 			   btrfs_file_extent_inline_start(ei), inline_size);
 	sctx->send_size += inline_size;
@@ -5568,7 +5566,6 @@ static int send_encoded_inline_extent(struct send_ctx *sctx,
 	ret = send_cmd(sctx);
 
 tlv_put_failure:
-out:
 	return ret;
 }
 
Signature · 1 line
2.45.2
Reviewed-by on the v1 series
#4 lore raw
In reply to [email protected]
Quoted 3 lines · 在 2025/3/7 04:25, [email protected] 写道:

From: Filipe Manana <[email protected]>

Simple cleanups, reduce code, details in the change logs.

Thanks,
Qu

Quoted 8 lines

Filipe Manana (2):
btrfs: send: remove unnecessary inode lookup at send_encoded_inline_extent()
btrfs: send: simplify return logic from send_encoded_extent()

  fs/btrfs/send.c | 19 +++++--------------
  1 file changed, 5 insertions(+), 14 deletions(-)