Skip to contentSkip to conversation

AutoFS Race Conditions? Negative Cache?

DISCUSSION Michael Loftis 2 participants 9 messages Jan 27, 2009 – Feb 3, 2009 Kernel automounter

lore
Share & tools
lore
#0 lore raw

First, I'm sorry if you guys have answered any of this before but since there's no public archives (the link on the kernel.org mailman interface gets me an apache permission denied error) I'm not able to search them.

Debian 4.0, 2.6.18-6-686 (2.6.18.dfsg.1-23etch1) kernel, autofs 4.1.4-13

IS there any negative cache in AutoFS? I ask because I appear to be seeing repetitive calls to mount things that had already failed. This is using a wildcard map (full deployment, if we can make the automounter work at all won't be using a wildcard map).

I keep seeing multiple mounts for the same place, AutoFS appears to race itself a lot under high loads.

Is it expected behavior that autofs gets called for EVERY miss under the autofs tree? I would think not, but I can't figure out (excepting maybe the race conditions) how a map could cause multiple mount entries except because of race conditions.

for ex (actual domain name changed to protect bystanders): (in /proc/mounts)
nfs0:/www/vhosts/l /d1/l/luserdomain.org/logs nfs rw,vers=3,rsize=8192,wsize=8192,hard,intr,proto=udp,timeo=11,retrans=2,sec=sys,addr=nfs0 0 0
/dev/hda3 /d1/l/luserdomain.org/logs/.renv ext3 rw,noatime,data=ordered 0 0

== auto.master ==
/d1/0 /etc/auto.jail -strict -DH=0
/d1/1 /etc/auto.jail -strict -DH=1
...
/d1/z /etc/auto.jail -strict -DH=z

== auto.jail ==
* / :/www/vhosts/${H}/& /.renv :/opt/jail

so how does that possibly end up with mounts like I'd shown above? I was under the impression that autofs4 would only ever call automounter with a single key...for right now the source of the mounts is an nfs tree, there are symlinks to other NFS mounts. the bind mount mechanism works for now. The reason I'm deploying this way and not with a static map is our management software does not yet have the bits to modify a (LDAP) map, but if it won't work for this proof of concept, I'm not sure it'll work at all.

Any help/guidance/wisdom/etc would be appreciated.

Signature · 3 lines
"Genius might be described as a supreme capacity for getting its possessors
into trouble of all kinds."
-- Samuel Butler
maintainer
#1 lore raw
Quoted 11 lines · Michael Loftis

First, I'm sorry if you guys have answered any of this before but since there's no public archives (the link on the kernel.org mailman interface gets me an apache permission denied error) I'm not able to search them.

Debian 4.0, 2.6.18-6-686 (2.6.18.dfsg.1-23etch1) kernel, autofs 4.1.4-13

IS there any negative cache in AutoFS? I ask because I appear to be seeing repetitive calls to mount things that had already failed. This is using a wildcard map (full deployment, if we can make the automounter work at all won't be using a wildcard map).

Quoted 7 lines

I keep seeing multiple mounts for the same place, AutoFS appears to race itself a lot under high loads.

Is it expected behavior that autofs gets called for EVERY miss under the autofs tree? I would think not, but I can't figure out (excepting maybe the race conditions) how a map could cause multiple mount entries except because of race conditions.

It was quite a long while before we realized that a change to the VFS between kernel 2.4 and 2.6 stopped the kernel module negative caching from working. Trying to re-implement it in the kernel proved to be far to complicated so it was eventually added to the daemon. I haven't updated version 4 for a long time and don't plan to do so as the effort in targeted at version 5 and has been for some time. I don't have time to do both so version 5 gets the effort. Of course, if distribution package maintainers want to update their packages, patches are around and I can help with that effort.

There are other problems with the kernel module in 2.6.18 that appear to give similar symptoms as well. You could try patching the kernel with the latest autofs4 kernel module patches, which can be found in the current version 5 tarball. There is still one issue that I'm aware of that affects version 4 specifically, but I can't yet duplicate it and so can't check if a fix would introduce undesirable side effects.

Quoted 9 lines

for ex (actual domain name changed to protect bystanders): (in /proc/mounts)
nfs0:/www/vhosts/l /d1/l/luserdomain.org/logs nfs rw,vers=3,rsize=8192,wsize=8192,hard,intr,proto=udp,timeo=11,retrans=2,sec=sys,addr=nfs0 0 0
/dev/hda3 /d1/l/luserdomain.org/logs/.renv ext3 rw,noatime,data=ordered 0 0

Quoted 8 lines

== auto.master ==
/d1/0 /etc/auto.jail -strict -DH=0
/d1/1 /etc/auto.jail -strict -DH=1
...
/d1/z /etc/auto.jail -strict -DH=z

== auto.jail ==
* / :/www/vhosts/${H}/& /.renv :/opt/jail

I don't know where these mounts are coming from.
It doesn't look right but we don't know as we don't have a debug log to refer to.

Quoted 11 lines

so how does that possibly end up with mounts like I'd shown above? I was under the impression that autofs4 would only ever call automounter with a single key...for right now the source of the mounts is an nfs tree, there are symlinks to other NFS mounts. the bind mount mechanism works for now. The reason I'm deploying this way and not with a static map is our management software does not yet have the bits to modify a (LDAP) map, but if it won't work for this proof of concept, I'm not sure it'll work at all.

Any help/guidance/wisdom/etc would be appreciated.

#2 lore raw
Quoted 9 lines · --On January 28, 2009 12:30:06 PM +0900 Ian Kent <[email protected]> wrote:

It was quite a long while before we realized that a change to the VFS between kernel 2.4 and 2.6 stopped the kernel module negative caching from working. Trying to re-implement it in the kernel proved to be far to complicated so it was eventually added to the daemon. I haven't updated version 4 for a long time and don't plan to do so as the effort in targeted at version 5 and has been for some time. I don't have time to do both so version 5 gets the effort. Of course, if distribution package maintainers want to update their packages, patches are around and I can help with that effort.

I'll get ahold of the Debian (kernel and autofs) maintainer email addresses and ask them about that. It's not that I/we can't maintain our own kernels and autofs packages, it's just that (atleast for the kernel) it's a pretty high work load on an already thin staff.

Quoted 6 lines

There are other problems with the kernel module in 2.6.18 that appear to give similar symptoms as well. You could try patching the kernel with the latest autofs4 kernel module patches, which can be found in the current version 5 tarball. There is still one issue that I'm aware of that affects version 4 specifically, but I can't yet duplicate it and so can't check if a fix would introduce undesirable side effects.

I understand that. I'm having trouble reproducing this one except under load, which is why I decided it's probably some sort of race condition. And it goes away when i set timeout=0. I'm betting though that with 'current' autofs4 module it may not happen or with 'current' daemon and module. I tried to get autofs5 debian package from sid/lenny (debian unstable/testing) to compile but because it's using some symbols that don't exist in ldap.h from openldap 2.1 it won't compile for Debian 4.0 without a little bit of massaging.

Another problem I ran into was that there's no way to pass the -n flag to mount. I'm probably going to have to make my own autofs4 daemon packages, but is this a feature of autofs5 daemon? The reason I ask is the webservers here well, linking /proc/mounts to /etc/mtab is bad for the same reason, ls takes a few seconds (as do many other things) to execute when there's 12k+ mounts in /etc/mtab (that might be less if we can get timeout's to work but as we don't have any profiles on this...). We'd need this long term for both nfs and bind mounts. It doesn't appear that it's an option in autofs5 either as the call ends up being ::

                err = spawn_bind_mount(ap->logopt,
                             SLOPPYOPT "-o", options, what, fullpath, NULL);
Quoted 17 lines
Quoted 17 lines

for ex (actual domain name changed to protect bystanders): (in /proc/mounts)
nfs0:/www/vhosts/l /d1/l/luserdomain.org/logs nfs rw,vers=3,rsize=8192,wsize=8192,hard,intr,proto=udp,timeo=11,retrans=2,s ec=sys,addr=nfs0 0 0
/dev/hda3 /d1/l/luserdomain.org/logs/.renv ext3 rw,noatime,data=ordered 0 0

== auto.master ==
/d1/0 /etc/auto.jail -strict -DH=0
/d1/1 /etc/auto.jail -strict -DH=1
...
/d1/z /etc/auto.jail -strict -DH=z

Quoted 6 lines
Quoted 2 lines

== auto.jail ==
* / :/www/vhosts/${H}/& /.renv :/opt/jail

I don't know where these mounts are coming from.
It doesn't look right but we don't know as we don't have a debug log to refer to.

I did try that, but there just isn't fast enough disks to get the condition to happen and get the logs. I'll poke with it a bit more though and see if I can get any more useful information, my hunch is it's a race condition on the umount call(s) somehow with multi-mounts.

maintainer
#3 lore raw
Quoted 13 lines · Michael Loftis
Quoted 9 lines · --On January 28, 2009 12:30:06 PM +0900 Ian Kent <[email protected]> wrote:

It was quite a long while before we realized that a change to the VFS between kernel 2.4 and 2.6 stopped the kernel module negative caching from working. Trying to re-implement it in the kernel proved to be far to complicated so it was eventually added to the daemon. I haven't updated version 4 for a long time and don't plan to do so as the effort in targeted at version 5 and has been for some time. I don't have time to do both so version 5 gets the effort. Of course, if distribution package maintainers want to update their packages, patches are around and I can help with that effort.

Quoted 4 lines

I'll get ahold of the Debian (kernel and autofs) maintainer email addresses and ask them about that. It's not that I/we can't maintain our own kernels and autofs packages, it's just that (atleast for the kernel) it's a pretty high work load on an already thin staff.

Understood.

Quoted 8 lines
Quoted 7 lines

There are other problems with the kernel module in 2.6.18 that appear to give similar symptoms as well. You could try patching the kernel with the latest autofs4 kernel module patches, which can be found in the current version 5 tarball. There is still one issue that I'm aware of that affects version 4 specifically, but I can't yet duplicate it and so can't check if a fix would introduce undesirable side effects.

Quoted 8 lines

I understand that. I'm having trouble reproducing this one except under load, which is why I decided it's probably some sort of race condition. And it goes away when i set timeout=0. I'm betting though that with 'current' autofs4 module it may not happen or with 'current' daemon and module. I tried to get autofs5 debian package from sid/lenny (debian unstable/testing) to compile but because it's using some symbols that don't exist in ldap.h from openldap 2.1 it won't compile for Debian 4.0 without a little bit of massaging.

What are the symbols?
Send over the compile breakage output or the Debian source package (I can probably check it out on my Ubuntu test machine).

Quoted 10 lines

Another problem I ran into was that there's no way to pass the -n flag to mount. I'm probably going to have to make my own autofs4 daemon packages, but is this a feature of autofs5 daemon? The reason I ask is the webservers here well, linking /proc/mounts to /etc/mtab is bad for the same reason, ls takes a few seconds (as do many other things) to execute when there's 12k+ mounts in /etc/mtab (that might be less if we can get timeout's to work but as we don't have any profiles on this...). We'd need this long term for both nfs and bind mounts. It doesn't appear that it's an option in autofs5 either as the call ends up being ::

Quoted 2 lines
                err = spawn_bind_mount(ap->logopt,
                             SLOPPYOPT "-o", options, what, fullpath, NULL);

Right, have a look at 5.0.4, those functions will check if /etc/mtab is a link to /proc/mounts and add "-n" to the mount options if it is. I try my best to keep all the individual patches for each version update (at least through the v5 updates) and often they are straight forward to backport.

It's true that there are still bugs in v5, even after more than two years working at it, but as far as I can tell, people generally feel that v5 is much better than v4.

Quoted 31 lines
Quoted 18 lines
Quoted 18 lines

for ex (actual domain name changed to protect bystanders): (in /proc/mounts)
nfs0:/www/vhosts/l /d1/l/luserdomain.org/logs nfs rw,vers=3,rsize=8192,wsize=8192,hard,intr,proto=udp,timeo=11,retrans=2,s ec=sys,addr=nfs0 0 0
/dev/hda3 /d1/l/luserdomain.org/logs/.renv ext3 rw,noatime,data=ordered 0 0

== auto.master ==
/d1/0 /etc/auto.jail -strict -DH=0
/d1/1 /etc/auto.jail -strict -DH=1
...
/d1/z /etc/auto.jail -strict -DH=z

Quoted 6 lines
Quoted 2 lines

== auto.jail ==
* / :/www/vhosts/${H}/& /.renv :/opt/jail

I don't know where these mounts are coming from.
It doesn't look right but we don't know as we don't have a debug log to refer to.

I did try that, but there just isn't fast enough disks to get the condition to happen and get the logs. I'll poke with it a bit more though and see if I can get any more useful information, my hunch is it's a race condition on the umount call(s) somehow with multi-mounts.

#4 lore raw
Quoted 9 lines · --On February 3, 2009 9:45:55 AM +0900 Ian Kent <[email protected]> wrote:
Quoted 8 lines

I understand that. I'm having trouble reproducing this one except under load, which is why I decided it's probably some sort of race condition. And it goes away when i set timeout=0. I'm betting though that with 'current' autofs4 module it may not happen or with 'current' daemon and module. I tried to get autofs5 debian package from sid/lenny (debian unstable/testing) to compile but because it's using some symbols that don't exist in ldap.h from openldap 2.1 it won't compile for Debian 4.0 without a little bit of massaging.

Quoted 3 lines

What are the symbols?
Send over the compile breakage output or the Debian source package (I can probably check it out on my Ubuntu test machine).

Using the autofs5 package from sid and after a few minor massages to get the debhelper stuff into compliance with the older etch dh tools (5.0.3 base, but same errors are present in 5.0.4, same undef-ed symbol) LDAP_CONTROL_PAGEDRESULTS seems to have appeared somewhere eitehr in OpenLDAP 2.2 or in 2.1 after debians libldap2-dev 2.1.30-13.3 packages.

gcc -O2 -Wall -D_REENTRANT -D_FILE_OFFSET_BITS=64 -I../include -I../lib -fPIC -D_GNU_SOURCE -DAUTOFS_LIB_DIR=\"/usr/lib/autofs\" -DAUTOFS_MAP_DIR=\"/etc\" -DLDAP_DEPRECATED=1 -I/usr/include/libxml2 -DLDAP_THREAD_SAFE -c cyrus-sasl.c
gcc -shared -O2 -Wall -D_REENTRANT -D_FILE_OFFSET_BITS=64 -I../include -I../lib -fPIC -D_GNU_SOURCE -DAUTOFS_LIB_DIR=\"/usr/lib/autofs\" -DAUTOFS_MAP_DIR=\"/etc\" -DLDAP_DEPRECATED=1 -I/usr/include/libxml2 -DLDAP_THREAD_SAFE -o lookup_ldap.so \
lookup_ldap.c cyrus-sasl.o ../lib/autofs.a -lldap -llber -lresolv -lsasl2
-L/usr/lib -lxml2 -lcrypto -lkrb5
lookup_ldap.c: In function 'ldap_create_page_control':
lookup_ldap.c:88: error: 'LDAP_CONTROL_PAGEDRESULTS' undeclared (first use in this function)
lookup_ldap.c:88: error: (Each undeclared identifier is reported only once lookup_ldap.c:88: error: for each function it appears in.)
lookup_ldap.c: In function 'ldap_parse_page_control':
lookup_ldap.c:103: error: 'LDAP_CONTROL_PAGEDRESULTS' undeclared (first use in this function)
make[2]: *** [lookup_ldap.so] Error 1
make[2]: Leaving directory `/home/mloftis/dev/autofs/autofs5-5.0.3/modules' make[1]: *** [daemon] Error 2
make[1]: Leaving directory `/home/mloftis/dev/autofs/autofs5-5.0.3'
make: *** [build.stamp] Error 2

Quoted 20 lines
Quoted 12 lines

Another problem I ran into was that there's no way to pass the -n flag to mount. I'm probably going to have to make my own autofs4 daemon packages, but is this a feature of autofs5 daemon? The reason I ask is the webservers here well, linking /proc/mounts to /etc/mtab is bad for the same reason, ls takes a few seconds (as do many other things) to execute when there's 12k+ mounts in /etc/mtab (that might be less if we can get timeout's to work but as we don't have any profiles on this...). We'd need this long term for both nfs and bind mounts. It doesn't appear that it's an option in autofs5 either as the call ends up being :: err = spawn_bind_mount(ap->logopt, SLOPPYOPT "-o", options,

Quoted 1 line
                             what, fullpath, NULL);

Right, have a look at 5.0.4, those functions will check if /etc/mtab is a link to /proc/mounts and add "-n" to the mount options if it is. I try my best to keep all the individual patches for each version update (at least through the v5 updates) and often they are straight forward to backport.

Quoted 3 lines

It's true that there are still bugs in v5, even after more than two years working at it, but as far as I can tell, people generally feel that v5 is much better than v4.

Yeah doing a symlink still has the same problem for us. ls does 'something' that reads /etc/mtab. With our current script which walks our NFS tree and calls mount -n --bind everything is good, so for us we just need to be able to pass -n because we need a short /etc/mtab. -- /root is local btw... and if you strace you can see it walking through /etc/mtab. Other utils, like df too. Granted once we can get timeouts working they'll be a lot shorter but the delay will still be significant. Right now it's carrying ~6k mounts from the old system and the active mounts from the autofs based stuff (again it's not unmounting right now because turning that on caused it to become completely unstable) No symlinks in either, just a few misc files (excluded from here though).

web6:~# pwd
/root
web6:~# time ls
...

real 0m2.051s
user 0m0.016s
sys 0m1.960s

web6:~# wc -l /proc/mounts
15799 /proc/mounts
web5:~# pwd
/root
web5:~# time ls
...

real 0m0.028s
user 0m0.000s
sys 0m0.028s

web5:~# wc -l /proc/mounts
5668 /proc/mounts
Signature · 3 lines
"Genius might be described as a supreme capacity for getting its possessors
into trouble of all kinds."
-- Samuel Butler
maintainer
#5 lore raw
Quoted 16 lines · Michael Loftis
Quoted 9 lines · --On February 3, 2009 9:45:55 AM +0900 Ian Kent <[email protected]> wrote:
Quoted 8 lines

I understand that. I'm having trouble reproducing this one except under load, which is why I decided it's probably some sort of race condition. And it goes away when i set timeout=0. I'm betting though that with 'current' autofs4 module it may not happen or with 'current' daemon and module. I tried to get autofs5 debian package from sid/lenny (debian unstable/testing) to compile but because it's using some symbols that don't exist in ldap.h from openldap 2.1 it won't compile for Debian 4.0 without a little bit of massaging.

Quoted 3 lines

What are the symbols?
Send over the compile breakage output or the Debian source package (I can probably check it out on my Ubuntu test machine).

Quoted 5 lines

Using the autofs5 package from sid and after a few minor massages to get the debhelper stuff into compliance with the older etch dh tools (5.0.3 base, but same errors are present in 5.0.4, same undef-ed symbol) LDAP_CONTROL_PAGEDRESULTS seems to have appeared somewhere eitehr in OpenLDAP 2.2 or in 2.1 after debians libldap2-dev 2.1.30-13.3 packages.

My bad since those functions are defined by autofs if they aren't present I should be checking for the related symbol define.

Does this help?

autofs-5.0.4 - -check LDAP_CONTROL_PAGEDRESULTS defined

From: Ian Kent <[email protected]>

If LDAP_CONTROL_PAGEDRESULTS is not defined in LDAP includes then define it.
---

 modules/lookup_ldap.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
modules/lookup_ldap.c +4 -0
index 6ba80eb..64b4168 100644
@@ -39,6 +39,10 @@
 
 #define MODPREFIX "lookup(ldap): "
 
+#ifndef LDAP_CONTROL_PAGEDRESULTS
+#define LDAP_CONTROL_PAGEDRESULTS "1.2.840.113556.1.4.319" /* RFC 2696 */
+#endif
+
 int lookup_version = AUTOFS_LOOKUP_VERSION;	/* Required by protocol */
 
 static struct ldap_schema common_schema[] = {
maintainer
#6 lore raw
In reply to Michael Loftis
Quoted 24 lines · Michael Loftis
Quoted 20 lines
Quoted 12 lines

Another problem I ran into was that there's no way to pass the -n flag to mount. I'm probably going to have to make my own autofs4 daemon packages, but is this a feature of autofs5 daemon? The reason I ask is the webservers here well, linking /proc/mounts to /etc/mtab is bad for the same reason, ls takes a few seconds (as do many other things) to execute when there's 12k+ mounts in /etc/mtab (that might be less if we can get timeout's to work but as we don't have any profiles on this...). We'd need this long term for both nfs and bind mounts. It doesn't appear that it's an option in autofs5 either as the call ends up being :: err = spawn_bind_mount(ap->logopt, SLOPPYOPT "-o", options,

Quoted 1 line
                             what, fullpath, NULL);

Right, have a look at 5.0.4, those functions will check if /etc/mtab is a link to /proc/mounts and add "-n" to the mount options if it is. I try my best to keep all the individual patches for each version update (at least through the v5 updates) and often they are straight forward to backport.

Quoted 3 lines

It's true that there are still bugs in v5, even after more than two years working at it, but as far as I can tell, people generally feel that v5 is much better than v4.

Quoted 12 lines

Yeah doing a symlink still has the same problem for us. ls does 'something' that reads /etc/mtab. With our current script which walks our NFS tree and calls mount -n --bind everything is good, so for us we just need to be able to pass -n because we need a short /etc/mtab. -- /root is local btw... and if you strace you can see it walking through /etc/mtab. Other utils, like df too. Granted once we can get timeouts working they'll be a lot shorter but the delay will still be significant. Right now it's carrying ~6k mounts from the old system and the active mounts from the autofs based stuff (again it's not unmounting right now because turning that on caused it to become completely unstable) No symlinks in either, just a few misc files (excluded from here though).

Using "-n" is likely a problem for autofs prior to 5.0.4 but would also require the 2.6.28 kernel module patch update for the kernel you are using and you need to tell autofs to use the newly introduced ioctl interface otherwise it will still scan mtab from time to time, expecting it to be up to date.

But, once the above is in place it should be possible to use a "-n" on the mount commands without affecting autofs function. Not sure the best way to provide that though.

Ian

#7 lore raw
Quoted 9 lines · --On February 3, 2009 12:34:36 PM +0900 Ian Kent <[email protected]> wrote:

Using "-n" is likely a problem for autofs prior to 5.0.4 but would also require the 2.6.28 kernel module patch update for the kernel you are using and you need to tell autofs to use the newly introduced ioctl interface otherwise it will still scan mtab from time to time, expecting it to be up to date.

But, once the above is in place it should be possible to use a "-n" on the mount commands without affecting autofs function. Not sure the best way to provide that though.

hmmm food for thought anyway. I'm always leery of moving forward to newer linux kernels, not much of a problem in Debian since they pick a version and keep with it throughout a release. I may or may not have time to dedicated to work with the patch you provided for autofs5 immediately, right now our push is to just get this deployed. I didn't realize the automounter scanned mtab though, so that's good to know.

I greatly appreciate your help Ian, and will let you guys know of any gotchas we run into. It's a pretty odd environment, serving jails for ~10k domains so when something doesn't work right even 1% of the time it's usually pretty obvious.

Quoted 4 lines

Ian

Signature · 3 lines
"Genius might be described as a supreme capacity for getting its possessors
into trouble of all kinds."
-- Samuel Butler
maintainer
#8 lore raw
Quoted 14 lines · Michael Loftis
Quoted 9 lines · --On February 3, 2009 12:34:36 PM +0900 Ian Kent <[email protected]> wrote:

Using "-n" is likely a problem for autofs prior to 5.0.4 but would also require the 2.6.28 kernel module patch update for the kernel you are using and you need to tell autofs to use the newly introduced ioctl interface otherwise it will still scan mtab from time to time, expecting it to be up to date.

But, once the above is in place it should be possible to use a "-n" on the mount commands without affecting autofs function. Not sure the best way to provide that though.

Quoted 6 lines

hmmm food for thought anyway. I'm always leery of moving forward to newer linux kernels, not much of a problem in Debian since they pick a version and keep with it throughout a release. I may or may not have time to dedicated to work with the patch you provided for autofs5 immediately, right now our push is to just get this deployed. I didn't realize the automounter scanned mtab though, so that's good to know.

The main problem arises because we need to check if something is mounted a lot and /proc/mounts can be much larger than the mtab. The kernel update I mention above was needed for another reason but an operation to check mounted-ness was added at the same time to eliminate the need to look at the mtab. You might not need to go to a new kernel but I've only ported this particular patch as far back at 2.6.22 at this stage. I need to do a port back to 2.6.18 at some point soon so maybe that will cover most of the work needed for the in-between version as well. Anyway, it is still a big change so it really is your call as to whether it is worth the effort from yourselves, but this is the story, to the best of my knowledge anyway.

Ian