All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] btrfs: fix re-dirty process of tree-log nodes
@ 2021-11-29  2:49 Naohiro Aota
  2021-11-29  7:57 ` Johannes Thumshirn
  2021-11-29 12:19 ` David Sterba
  0 siblings, 2 replies; 5+ messages in thread
From: Naohiro Aota @ 2021-11-29  2:49 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba, Naohiro Aota

For zoned btrfs, we re-dirty a freeing tree node to ensure btrfs write
the region and not to leave a write hole on a zoned device. Current
code failed to re-dirty a node when the tree-log tree's depth >=
2. This leads to a transaction abort with -EAGAIN.

Fix the issue by properly re-dirty a node on walking up the tree.

Link: https://github.com/kdave/btrfs-progs/issues/415
Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
---
 fs/btrfs/tree-log.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index de79e15a7c6a..a42e132f35f5 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -2890,6 +2890,8 @@ static noinline int walk_up_log_tree(struct btrfs_trans_handle *trans,
 						     path->nodes[*level]->len);
 					if (ret)
 						return ret;
+					btrfs_redirty_list_add(trans->transaction,
+							       next);
 				} else {
 					if (test_and_clear_bit(EXTENT_BUFFER_DIRTY, &next->bflags))
 						clear_extent_buffer_dirty(next);
@@ -2970,6 +2972,8 @@ static int walk_log_tree(struct btrfs_trans_handle *trans,
 						next->start, next->len);
 				if (ret)
 					goto out;
+				btrfs_redirty_list_add(trans->transaction,
+						       next);
 			} else {
 				if (test_and_clear_bit(EXTENT_BUFFER_DIRTY, &next->bflags))
 					clear_extent_buffer_dirty(next);
@@ -3420,8 +3424,6 @@ static void free_log_tree(struct btrfs_trans_handle *trans,
 			  EXTENT_DIRTY | EXTENT_NEW | EXTENT_NEED_WAIT);
 	extent_io_tree_release(&log->log_csum_range);
 
-	if (trans && log->node)
-		btrfs_redirty_list_add(trans->transaction, log->node);
 	btrfs_put_root(log);
 }
 
-- 
2.34.1


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

end of thread, other threads:[~2021-11-30  1:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-29  2:49 [PATCH] btrfs: fix re-dirty process of tree-log nodes Naohiro Aota
2021-11-29  7:57 ` Johannes Thumshirn
2021-11-30  1:51   ` Naohiro Aota
2021-11-29 12:19 ` David Sterba
2021-11-30  1:51   ` Naohiro Aota

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.