Skip to contentSkip to conversation

btrfs-progs: print the csum length in debug-tree

PATCH In review [email protected] 3 participants 3 messages Aug 25, 2017 – Sep 1, 2017 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 btrfs-progs: print the csum length in debug-tree

From: Josef Bacik <[email protected]>

While looking at a log of a corrupted fs I needed to verify we were missing csums for a given range. Make this easier by printing out the range of bytes a csum item covers.

---
v1->v2:
- print the byte range instead of just the length

 print-tree.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
print-tree.c +9 -2
index 5927ed3..2aead6a 100644
@@ -1103,9 +1103,16 @@ void btrfs_print_leaf(struct btrfs_root *root, struct extent_buffer *eb)
 		case BTRFS_CSUM_ITEM_KEY:
 			printf("\t\tcsum item\n");
 			break;
-		case BTRFS_EXTENT_CSUM_KEY:
-			printf("\t\textent csum item\n");
+		case BTRFS_EXTENT_CSUM_KEY: {
+			u16 csum_size =
+				btrfs_super_csum_size(root->fs_info->super_copy);
+			u32 size = (item_size / csum_size) *
+				root->fs_info->sectorsize;
+			printf("\t\textent csum item range %llu-%llu\n",
+			       (unsigned long long)disk_key.offset,
+			       (unsigned long long)disk_key.offset + size);
 			break;
+			}
 		case BTRFS_EXTENT_DATA_KEY:
 			print_file_extent_item(eb, item, i, ptr);
 			break;
Signature · 1 line
2.7.4
Reviewed-by on v2 1/1
#1 lore raw
Quoted 7 lines · On 25.08.2017 18:11, [email protected] wrote:

From: Josef Bacik <[email protected]>

While looking at a log of a corrupted fs I needed to verify we were missing csums for a given range. Make this easier by printing out the range of bytes a csum item covers.

Quoted 31 lines

---
v1->v2:
- print the byte range instead of just the length

 print-tree.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
print-tree.c +9 -2
index 5927ed3..2aead6a 100644
@@ -1103,9 +1103,16 @@ void btrfs_print_leaf(struct btrfs_root *root, struct extent_buffer *eb)
 		case BTRFS_CSUM_ITEM_KEY:
 			printf("\t\tcsum item\n");
 			break;
-		case BTRFS_EXTENT_CSUM_KEY:
-			printf("\t\textent csum item\n");
+		case BTRFS_EXTENT_CSUM_KEY: {
+			u16 csum_size =
+				btrfs_super_csum_size(root->fs_info->super_copy);
+			u32 size = (item_size / csum_size) *
+				root->fs_info->sectorsize;
+			printf("\t\textent csum item range %llu-%llu\n",
+			       (unsigned long long)disk_key.offset,
+			       (unsigned long long)disk_key.offset + size);
 			break;
+			}
 		case BTRFS_EXTENT_DATA_KEY:
 			print_file_extent_item(eb, item, i, ptr);
 			break;