Skip to content

Commit 975a6a8

Browse files
adam900710kdave
authored andcommitted
btrfs: add extra error messages for delalloc range related errors
All the error handling bugs I hit so far are all -ENOSPC from either: - cow_file_range() - run_delalloc_nocow() - submit_uncompressed_range() Previously when those functions failed, there was no error message at all, making the debugging much harder. So here we introduce extra error messages for: - cow_file_range() - run_delalloc_nocow() - submit_uncompressed_range() - writepage_delalloc() when btrfs_run_delalloc_range() failed - extent_writepage() when extent_writepage_io() failed One example of the new debug error messages is the following one: run fstests generic/750 at 2024-12-08 12:41:41 BTRFS: device fsid 461b25f5-e240-4543-8deb-e7c2bd01a6d3 devid 1 transid 8 /dev/mapper/test-scratch1 (253:4) scanned by mount (2436600) BTRFS info (device dm-4): first mount of filesystem 461b25f5-e240-4543-8deb-e7c2bd01a6d3 BTRFS info (device dm-4): using crc32c (crc32c-arm64) checksum algorithm BTRFS info (device dm-4): forcing free space tree for sector size 4096 with page size 65536 BTRFS info (device dm-4): using free-space-tree BTRFS warning (device dm-4): read-write for sector size 4096 with page size 65536 is experimental BTRFS info (device dm-4): checking UUID tree BTRFS error (device dm-4): cow_file_range failed, root=363 inode=412 start=503808 len=98304: -28 BTRFS error (device dm-4): run_delalloc_nocow failed, root=363 inode=412 start=503808 len=98304: -28 BTRFS error (device dm-4): failed to run delalloc range, root=363 ino=412 folio=458752 submit_bitmap=11-15 start=503808 len=98304: -28 Which shows an error from cow_file_range() which is called inside a nocow write attempt, along with the extra bitmap from writepage_delalloc(). Reviewed-by: Boris Burkov <[email protected]> Signed-off-by: Qu Wenruo <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 61d7307 commit 975a6a8

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

fs/btrfs/extent_io.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1255,6 +1255,15 @@ static noinline_for_stack int writepage_delalloc(struct btrfs_inode *inode,
12551255
wbc);
12561256
if (ret >= 0)
12571257
last_finished_delalloc_end = found_start + found_len;
1258+
if (unlikely(ret < 0))
1259+
btrfs_err_rl(fs_info,
1260+
"failed to run delalloc range, root=%lld ino=%llu folio=%llu submit_bitmap=%*pbl start=%llu len=%u: %d",
1261+
btrfs_root_id(inode->root),
1262+
btrfs_ino(inode),
1263+
folio_pos(folio),
1264+
fs_info->sectors_per_page,
1265+
&bio_ctrl->submit_bitmap,
1266+
found_start, found_len, ret);
12581267
} else {
12591268
/*
12601269
* We've hit an error during previous delalloc range,
@@ -1553,6 +1562,12 @@ static int extent_writepage(struct folio *folio, struct btrfs_bio_ctrl *bio_ctrl
15531562
PAGE_SIZE, bio_ctrl, i_size);
15541563
if (ret == 1)
15551564
return 0;
1565+
if (ret < 0)
1566+
btrfs_err_rl(fs_info,
1567+
"failed to submit blocks, root=%lld inode=%llu folio=%llu submit_bitmap=%*pbl: %d",
1568+
btrfs_root_id(inode->root), btrfs_ino(inode),
1569+
folio_pos(folio), fs_info->sectors_per_page,
1570+
&bio_ctrl->submit_bitmap, ret);
15561571

15571572
bio_ctrl->wbc->nr_to_write--;
15581573

fs/btrfs/inode.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,6 +1132,10 @@ static void submit_uncompressed_range(struct btrfs_inode *inode,
11321132
if (locked_folio)
11331133
btrfs_folio_end_lock(inode->root->fs_info, locked_folio,
11341134
start, async_extent->ram_size);
1135+
btrfs_err_rl(inode->root->fs_info,
1136+
"%s failed, root=%llu inode=%llu start=%llu len=%llu: %d",
1137+
__func__, btrfs_root_id(inode->root),
1138+
btrfs_ino(inode), start, async_extent->ram_size, ret);
11351139
}
11361140
}
11371141

@@ -1576,6 +1580,10 @@ static noinline int cow_file_range(struct btrfs_inode *inode,
15761580
btrfs_qgroup_free_data(inode, NULL, start + cur_alloc_size,
15771581
end - start - cur_alloc_size + 1, NULL);
15781582
}
1583+
btrfs_err_rl(fs_info,
1584+
"%s failed, root=%llu inode=%llu start=%llu len=%llu: %d",
1585+
__func__, btrfs_root_id(inode->root),
1586+
btrfs_ino(inode), orig_start, end + 1 - orig_start, ret);
15791587
return ret;
15801588
}
15811589

@@ -2322,6 +2330,10 @@ static noinline int run_delalloc_nocow(struct btrfs_inode *inode,
23222330
btrfs_qgroup_free_data(inode, NULL, cur_offset, end - cur_offset + 1, NULL);
23232331
}
23242332
btrfs_free_path(path);
2333+
btrfs_err_rl(fs_info,
2334+
"%s failed, root=%llu inode=%llu start=%llu len=%llu: %d",
2335+
__func__, btrfs_root_id(inode->root),
2336+
btrfs_ino(inode), start, end + 1 - start, ret);
23252337
return ret;
23262338
}
23272339

0 commit comments

Comments
 (0)