On Fri, May 19, 2017 at 08:17:55AM +0800, Anand Jain wrote: > > XFS already logs its own unmounts. > > Nice. as far as I know its only in XFS. Ext4 logs mounts, but not unmounts. > > I prefer to let each filesystem log > > its own unmount, because then the mount/unmount messages also have the > > same prefix as all other messages coming from that filesystem driver. > > Ok. One nitpick though there are other mount types (remount, bind..), > and subsequent mounts of the same FS and FS driver can't log them > effectively. The other issue is there is a difference between when an unmount is started, or when a file system is unmounted in one namespace, and when the file system as a whole is unmounted by the low-level because there are no longer any references to the file system in any namespace. More than once I've gotten a bug report for ext4 that was really caused by the fact that some program had forked a daemon process in its own namespace, so when the USB thumbdrive was unmounted, it wasn't *really* unmounted. So being able to clearly express that in the logs is also a good thing. I think the way to do that is to have one set of logs for when the file system is unmounted from one mount namespace (or from a bind mount), with perhaps an indication of the number of remaining refcounts, and to make this be distinct from the unmount of the underlying low file system code, which should be logged by the file system code itself. - Ted