Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mounting from /etc/fstab #211

Open
eu41 opened this issue Aug 18, 2016 · 16 comments
Open

Mounting from /etc/fstab #211

eu41 opened this issue Aug 18, 2016 · 16 comments

Comments

@eu41
Copy link

eu41 commented Aug 18, 2016

The previous update #205 fixed the mounting with filesystem specific options when mounting with lklfuse from command line, but not from /etc/fstab.

The following happens:

lklfuse -o type=btrfs,opts=space_cache,compress=no,discard

works perfectly fine from command line.

When adding this line in /etc/fstab:

/dev/ada2p2 /mnt/data fuse mountprog=/usr/local/bin/lklfuse,type=btrfs,opts=space_cache 0 0

it also works.

But when I add a second or third, fourth filesystem specific option:

/dev/ada2p2 /mnt/data fuse mountprog=/usr/local/bin/lklfuse,type=btrfs,opts=space_cache,compress=no,discard 0 0

it fails with message "Unknown option compress=no".

Tried with one escape, two escapes and no escape, same result.

From fstab it only works with one option, it seems that it cannot deal with subsequent options after the first one.

@ghost
Copy link

ghost commented Aug 18, 2016

This is probably an issue with how fstab is parsed and how many times the options are passed through shell. You may need 4 escapes :)

Can you please attach a strace -f of the mount command?

@cemeyer can you please take a look? I am not familiar with FreeBSD and Linux has a different way of handling fstab / mount (using external helpers) which makes it hard for me to debug it.

@cemeyer
Copy link

cemeyer commented Aug 18, 2016

I'll look. I don't have a lot of familiarity with this part of the system either. If I had to guess, I'd guess that whatever parses fstab is ignoring your escapes entirely and just splitting on commas.

Edit: I can't even get mount to attempt to mount a fuse filesystem. It prints:

fstab: /etc/fstab:9: Inappropriate file type or format
fstab: /etc/fstab:9: Inappropriate file type or format

Any idea, @eu41?

@opurdila, by the way, the FreeBSD equivalent of strace is called truss.

@eu41
Copy link
Author

eu41 commented Aug 18, 2016

Conrad, try a fstab entry simlar to mine.
Alternatively, send your fstab line so I can have a look.

@cemeyer
Copy link

cemeyer commented Aug 18, 2016

Conrad, try a fstab entry simlar to mine.
Alternatively, send your fstab line so I can have a look.

I used a very similar line:

/dev/da0 /mnt/USB fuse mountprog=/usr/local/bin/lklfuse,type=ext4,opts=space_cache\,compress=no\,discard 0 0

@eu41
Copy link
Author

eu41 commented Aug 18, 2016

Your line has the proper format, but ext4 does not support space_cache and compress=no, which are specific to btrfs.
Fort ext 4 you could try "nodealloc,auto_da_alloc,discard" on an ext4 formatted partition.
Remove discard if it's not on a SSD.

@eu41
Copy link
Author

eu41 commented Aug 18, 2016

The output of truss -f mount /dev/ada5p5 is attached in a text file.
truss.txt

@cemeyer
Copy link

cemeyer commented Aug 18, 2016

Your line has the proper format, but ext4 does not support space_cache and compress=no, which are specific to btrfs.
Fort ext 4 you could try "nodealloc,auto_da_alloc,discard" on an ext4 formatted partition.
Remove discard if it's not on a SSD.

mount hasn't gotten to where opts gets parsed, so this doesn't matter at all. Removing those options gives the same result.

The output of truss -f mount /dev/ada5p5 is attached in a text file.

Thanks!

@eu41
Copy link
Author

eu41 commented Aug 18, 2016

Would it be useful to send you the output of truss command that mounts successfully from command line?

@ghost
Copy link

ghost commented Aug 19, 2016

Hmm, looks like the output does not help much because the lklfuse execve arguments are not show. Quickly googling freebsd, truss and execve shows that using -a might help.

