grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: XFS in GRUB and sparse directories


From: Vladimir 'phcoder' Serbinenko
Subject: Re: XFS in GRUB and sparse directories
Date: Wed, 30 Aug 2017 13:56:56 +0000

Fixed, thanks

Le Mon, Aug 21, 2017 à 3:37 PM, Tuomas Tynkkynen <address@hidden> a écrit :
Hi,

The XFS driver in GRUB doesn't seem to handle sparse blocks in directories
correctly. This can be reproduced by creating a simple XFS filesystem
with a couple of files removed from the 'middle:

------------------------------------------------------
truncate -s 16M /tmp/xfstest.img
mkfs.xfs /tmp/xfstest.img
mount /tmp/xfstest.img /media

mkdir /media/dir
for i in A B C D E F G; do
    for j in {000..999}; do
        touch /media/dir/$i$j
    done
done
rm -rf /media/dir/B* /media/dir/C*

umount /media
------------------------------------------------------
Or grab it from https://cs.helsinki.fi/u/tmtynkky/xfs-sparse-dir.img.xz
(181K
compressed).

Now running `grub-fstest /tmp/xfstest.img ls /dir` on that gives a
decent spam of 'error: not a correct XFS inode.', coming from:

#0  grub_error (n=GRUB_ERR_BAD_FS, fmt=0x4bd332 "not a correct XFS inode") at grub-core/kern/err.c:41
#1  0x000000000043baf6 in grub_xfs_read_inode (data="" ino=0, inode=0x7216a4) at grub-core/fs/xfs.c:491
#2  0x000000000043c21b in iterate_dir_call_hook (ino=0, filename=0x77da79 "", ctx=0x7fffffffb590) at grub-core/fs/xfs.c:712
#3  0x000000000043c766 in grub_xfs_iterate_dir (dir=0x721060, hook=0x43ca5f <grub_xfs_dir_iter>, hook_data=0x7fffffffb690) at grub-core/fs/xfs.c:856
#4  0x000000000043cbad in grub_xfs_dir (device=0x720850, path=0x7205b0 "/dir", hook=0x4070c8 <print_files>, hook_data=0x7fffffffb6f0) at grub-core/fs/xfs.c:984
#5  0x000000000040750b in grub_ls_list_files (dirname=0x7205b0 "/dir", longlist=0, all=0, human=0) at grub-core/commands/ls.c:217
#6  0x00000000004076db in grub_cmd_ls (ctxt=0x7fffffffb7a0, argc=1, args=0x720830) at grub-core/commands/ls.c:275
#7  0x00000000004a2167 in grub_extcmd_dispatcher (cmd=0x71f270, argc=1, args=0x71f0c0, script=0x0) at grub-core/commands/extcmd.c:54
#8  0x00000000004a21c6 in grub_extcmd_dispatch (cmd=0x71f270, argc=1, args=0x71f0c0) at grub-core/commands/extcmd.c:67
#9  0x0000000000403763 in execute_command (name=0x4ba178 "ls", n=1, args=0x71f0c0) at util/grub-fstest.c:59
#10 0x000000000040449e in fstest (n=1) at util/grub-fstest.c:433
#11 0x0000000000405189 in main (argc=4, argv=0x7fffffffba38) at util/grub-fstest.c:769

Some poking in GDB tells that grub_xfs_iterate_dir is processing a zeroed out direntry
in block 4 of the directory inode 6915. That appears to be a sparse block
if I'm understanding the xfs_db correctly:

------------------------------------------------------
xfs_db> inode 6915
xfs_db> p
core.magic = 0x494e
core.mode = 040755
core.version = 3
core.format = 3 (btree)
...
core.size = 114688
core.nblocks = 43
core.extsize = 0
core.nextents = 41
core.naextents = 0
core.forkoff = 0
core.aformat = 2 (extents)
...
xfs_db> bmap

data offset 0 startblock 872 (0/872) count 1 flag 0
data offset 1 startblock 874 (0/874) count 1 flag 0
data offset 2 startblock 932 (0/932) count 1 flag 0
data offset 3 startblock 935 (0/935) count 1 flag 0
data offset 11 startblock 1240 (0/1240) count 1 flag 0
data offset 12 startblock 1242 (0/1242) count 1 flag 0
data offset 13 startblock 1308 (0/1308) count 1 flag 0
data offset 14 startblock 1310 (0/1310) count 1 flag 0
data offset 15 startblock 1376 (0/1376) count 1 flag 0
data offset 16 startblock 1378 (0/1378) count 1 flag 0
data offset 17 startblock 1436 (0/1436) count 1 flag 0
data offset 18 startblock 1438 (0/1438) count 1 flag 0
data offset 19 startblock 1504 (0/1504) count 1 flag 0
data offset 20 startblock 1506 (0/1506) count 1 flag 0
data offset 21 startblock 1572 (0/1572) count 1 flag 0
data offset 22 startblock 1574 (0/1574) count 1 flag 0
data offset 23 startblock 1640 (0/1640) count 1 flag 0
data offset 24 startblock 1642 (0/1642) count 1 flag 0
data offset 25 startblock 1708 (0/1708) count 1 flag 0
data offset 26 startblock 1710 (0/1710) count 1 flag 0
data offset 27 startblock 1776 (0/1776) count 1 flag 0
data offset 8388608 startblock 873 (0/873) count 1 flag 0
data offset 8388609 startblock 933 (0/933) count 2 flag 0
data offset 8388611 startblock 968 (0/968) count 1 flag 0
data offset 8388612 startblock 970 (0/970) count 1 flag 0
data offset 8388621 startblock 1309 (0/1309) count 1 flag 0
data offset 8388622 startblock 1311 (0/1311) count 1 flag 0
data offset 8388623 startblock 1377 (0/1377) count 1 flag 0
data offset 8388624 startblock 1379 (0/1379) count 1 flag 0
data offset 8388625 startblock 1437 (0/1437) count 1 flag 0
data offset 8388626 startblock 1439 (0/1439) count 1 flag 0
data offset 8388627 startblock 1505 (0/1505) count 1 flag 0
data offset 8388628 startblock 1507 (0/1507) count 1 flag 0
data offset 8388629 startblock 1573 (0/1573) count 1 flag 0
data offset 8388630 startblock 1575 (0/1575) count 1 flag 0
data offset 8388631 startblock 1641 (0/1641) count 1 flag 0
data offset 8388632 startblock 1643 (0/1643) count 1 flag 0
data offset 8388633 startblock 1709 (0/1709) count 1 flag 0
data offset 8388634 startblock 1711 (0/1711) count 1 flag 0
data offset 8388635 startblock 1777 (0/1777) count 1 flag 0
data offset 16777216 startblock 875 (0/875) count 1 flag 0
------------------------------------------------------

I suppose grub_xfs_iterate_dir() should be taught to skip
over sparse blocks in directory allocations, or maybe
there is something more wrong with the directory code?

_______________________________________________
Grub-devel mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/grub-devel

reply via email to

[Prev in Thread] Current Thread [Next in Thread]