@@ -5410,7 +5410,8 @@ static int process_extent_item(struct btrfs_root *root,
return -EIO;
}
if (metadata)
- btrfs_check_subpage_eb_alignment(key.objectid, num_bytes);
+ btrfs_check_subpage_eb_alignment(gfs_info, key.objectid,
+ num_bytes);
memset(&tmpl, 0, sizeof(tmpl));
tmpl.start = key.objectid;
@@ -175,20 +175,24 @@ static inline u32 btrfs_type_to_imode(u8 type)
int get_extent_item_generation(u64 bytenr, u64 *gen_ret);
/*
- * Check tree block alignment for future subpage support on 64K page system.
+ * Check tree block alignment for future subpage support.
*
- * Subpage support on 64K page size require one eb to be completely contained
- * by a page. Not allowing a tree block to cross 64K page boundary.
+ * For subpage support, either nodesize is smaller than PAGE_SIZE, then tree
+ * block should not cross page boundary. (A)
+ * Or nodesize >= PAGE_SIZE, then it should be page aligned. (B)
*
- * Since subpage support is still under development, this check only provides
- * warning.
+ * But here we have no idea the PAGE_SIZE could be, so here we play safe by
+ * requiring all tree blocks to be nodesize aligned.
+ *
+ * For 4K page size system, it always meets condtion (B), thus we don't need
+ * to bother that much.
*/
-static inline void btrfs_check_subpage_eb_alignment(u64 start, u32 len)
+static inline void btrfs_check_subpage_eb_alignment(struct btrfs_fs_info *info,
+ u64 start, u32 len)
{
- if (start / BTRFS_MAX_METADATA_BLOCKSIZE !=
- (start + len - 1) / BTRFS_MAX_METADATA_BLOCKSIZE)
+ if (!IS_ALIGNED(start, info->nodesize))
warning(
-"tree block [%llu, %llu) crosses 64K page boundary, may cause problem for 64K page system",
+"tree block [%llu, %llu) is not nodesize aligned, may cause problem for 64K page system",
start, start + len);
}
@@ -4265,7 +4265,8 @@ static int check_extent_item(struct btrfs_path *path)
err |= CROSSING_STRIPE_BOUNDARY;
}
if (metadata)
- btrfs_check_subpage_eb_alignment(key.objectid, nodesize);
+ btrfs_check_subpage_eb_alignment(gfs_info, key.objectid,
+ nodesize);
ptr = (unsigned long)(ei + 1);
@@ -850,7 +850,7 @@ check_test_results()
local testname="$2"
# Check subpage related warning
- if grep -q "crrosses 64K page boundary" "$results"; then
+ if grep -q "not nodesize aligned" "$results"; then
_fail "found subpage related warning for case $testname"
fi
}
For the incoming extra page size support for subpage (sectorsize < PAGE_SIZE) cases, the support for metadata will be a critical point. Currently for subpage support, we require 64K page size, so that no matter whatever the nodesize is, it will be contained inside one page. And we will reject any tree block which crosses page boundary. But for other page size, especially 16K page size, we must support nodesize differently. For nodesize < PAGE_SIZE, we will have the same requirement (tree blocks can't cross page boundary). While for nodesize >= PAGE_SIZE, we will require the tree blocks to be page aligned. To support such feature, we will make btrfs-check to reports more subpage related warnings for metadata. This patch will report any tree block which is not nodesize aligned as a warning. Existing mkfs/convert has already make sure all new tree blocks are nodesize aligned, this is just for older converted filesystems. Signed-off-by: Qu Wenruo <wqu@suse.com> --- check/main.c | 3 ++- check/mode-common.h | 22 +++++++++++++--------- check/mode-lowmem.c | 3 ++- tests/common | 2 +- 4 files changed, 18 insertions(+), 12 deletions(-)