@eu41 could you please rerun truss with -a and post the result here? Thanks!

@eu41
Copy link
Author

eu41 commented Aug 19, 2016

Octavian, I don't know much about tracing/debugging, but I did what you asked and applied some logic.
The output of truss -a is attached for two commands and I'm also attaching an extract from my fstab.

  1. truss -a lklfuse -o type=btrfs,opts=space_cache,discard /dev/ada5p4 /mnt/data (successful)
  2. truss -a mount /dev/ada5p4 (this should mount from /etc/fstab, but fails)

The second command fails with the message:

fuse: unknown option `discard'

As you see, the message indicates that the parsing of fstab seems to work properly, the option 'discard' is correctly detected, but somehow is unknown to fuse. Note that even if I add one escape or two escapes in fstab for "opts= ...", I get the same error message, which indicates again that parsing works fine.

Note that the first line in my fstab, which is using ntfs-3g to mount a Windows partition works perfectly when doing "mount /dev/ada5p1". So there seems to be a difference on the way ntfs3g, lklfuse or mount deal with fstab lines.

One more thing: the command that fails is "mount /dev/ada5p4". However, at the end of the output of truss you can see that actually mount is not trying to work with ada5p4 (btrfs partition), but ada5p5, which is my Freebsd native ufs root partition. No ideea why it does that. I have a feeling that FreeBSD mount does not know anything other than ufs partitions, but I cannot explain why "mount /dev/ada5p1" properly mounts the ntfs windows partition, while "mount /dev/ada5p4" fails to mount the btrfs partition.

I don't know which one, mount or lklfuse, is the problem, but the fact that the parsing works, leans towards an lklfuse issue.

Maybe Conrad has some ideas here.

truss-lklfuse_command_line.txt
truss-mount.txt
fstab.txt

@ghost
Copy link

ghost commented Aug 19, 2016

@eu41 please run with -f as well, i.e. truss -f -a, otherwise we can't see the arguments passed to fuse.

@eu41
Copy link
Author

eu41 commented Aug 20, 2016

See attached the output of truss -f -a for three versions of fstab: no escapes, 1 escape, 2 escapes.

Looking at the parameters passed to lklfuse in execve, I think that the fstab should not include any escapes and it's up to lklfuse to assemble into one string all the "-o" options that follow "opts=..." and then use that string to do the mount.

truss-no_excapes.txt
truss-one_escape.txt
truss-two_escapes.txt

@ghost
Copy link

ghost commented Aug 20, 2016

Thanks! It seems that the fstab parser ignores the comma escapes. Also please note that -o rw, -o noatime, etc. are only passed to the fuse module and does not reach LKL.

Right now lklfuse follows the libfuse's conventions and options to be passed to the mount system call should be passed as -o opts=... with , and = escaped.

I am not sure if it is wise to pass all -o options to LKL since there may be collisions with fuse options. A safe way to solve this is to use a separate mount script as a wrapper for lklfuse.

I'll have to think about this more, hope to have something in a couple of days.

@eu41
Copy link
Author

eu41 commented Aug 20, 2016

Why not trying to pass to LKL only its own specific options, including filesystem specific options, like

-o type=btrfs,opts=space_cache,compress=no,discard ... etc.

and leave the others like "rw,noatime ... etc." to be dealt with by OS specific mount command?

After you think about it and do the necessary modifications, please let Conrad know, so he can update the FreeBSD port.

@M1cha
Copy link

M1cha commented Oct 22, 2016

crazy idea: why don't we just use the original mount command(from busybox or core-utils) and either change the source or use LD_PRELOAD to change the 'mount' syscall to a lklfuse function call?
This way you could use all the features that come with that command including fs detection.

@eu41
Copy link
Author

eu41 commented Oct 22, 2016

Check attached FreeBSD /etc/fstab:

fstab.txt

"mount /mnt/windows" works, while "mount /mnt/gentoo" fails

Puzzling why ntfs-3g works fine and has no problems processing all the mounting options, one of them
specific to that filesystem, while lklfuse cannot do the same and fails.

thehajime pushed a commit to thehajime/linux that referenced this issue Aug 4, 2022
ACPICA commit 29da9a2a3f5b2c60420893e5c6309a0586d7a329

ACPI is allocating an object using kmalloc(), but then frees it
using kmem_cache_free(<"Acpi-Namespace" kmem_cache>).

This is wrong and can lead to boot failures manifesting like this:

    hpet0: 3 comparators, 64-bit 100.000000 MHz counter
    clocksource: Switched to clocksource tsc-early
    BUG: unable to handle page fault for address: 000000003ffe0018
    #PF: supervisor read access in kernel mode
    #PF: error_code(0x0000) - not-present page
    PGD 0 P4D 0
    Oops: 0000 [#1] SMP PTI
    CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.6.0+ lkl#211
    Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS
Ubuntu-1.8.2-1ubuntu1 04/01/2014
    RIP: 0010:kmem_cache_alloc+0x70/0x1d0
    Code: 00 00 4c 8b 45 00 65 49 8b 50 08 65 4c 03 05 6f cc e7 7e 4d 8b
20 4d 85 e4 0f 84 3d 01 00 00 8b 45 20 48 8b 7d 00 48 8d 4a 01 <49> 8b
   1c 04 4c 89 e0 65 48 0f c7 0f 0f 94 c0 84 c0 74 c5 8b 45 20
    RSP: 0000:ffffc90000013df8 EFLAGS: 00010206
    RAX: 0000000000000018 RBX: ffffffff81c49200 RCX: 0000000000000002
    RDX: 0000000000000001 RSI: 0000000000000dc0 RDI: 000000000002b300
    RBP: ffff88803e403d00 R08: ffff88803ec2b300 R09: 0000000000000001
    R10: 0000000000000dc0 R11: 0000000000000006 R12: 000000003ffe0000
    R13: ffffffff8110a583 R14: 0000000000000dc0 R15: ffffffff81c49a80
    FS:  0000000000000000(0000) GS:ffff88803ec00000(0000)
knlGS:0000000000000000
    CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    CR2: 000000003ffe0018 CR3: 0000000001c0a001 CR4: 00000000003606f0
    DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
    DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
    Call Trace:
     __trace_define_field+0x33/0xa0
     event_trace_init+0xeb/0x2b4
     tracer_init_tracefs+0x60/0x195
     ? register_tracer+0x1e7/0x1e7
     do_one_initcall+0x74/0x160
     kernel_init_freeable+0x190/0x1f0
     ? rest_init+0x9a/0x9a
     kernel_init+0x5/0xf6
     ret_from_fork+0x35/0x40
    CR2: 000000003ffe0018
    ---[ end trace 707efa023f2ee960 ]---
    RIP: 0010:kmem_cache_alloc+0x70/0x1d0

Bisection leads to unrelated changes in slab; Vlastimil Babka
suggests an unrelated layout or slab merge change merely exposed
the underlying bug.

Link: https://lore.kernel.org/lkml/[email protected]/
Link: https://lore.kernel.org/r/[email protected]
Link: acpica/acpica@29da9a2a
Fixes: f79c8e4 ("ACPICA: Namespace: simplify creation of the initial/default namespace")
Reported-by: Jan Kiszka <[email protected]>
Diagnosed-by: Vlastimil Babka <[email protected]>
Diagnosed-by: Kees Cook <[email protected]>
Signed-off-by: Vegard Nossum <[email protected]>
Signed-off-by: Bob Moore <[email protected]>
Signed-off-by: Erik Kaneda <[email protected]>
Cc: 5.10+ <[email protected]> # 5.10+
Signed-off-by: Rafael J. Wysocki <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants