All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] btrfs: fix a bug with the squotas code and cleanup.
@ 2026-10-05 12:13 fdmanana
  2026-10-05 12:13 ` [PATCH 1/2] btrfs: fix lost error return value in btrfs_alloc_logged_file_extent() fdmanana
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: fdmanana @ 2026-10-05 12:13 UTC (permalink / raw)
  To: linux-btrfs

From: Filipe Manana <fdmanana@suse.com>

Fix a bug during log replay (regardless if quotas are enabled or not) and
a cleanup.

Filipe Manana (2):
  btrfs: fix lost error return value in btrfs_alloc_logged_file_extent()
  btrfs: qgroup: make btrfs_record_squota_delta() return void

 fs/btrfs/extent-tree.c | 11 ++++-------
 fs/btrfs/qgroup.c      | 14 +++++---------
 fs/btrfs/qgroup.h      |  4 ++--
 3 files changed, 11 insertions(+), 18 deletions(-)

-- 
2.47.2


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] btrfs: fix lost error return value in btrfs_alloc_logged_file_extent()
  2026-10-05 12:13 [PATCH 0/2] btrfs: fix a bug with the squotas code and cleanup fdmanana
@ 2026-10-05 12:13 ` fdmanana
  2026-10-05 12:13 ` [PATCH 2/2] btrfs: qgroup: make btrfs_record_squota_delta() return void fdmanana
  2026-10-05 22:13 ` [PATCH 0/2] btrfs: fix a bug with the squotas code and cleanup Qu Wenruo
  2 siblings, 0 replies; 4+ messages in thread
From: fdmanana @ 2026-10-05 12:13 UTC (permalink / raw)
  To: linux-btrfs

From: Filipe Manana <fdmanana@suse.com>

If we fail to allocate a reserved file extent we then call
btrfs_record_squota_delta() and assign its return value to 'ret',
discarding the error from the failed allocation attempt and allowing
log replay to proceed as if no errors happened, resulting in some
replayed file extent item to point to an unallocated extent. At the
moment btrfs_record_squota_delta() always returns 0 (success).

Fixes: cecbb533b5fc ("btrfs: record simple quota deltas in delayed refs")
Signed-off-by: Filipe Manana <fdmanana@suse.com>
---
 fs/btrfs/extent-tree.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index a0d5ab03aae2..15b4ed56ce71 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -5227,7 +5227,8 @@ int btrfs_alloc_logged_file_extent(struct btrfs_trans_handle *trans,
 					 offset, ins, 1, root_objectid);
 	if (ret)
 		btrfs_pin_extent(trans, ins->objectid, ins->offset);
-	ret = btrfs_record_squota_delta(fs_info, &delta);
+	else
+		ret = btrfs_record_squota_delta(fs_info, &delta);
 	btrfs_put_block_group(block_group);
 	return ret;
 }
