path: root/volumes.h
diff options
authorDavid Sterba <>2015-09-10 16:36:04 +0200
committerDavid Sterba <>2015-09-11 16:46:14 +0200
commit73a894e51e5bcea9fddc4f3ded37d0ad81456e92 (patch)
tree4282c5993b8541dffaed600c64c2100d063f2aef /volumes.h
parent81a58518d42eec1055ca70640e722d601c4572b1 (diff)
btrfs-progs: fix cross stripe boundary check
Commit 854437ca3c228d8ab3eb24d2efc1c21b5d56a635 ("btrfs-progs: extent-tree: avoid allocating tree block that crosses stripe boundary") does not work for 64k nodesize. Due to an off-by-one error, all queries to check_crossing_stripes will return that all extents cross a stripe and this will lead to a false ENOSPC. This crashes later $ ./mkfs.btrfs -n 64k image ./mkfs.btrfs(btrfs_reserve_extent+0xb77)[0x417f38] ./mkfs.btrfs(btrfs_alloc_free_block+0x57)[0x417fe0] ./mkfs.btrfs(__btrfs_cow_block+0x163)[0x408eb7] ./mkfs.btrfs(btrfs_cow_block+0xd0)[0x4097c4] ./mkfs.btrfs(btrfs_search_slot+0x16f)[0x40be4d] ./mkfs.btrfs(btrfs_insert_empty_items+0xc0)[0x40d5f9] ./mkfs.btrfs(btrfs_insert_item+0x99)[0x40da5f] ./mkfs.btrfs(btrfs_make_block_group+0x4d)[0x41705c] ./mkfs.btrfs(main+0xeef)[0x434b56] Holger Hoffstätte reports that this also fixes false positives in case the nodesize is less than 64k. This happens when the node blocks end at the stripe boundary. Reviewed-by: Qu Wenruo <> Signed-off-by: David Sterba <>
Diffstat (limited to 'volumes.h')
1 files changed, 1 insertions, 1 deletions
diff --git a/volumes.h b/volumes.h
index f7761311..4ecb9931 100644
--- a/volumes.h
+++ b/volumes.h
@@ -156,7 +156,7 @@ struct map_lookup {
static inline int check_crossing_stripes(u64 start, u64 len)
return (start / BTRFS_STRIPE_LEN) !=
- ((start + len) / BTRFS_STRIPE_LEN);
+ ((start + len - 1) / BTRFS_STRIPE_LEN);
int __btrfs_map_block(struct btrfs_mapping_tree *map_tree, int rw,