mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/kdave/btrfs-progs.git
synced 2024-12-04 01:24:20 +08:00
af6f301834
[BUG] There is a bug report that on s390x big endian systems, mkfs.btrfs just fails: $ mkfs.btrfs -f ~/test.img btrfs-progs v6.3.1 Invalid mapping for 1081344-1097728, got 17592186044416-17592190238720 Couldn't map the block 1081344 ERROR: cannot read chunk root ERROR: open ctree failed [CAUSE] The error is caused by wrong endian conversion. The s390x is a big endian architecture: $ lscpu Byte Order: Big Endian While checking the offending @disk_key and @key inside btrfs_read_sys_array(), we got: 2301 while (cur_offset < array_size) { (gdb) 2304 if (cur_offset + len > array_size) (gdb) 2307 btrfs_disk_key_to_cpu(&key, disk_key); (gdb) 2310 sb_array_offset += len; (gdb) print *disk_key $2 = {objectid = 281474976710656, type = 228 '\344', offset = 17592186044416} (gdb) print key $3 = {objectid = 281474976710656, type = 228 '\344', offset = 17592186044416} (gdb) Now we can see, @disk_key is indeed in the little endian, but @key is not converted to the CPU native endian. Furthermore, if we step into the help btrfs_disk_key_to_cpu(), it shows we're using little endian version: (gdb) step btrfs_disk_key_to_cpu (disk_key=0x109fcdb, cpu_key=0x3ffffff847f) at ./kernel-shared/accessors.h:592 592 memcpy(cpu_key, disk_key, sizeof(struct btrfs_key)); [FIX] The kernel accessors.h checks if __LITTLE_ENDIAN is defined or not, but that only works inside kernel. In user space, __LITTLE_ENDIAN and __BIG_ENDIAN are both provided by kerncompat.h that should have been included already. Instead we should check __BYTE_ORDER against __LITTLE_ENDIAN to determine our endianness. With this change, s390x build works as expected now. Issue: #639 Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com> |
||
---|---|---|
.. | ||
uapi | ||
accessors.c | ||
accessors.h | ||
async-thread.c | ||
async-thread.h | ||
backref.c | ||
backref.h | ||
compression.h | ||
ctree.c | ||
ctree.h | ||
delayed-ref.c | ||
delayed-ref.h | ||
dir-item.c | ||
disk-io.c | ||
disk-io.h | ||
extent_io.c | ||
extent_io.h | ||
extent-io-tree.c | ||
extent-io-tree.h | ||
extent-tree.c | ||
file-item.c | ||
file-item.h | ||
file.c | ||
free-space-cache.c | ||
free-space-cache.h | ||
free-space-tree.c | ||
free-space-tree.h | ||
inode-item.c | ||
inode.c | ||
locking.c | ||
locking.h | ||
messages.c | ||
messages.h | ||
misc.h | ||
print-tree.c | ||
print-tree.h | ||
README.md | ||
root-tree.c | ||
send.h | ||
transaction.c | ||
transaction.h | ||
tree-checker.c | ||
tree-checker.h | ||
tree-mod-log.h | ||
ulist.c | ||
ulist.h | ||
uuid-tree.c | ||
volumes.c | ||
volumes.h | ||
zoned.c | ||
zoned.h |
Shared sources with kernel
Status and progress of kernel/userspace synchronization.
- accessors.c - done, local changes
- accessors.h - done, local changes
- async-thread.c - done
- async-thread.h - done
- backref.c - todo
- backref.h - todo
- compression.h - done
- ctree.c - partial
- ctree.h - partial
- delayed-ref.c - partial
- delayed-ref.h - partial
- dir-item.c - partial
- disk-io.c - todo
- disk-io.h - todo
- extent_io.c
- extent_io.h
- extent-io-tree.c - done, local changes
- extent-io-tree.h - done, local changes
- extent-tree.c - todo
- file.c - todo
- file-item.c - todo
- file-item.h - partial
- free-space-cache.c - not needed
- free-space-cache.h - not needed
- free-space-tree.c - partial
- free-space-tree.h - partial
- inode.c - todo
- inode-item.c - partial
- locking.c - done, local changes
- locking.h - done, local changes
- messages.c - done, local changes
- messages.h - done, local changes
- misc.h - done
- print-tree.c - partial, sync to kernel
- print-tree.h - partial
- root-tree.c - partial
- root-tree.h - done
- send.h - done
- transaction.c - todo
- transaction.h - partial, local changes
- tree-checker.c - partial, local changes
- tree-checker.h - partial, local changes
- tree-mod-log.h - done, local changes
- ulist.c - done
- ulist.h - done
- uuid-tree.c - partial
- volumes.c - todo, local changes
- volumes.h - todo, local changes
- zoned.c - todo
- zoned.h - todo