-- 
2.47.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] btrfs: qgroup: make btrfs_record_squota_delta() return void
  2026-10-05 12:13 [PATCH 0/2] btrfs: fix a bug with the squotas code and cleanup fdmanana
  2026-10-05 12:13 ` [PATCH 1/2] btrfs: fix lost error return value in btrfs_alloc_logged_file_extent() fdmanana
@ 2026-10-05 12:13 ` fdmanana
  2026-10-05 22:13 ` [PATCH 0/2] btrfs: fix a bug with the squotas code and cleanup Qu Wenruo
  2 siblings, 0 replies; 4+ messages in thread
From: fdmanana @ 2026-10-05 12:13 UTC (permalink / raw)
  To: linux-btrfs

From: Filipe Manana <fdmanana@suse.com>

The function never returns any error, so simplify it and its callers by
making it return void.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
---
 fs/btrfs/extent-tree.c | 10 +++-------
 fs/btrfs/qgroup.c      | 14 +++++---------
 fs/btrfs/qgroup.h      |  4 ++--
 3 files changed, 10 insertions(+), 18 deletions(-)

diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 15b4ed56ce71..9b0a5c6b96f3 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -1658,7 +1658,7 @@ static int run_delayed_data_ref(struct btrfs_trans_handle *trans,
 						 href->owning_root);
 		free_head_ref_squota_rsv(trans->fs_info, href);
 		if (!ret)
-			ret = btrfs_record_squota_delta(trans->fs_info, &delta);
+			btrfs_record_squota_delta(trans->fs_info, &delta);
 	} else if (node->action == BTRFS_ADD_DELAYED_REF) {
 		ret = __btrfs_inc_extent_ref(trans, node, extent_op);
 	} else if (node->action == BTRFS_DROP_DELAYED_REF) {
@@ -3180,11 +3180,7 @@ static int do_free_extent_accounting(struct btrfs_trans_handle *trans,
 		}
 	}
 
-	ret = btrfs_record_squota_delta(trans->fs_info, delta);
-	if (unlikely(ret)) {
-		btrfs_abort_transaction(trans, ret);
-		return ret;
-	}
+	btrfs_record_squota_delta(trans->fs_info, delta);
 
 	/* If remapped, FST has already been taken care of in remove_range_from_remap_tree(). */
 	if (!remapped) {
@@ -5228,7 +5224,7 @@ int btrfs_alloc_logged_file_extent(struct btrfs_trans_handle *trans,
 	if (ret)
 		btrfs_pin_extent(trans, ins->objectid, ins->offset);
 	else
-		ret = btrfs_record_squota_delta(fs_info, &delta);
+		btrfs_record_squota_delta(fs_info, &delta);
 	btrfs_put_block_group(block_group);
 	return ret;
 }
diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
index 54d82d6fd4bb..cf8dfd5c692b 100644
--- a/fs/btrfs/qgroup.c
+++ b/fs/btrfs/qgroup.c
@@ -4966,10 +4966,9 @@ void btrfs_qgroup_destroy_extent_records(struct btrfs_transaction *trans)
 	xa_destroy(&trans->delayed_refs.dirty_extents);
 }
 
-int btrfs_record_squota_delta(struct btrfs_fs_info *fs_info,
-			      const struct btrfs_squota_delta *delta)
+void btrfs_record_squota_delta(struct btrfs_fs_info *fs_info,
+			       const struct btrfs_squota_delta *delta)
 {
-	int ret;
 	struct btrfs_qgroup *qgroup;
 	struct btrfs_qgroup *qg;
 	LIST_HEAD(qgroup_list);
@@ -4979,24 +4978,22 @@ int btrfs_record_squota_delta(struct btrfs_fs_info *fs_info,
 
 	if (btrfs_qgroup_mode(fs_info) != BTRFS_QGROUP_MODE_SIMPLE &&
 	    !test_bit(BTRFS_FS_SQUOTA_ENABLING, &fs_info->flags))
-		return 0;
+		return;
 
 	if (!btrfs_is_fstree(root))
-		return 0;
+		return;
 
 	/* If the extent predates enabling quotas, don't count it. */
 	if (delta->generation < fs_info->qgroup_enable_gen)
-		return 0;
+		return;
 
 	spin_lock(&fs_info->qgroup_lock);
 	qgroup = find_qgroup_rb(fs_info, root);
 	if (WARN_ON_ONCE(!qgroup)) {
 		btrfs_warn(fs_info, "squota failed to find qgroup for root %llu", root);
-		ret = 0;
 		goto out;
 	}
 
-	ret = 0;
 	qgroup_iterator_add(&qgroup_list, qgroup);
 	list_for_each_entry(qg, &qgroup_list, iterator) {
 		struct btrfs_qgroup_list *glist;
@@ -5022,5 +5019,4 @@ int btrfs_record_squota_delta(struct btrfs_fs_info *fs_info,
 
 out:
 	spin_unlock(&fs_info->qgroup_lock);
-	return ret;
 }
diff --git a/fs/btrfs/qgroup.h b/fs/btrfs/qgroup.h
index c64b26b09c22..a29b4e216f25 100644
--- a/fs/btrfs/qgroup.h
+++ b/fs/btrfs/qgroup.h
@@ -427,7 +427,7 @@ int btrfs_qgroup_trace_subtree_after_cow(struct btrfs_trans_handle *trans,
 		struct btrfs_root *root, struct extent_buffer *eb);
 void btrfs_qgroup_destroy_extent_records(struct btrfs_transaction *trans);
 bool btrfs_check_quota_leak(const struct btrfs_fs_info *fs_info);
-int btrfs_record_squota_delta(struct btrfs_fs_info *fs_info,
-			      const struct btrfs_squota_delta *delta);
+void btrfs_record_squota_delta(struct btrfs_fs_info *fs_info,
+			       const struct btrfs_squota_delta *delta);
 
 #endif
-- 
2.47.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 0/2] btrfs: fix a bug with the squotas code and cleanup.
  2026-10-05 12:13 [PATCH 0/2] btrfs: fix a bug with the squotas code and cleanup fdmanana
  2026-10-05 12:13 ` [PATCH 1/2] btrfs: fix lost error return value in btrfs_alloc_logged_file_extent() fdmanana
  2026-10-05 12:13 ` [PATCH 2/2] btrfs: qgroup: make btrfs_record_squota_delta() return void fdmanana
@ 2026-10-05 22:13 ` Qu Wenruo
  2 siblings, 0 replies; 4+ messages in thread
From: Qu Wenruo @ 2026-10-05 22:13 UTC (permalink / raw)
  To: fdmanana, linux-btrfs



在 2026/10/5 22:43, fdmanana@kernel.org 写道:
> From: Filipe Manana <fdmanana@suse.com>
> 
> Fix a bug during log replay (regardless if quotas are enabled or not) and
> a cleanup.

Reviewed-by: Qu Wenruo <wqu@suse.com>

Thanks,
Qu

> 
> Filipe Manana (2):
>    btrfs: fix lost error return value in btrfs_alloc_logged_file_extent()
>    btrfs: qgroup: make btrfs_record_squota_delta() return void
> 
>   fs/btrfs/extent-tree.c | 11 ++++-------
>   fs/btrfs/qgroup.c      | 14 +++++---------
>   fs/btrfs/qgroup.h      |  4 ++--
>   3 files changed, 11 insertions(+), 18 deletions(-)
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-10-05 22:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-05 12:13 [PATCH 0/2] btrfs: fix a bug with the squotas code and cleanup fdmanana
2026-10-05 12:13 ` [PATCH 1/2] btrfs: fix lost error return value in btrfs_alloc_logged_file_extent() fdmanana
2026-10-05 12:13 ` [PATCH 2/2] btrfs: qgroup: make btrfs_record_squota_delta() return void fdmanana
2026-10-05 22:13 ` [PATCH 0/2] btrfs: fix a bug with the squotas code and cleanup Qu Wenruo

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.