The fastest way to detect legacy Samba mounts on Linux

What is the best (fastest) way to determine if a Samba mount point is dead on Linux? I need to do this in C. System calls such as statfs (), statvfs () for 30-40 seconds when the legacy mount is called, in which case they don't even return an error. It seems that stat () is faster than the others (about 10 seconds) and returns an error. The mount point may be deprecated because another host has dropped or the Samba daemon has been killed. Any advice is appreciated.

+4
source share
3 answers

I answer my question. The goal was to minimize the time spent by several processes trying to access obsolete mount points. Typically, system calls will be completed within a subsecond. Blocking outdated stocks for 10 seconds or even, say, 3 seconds was unacceptable, because these calls are made in several places, several times and the delay time accumulates. So, I ended up writing a monitoring process that checks the mount every n seconds and disables them if they are not available. I also read information from my configurations, saying which file systems should be deleted (mounted) and check the mtab file - if they are not there, this is an error. The mtab code check completes within a subsecond. Took a day or two to implement, but works great for me.

0
source

You can set an alarm (see alarm() and setitimer() ), which expires in a few seconds.

+1
source

Well, I don’t know how to do a faster check, but I can offer you to check all mount points at the same time in parallel, so you will always have the same total time, even with many samba mounts.

0
source

Source: https://habr.com/ru/post/1298942/


All Articles