Re: Does GRUB btrfs support log tree?

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

 



On Sat, Oct 26, 2019 at 9:12 AM Andrei Borzenkov <arvidjaar@xxxxxxxxx> wrote:
>
> 25.10.2019 12:47, Chris Murphy пишет:
> > I see references to root and chunk trees, but not the log tree.
> >
> > If boot related files: kernel, initramfs, bootloader configuration
> > files, are stored on Btrfs; and if they are changed in such a way as
> > to rely on the log tree; and then there's a crash; what's the worse
> > case scenario effect?
> >
> > At first glance, if the bootloader doesn't support log tree, it would
> > have a stale view of the file system.
>
> Yes, happened to me several times on ext4.

Yeah I have a reproducer on XFS, but was only able to get it to happen
once on ext4 and not again after 1/2 dozen attempts.

>
> > Since log tree writes means a
> > full file system update hasn't happened, the old file system state
> > hasn't been dereferenced, so even in an SSD + discard case, the system
> > should still be bootable. And at that point Btrfs kernel code does log
> > replay, and catches the system up, and the next update will boot the
> > new state.
> >
> > Correct?
> >
>
> Yes. If we speak about grub here, it actually tries very hard to ensure
> writes has hit disk (it fsyncs files as it writes them and it flushes
> raw devices). But I guess that fsync on btrfs just goes into log and
> does not force transaction. Is it possible to force transaction on btrfs
> from user space?

The only fsync I ever see Fedora's grub2-mkconfig do is for grubenv.
The grub.cfg is not fsync'd. When I do a strace of grub2-mkconfig,
it's so incredibly complicated. Using -ff -o options, I get over 1800
separate PID files exported. From what I can tell, it creates a brand
new file "grub.cfg.new" and writes to that. Then does a cat from
"grub.cfg.new" into "grub.cfg" - maybe it's file system specific
behavior, I'm not sure.

I'm pretty sure "sync" will do what you want, it calls syncfs() and
best as I can tell it does a full file system sync, doesn't use the
log tree. I'd argue grub-mkconfig should write all of its files, and
then sync that file system, rather than doing any fsync at all.



-- 
Chris Murphy




[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux