0

Is it possible to force a complete re-read of a mounted filesystem (EXT4) from disk in a blocking manner? I have a potential situation where independent and external hardware can modify a filesystem which is already mounted and in-use on Linux.

My perceived problem with simply unmounting and remounting the filesystem is that processes may attempt to use the filesystem after it is unmounted but before it is remounted.

I would like to reread/remount the entire filesystem (superblock included) in a manner that does not hinder any processes expecting the utilize the file system (i.e. blocking between an unmount and remount).

Is this possible in any manner?

  • The remount operation only allows one to change the mount flags. I would like the entire filesystem to be re-read from disk. – bangelo Apr 10 '15 at 15:55
  • As far as I know, ext doesn't have those semantics, but you could interpose another filesystem between the user and the filesystem, such as NFS. If you terminate the NFS server before fiddling with the underlying filesystem, processes will wait indefinitely (if they've mounted the filesystem hard) until it comes back. – Mark Plotnick Apr 10 '15 at 16:02
0

I have a potential situation where independent and external hardware can modify a filesystem which is already mounted and in-use on Linux.

This is impossible with a local filesystem like Ext4. It's not designed to handle changes that it did not handled by itself, it cannot reconciliate them with its own (memory-based) view of what's on disk.

Even if your Ext4 filesystem is mounted read-only and your external hardware modifies it, it will not work. From an architectural point of view, the only way it could work would require to unmount explicitly the ext4 filesystem, let the external hardware modify it, then mount it again - and only in that sequence. There's no way around this.

@Mark Plotnick has a good suggestion : you have a distributed problem, go solve it with filesystems which handle concurrent accesses, the simplest one being NFS. It still comes with nasty cache/coherency problem, you will have to understand them and configure NFS to your liking.

  • Another solution might be to go with a system that handles filesystem suspension, eg FreeBSD. There you can tell the kernel "don't touch that filesystem, I need to modify it", and the kernel will then flush the cache and pause writes (make them kind of hang) until the suspension is released; then it will reread everything from disk and allow the writes to continue. This is used for online growfs (man.freebsd.org/growfs), for example. – Edward Tomasz Napierala Jun 30 '17 at 10:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.