diff mbox series

[3/3] btrfs: add extra error messages for extent_writepage() failure

Message ID 1fec3614cbdbd7fc5a3411b00de28ad7e53df518.1732680197.git.wqu@suse.com (mailing list archive)
State New
Headers show
Series btrfs: extra debug output for sector size < page size cases | expand

Commit Message

Qu Wenruo Nov. 27, 2024, 4:06 a.m. UTC
During my development on aarch64 with 64K page size and 4K sector size,
I'm hitting several problems related to error handling of
extent_writepage(), most of them are caused by
btrfs_run_delalloc_range() failure with -ENOSPC error.

This error itself is already a problem for our data/metadata space
reservation code, but we also need extra info like the submit_bitmap to
calculate if the error handling is doing its job correctly.

So add two btrfs_err_rl()s to indicate the errors that is affecting the
error handling of extent_writepage(), which has already saved me several
times during debugging.

Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 fs/btrfs/extent_io.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
diff mbox series

Patch

diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 438974d4def4..e33f843c403c 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -1240,6 +1240,15 @@  static noinline_for_stack int writepage_delalloc(struct btrfs_inode *inode,
 						       found_start,
 						       found_start + found_len - 1,
 						       wbc);
+			if (unlikely(ret < 0))
+				btrfs_err_rl(fs_info,
+"failed to run delalloc range, root %lld ino %llu folio %llu submit_bitmap %*pbl start %llu len %u: %d",
+					     inode->root->root_key.objectid,
+					     btrfs_ino(inode),
+					     folio_pos(folio),
+					     fs_info->sectors_per_page,
+					     &bio_ctrl->submit_bitmap,
+					     found_start, found_len, ret);
 		} else {
 			/*
 			 * We've hit an error during previous delalloc range,
@@ -1506,6 +1515,13 @@  static int extent_writepage(struct folio *folio, struct btrfs_bio_ctrl *bio_ctrl
 				  PAGE_SIZE, bio_ctrl, i_size);
 	if (ret == 1)
 		return 0;
+	if (ret < 0)
+		btrfs_err_rl(fs_info,
+"failed to submit blocks, root %lld ino %llu folio %llu submit_bitmap %*pbl: %d",
+			     BTRFS_I(inode)->root->root_key.objectid,
+			     btrfs_ino(BTRFS_I(inode)),
+			     folio_pos(folio), fs_info->sectors_per_page,
+			     &bio_ctrl->submit_bitmap, ret);
 
 	bio_ctrl->wbc->nr_to_write--;