Hi,

Jochen Spieker wrote:
> > I was always under the impression that an LVM snapshot is not better
> > than an unclean filesystem, like for example after a power loss. But
> > this 20 year old document proved me wrong:
> > https://tldp.org/HOWTO/LVM-HOWTO/snapshotintro.html

[email protected]:
> Is there any reference for that? AFAIK LVM doesn't "know" about the
> underlying file system (if there is any).
In a later mail:
> This sounds very hypothetical: how should LVM that there is a file
> system /at all/ on the logical volume being snapshotted? How that
> this file system is mounted?

Obviously one can inquire the list of mounted filesystems and their
storage devices. From there it is possible to get to the VFS call
interface of Linux:

  https://www.kernel.org/doc/html/latest/filesystems/vfs.html
  "struct super_operations
   This describes how the VFS can manipulate the superblock of your
   filesystem. The following members are defined:
   [...]
   freeze_super
   [...]
   freeze_fs
   called when VFS is locking a filesystem and forcing it into a
   consistent state. This method is currently used by the Logical Volume
   Manager (LVM) and ioctl(FIFREEZE). Optional.
   [...]
   thaw_super
   [...]
   unfreeze_fs
   called when VFS is unlocking a filesystem and making it writable
   again after ->freeze_fs. Optional.
  "

While trying to find out how to get a filedescriptor that's usable with
ioctl(FIFREEZE), i came to a command line tool in Debian which offers
the desired functionality:

  https://manpages.debian.org/bullseye/util-linux/fsfreeze.8.en.html
  "NAME
     fsfreeze - suspend access to a filesystem (Ext3/4, ReiserFS, JFS,
     XFS)
   SYNOPSIS
     fsfreeze --freeze|--unfreeze mountpoint
   "

This is fewly usable with a backup run which needs substantial time
while blocking the filesystem activity.
That's where something like LVM is needed which can quickly fixate a
snapshot of the storage device state before it calls unfreeze_fs.


Have a nice day :)

Thomas

Reply via email to