-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for autofs "strictexpire" option #18445
Comments
Fyi, The questions that need to be answered are should the strictexpire option be used unconditionally and are there any cases where it could cause a problem? The answer to the later question should be, probably no, there shouldn't be a problem expiring a mount even though it has been recently accessed. The answer to the former question isn't quite so straight forward because some users might see increased umount/mount behaviour they don't expect and don't much like. The default behaviour is to reset the last_used counter on any access. The strictexpire autofs mount option changes the expire checking behaviour so that the last_used counter isn't updated on any access so that only mounts that are actually in use, such as when there is an open file or a process working directory within the automounted mount. Neither the default behaviour nor the strictexpire behaviour satisfies everyone which is why there is an option to change the behaviour. The default behaviour ensures that mounts that are being used in some way don't expire only to be mounted again shortly afterwards. This has the effect of mounts not expiring when people think they should and can lead to an accumulation of automounted mounts that won't expire because they are being accessed more frequently than the expire timeout. The strictexpire option avoids these accesses from keeping the automount from expiring. |
Did you verify that the using strictexpire option actually does resolve your problem? |
@raven-au I agree that strictexpire option shouldn't be used unconditionally. That's why I propose to add an option to the [Automount] section, and leave the choice to the end user.
Sorry, I'm not familiar with this. Since systemd does not expose the strictexpire option, how can I verify that? |
Yes, I saw that after posting when I looked at this again.
Ok, I was asking if you had made a change to systemd to test whether using the option actually resolved the mount not expiring. If you're not able to do that it's fine I just wanted to know, partly because I had observed mounts not expiring a while ago and I didn't think it was because of accesses updating the last_used field. I'm not familiar with the unit option processing so that's something I would need to work out if I was to try and propose changes to add this functionality. I'm also curious what others think about this request. |
I guess an alternative to checking if the change helps would be a little more about how you concluded the cause was the node-exporter filesystem collector that is accessing the mount more frequently than the expire timeout. |
Ok, so this node-exporter is a file system monitoring system. The strictexpire option can be used for this purpose if it isn't possible to instruct the monitoring system not look at these mounts or if it isn't sensible to exclude them for some reason. |
I use |
I'm not sure adding this option will behave the way you hope it will. statfs(2) is one of the stat like functions (I think the only one) that triggers an automount. There is an argument that, because it wants information about the file system there, and the autofs file system information is essentially meaningless, it should trigger an automount. So the strictexpire option will probably allow it to expire only to be mounted again on the next statfs access. I'm not sure that's the behaviour your looking for? |
I've verified that if the autofs is mounted but the actual filesystem is not, node-exporter will not trigger the mount. Maybe it will not issue statfs if the actual filesystem is not mounted. |
Ok, I had a quick look at the node-exporter source and it does ignore autofs file system mounts. |
@poettering , @yuwata could I have your thoughts on this request please? |
In recent versions of Gnome (3.38.3), |
I realized that node-exporter has a flag "--collector.filesystem.ignored-mount-points" that can be used to ignore these autofs mount points. And it is sufficient for my use case. But I think the requested feature is still useful in other cases. |
Since #21315 (systemd 250 or later), this can be accomplished with:
So this can be closed now I think? |
Tried this on Fedora 36. Works as expected. /etc/systemd/system/test_temp.automount
/etc/systemd/system/test_temp.mount
|
Just wanted to hijack this issue to thank @huww98 for reporting this curious interaction and sparing me hours of painful debugging. You're a gem! I need to learn a thing or two from your kernel debugging skills. I captured your findings and resolution steps in a Gist which will hopefully appear more easily in search results: https://gist.github.com/Robertof/abfc79660a3140a7c39057abd445e397 |
There's a little more information about this you might be interested in. The problem with statfs() has arisen because it's a stat like system call that was originally missed when other stat like system calls were changed to not trigger automounts when automounting support was added to the VFS (actually I think it was already a problem but that's a different thing). This can't be fixed because now it's expected behaviour and the VFS maintainer won't allow it to be changed. |
Hey @raven-au, this is really great context - thank you! I've added it to the Gist as an insightful tidbit. It's quite interesting! The autofs docs only mention |
Most stat like system calls will have something like this (it's changed over the years):
which essentially prevents automounting during the path walk. But statfs() has this: unsigned int lookup_flags = LOOKUP_FOLLOW|LOOKUP_AUTOMOUNT; which explicitly enables automounting during the path walk. That's pretty much all there is to it. It was because of this problem (at least a large part of the reason) that the strictexpire option was added. |
That makes a lot of sense. Thank you so much Ian for taking the time to share your wisdom! |
Is your feature request related to a problem? Please describe.
When using automount unit, I found the mount point is not unmounted when TimeoutIdleSec expires. I figured out that it is node-exporter filesystem collector that resets the
last_used
field in astatfs
system call. This can be avoided by specifying "strictexpire" option.Describe the solution you'd like
Add a StrictExpire option to [Automount] section in
.automount
unit file. And addstrictexpire
to this linesystemd/src/core/automount.c
Line 596 in e3f87b0
Describe alternatives you've considered
Add an AutofsOptions config to [Automount] section, allowing specifying arbitrary options, just like Options in [Mount] section.
For anyone who may be interested in this, Here is the call stack of the
last_used
field reset, gathered fromperf
The text was updated successfully, but these errors were encountered: