All of lore.kernel.org
 help / color / mirror / Atom feed
* autofs changes process's current working directory
@ 2009-09-07 11:36 Antonio Messina
  2009-10-09  5:58 ` Ian Kent
  0 siblings, 1 reply; 7+ messages in thread
From: Antonio Messina @ 2009-09-07 11:36 UTC (permalink / raw)
  To: autofs


[-- Attachment #1.1: Type: text/plain, Size: 3341 bytes --]

Hi all,

I'm experiencing a problem with autofs. It seems that when a process
is inside an automounted nfs filesystem, if I restart the automount
daemon the current working directory of the process is changed and a
few leading directory are removed leading to a non-existent cwd.

I have to say, however, that the process will continue to see the
current directory: for instance, if we are running a shell, a "ls"
will gives you the correct answer, I can edit files (but vi
complains about not finding the file when saving) and the "pwd"
command returns the right directory.

In order to reproduce the problem I've wrote a very simple program:

#include <unistd.h>
#include <stdio.h>
#include <sys/stat.h>

int main(){
  /* check if the current directory is right */
  char lpath[1024];
  int res;
  getcwd(lpath, 1024);
  res = access(lpath,F_OK);
  if(0 != res)
      printf("Error! My CWD is %s but it doens't exists!\n", lpath);
  else
      printf("My CWD is %s and it exists\n", lpath);
  return res;
}


a simple session follows:

[root@pc-amessina ~]# cd /home/RAID3-D3/vmware
[root@pc-amessina vmware]# ~/cwdcheck
My CWD is /home/RAID3-D3/vmware and it exists
[root@pc-amessina vmware]# service autofs restart
Stopping autofs:                                                [  OK  ]
Starting autofs:                                                [  OK  ]
[root@pc-amessina vmware]# ~/cwdcheck
Error! My CWD is /vmware but it doens't exists!


My auto.master is:

/home /etc/auto.home  -rw,soft,intr,rsize=8192,wsize=8192,sync

my auto.home is very long but the relevant line is:

RAID3-D3 climaserv3:/RAID3/D3

(we mount a few different filesystems from the climaserv3 machine,
but they are exported separately by the server)

My system is:

[root@pc-amessina ~]# uname -a
Linux pc-amessina.ictp.it 2.6.24.7-desktop-2mnb #1 SMP Thu Oct 30
18:03:14 EDT 2008 i686 Intel(R) Core(TM)2 Duo CPU     E8400  @
3.00GHz GNU/Linux

[root@pc-amessina ~]# cat /etc/redhat-release
Mandriva Linux release 2008.1 (Official) for i586

[root@pc-amessina ~]# rpm -q autofs
autofs-5.0.4-7mdv2008.1


Logs from automount follows:

Sep  3 12:55:33 localhost automount[11856]: Starting automounter
version 5.0.4, master map auto.master
Sep  3 12:55:33 localhost automount[11856]: using kernel protocol
version 5.00
Sep  3 12:55:33 localhost automount[11856]: mounted indirect on
/home with timeout 900, freq 225 seconds
Sep  3 12:55:53 localhost automount[11856]: attempting to mount
entry /home/RAID3-D3
Sep  3 12:55:53 localhost automount[11856]: mount(nfs): mounted
climaserv3:/RAID3/D3 on /home/RAID3-D3
Sep  3 12:55:53 localhost automount[11856]: mounted /home/RAID3-D3
Sep  3 12:55:59 localhost automount[11856]: 1 remaining in /home
Sep  3 12:55:59 localhost automount[11856]: filesystem /home still busy
Sep  3 12:56:04 localhost automount[11915]: Starting automounter
version 5.0.4, master map auto.master
Sep  3 12:56:04 localhost automount[11915]: using kernel protocol
version 5.00
Sep  3 12:56:04 localhost automount[11915]: mounted indirect on
/home with timeout 900, freq 225 seconds
Sep  3 12:56:09 localhost automount[11915]: attempting to mount
entry /home/RAID3-D3
Sep  3 12:56:09 localhost automount[11915]: mount(nfs): mounted
climaserv3:/RAID3/D3 on /home/RAID3-D3
Sep  3 12:56:09 localhost automount[11915]: mounted /home/RAID3-D3

[-- Attachment #1.2: Type: text/html, Size: 3784 bytes --]

[-- Attachment #2: Type: text/plain, Size: 140 bytes --]

_______________________________________________
autofs mailing list
autofs@linux.kernel.org
http://linux.kernel.org/mailman/listinfo/autofs

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: autofs changes process's current working directory
  2009-09-07 11:36 autofs changes process's current working directory Antonio Messina
@ 2009-10-09  5:58 ` Ian Kent
  2009-12-14 17:28   ` Leonardo Chiquitto
  0 siblings, 1 reply; 7+ messages in thread
From: Ian Kent @ 2009-10-09  5:58 UTC (permalink / raw)
  To: Antonio Messina; +Cc: autofs

Antonio Messina wrote:
> Hi all,
> 
> I'm experiencing a problem with autofs. It seems that when a process
> is inside an automounted nfs filesystem, if I restart the automount
> daemon the current working directory of the process is changed and a
> few leading directory are removed leading to a non-existent cwd.

That's right.

It's because, with older user space and kernel, the mount is detached
from the mount tree by a "umount -l" at restart when trying to cleanup
stale mounts.

Note that this is a non-trivial problem and took a long time to fix.

What autofs and kernel are you using?

> 
> I have to say, however, that the process will continue to see the
> current directory: for instance, if we are running a shell, a "ls"
> will gives you the correct answer, I can edit files (but vi
> complains about not finding the file when saving) and the "pwd"
> command returns the right directory.

Yes, but it depends on what you do.

A "cd ." in a shell will fix things but that's not much help for binary
applications that cannot be changed. You really have no choice but to
update to a user space and kernel that fixes this.

That isn't without it's own set of problems though. Such as, a restart
will happily "re-connect" to a pre-existing mount to a dead server.
People used to "kill -9" the daemon and just start autofs again to fix
this type of problem and init script options "forcestart" and
"forcerestart" were added to allow the previous broken behaviour to be used.

> 
> In order to reproduce the problem I've wrote a very simple program:
> 
> #include <unistd.h>
> #include <stdio.h>
> #include <sys/stat.h>
> 
> int main(){
>   /* check if the current directory is right */
>   char lpath[1024];
>   int res;
>   getcwd(lpath, 1024);
>   res = access(lpath,F_OK);
>   if(0 != res)
>       printf("Error! My CWD is %s but it doens't exists!\n", lpath);
>   else
>       printf("My CWD is %s and it exists\n", lpath);
>   return res;
> }
> 
> 
> a simple session follows:
> 
> [root@pc-amessina ~]# cd /home/RAID3-D3/vmware
> [root@pc-amessina vmware]# ~/cwdcheck
> My CWD is /home/RAID3-D3/vmware and it exists
> [root@pc-amessina vmware]# service autofs restart
> Stopping autofs:                                                [  OK  ]
> Starting autofs:                                                [  OK  ]
> [root@pc-amessina vmware]# ~/cwdcheck
> Error! My CWD is /vmware but it doens't exists!
> 
> 
> My auto.master is:
> 
> /home /etc/auto.home  -rw,soft,intr,rsize=8192,wsize=8192,sync
> 
> my auto.home is very long but the relevant line is:
> 
> RAID3-D3 climaserv3:/RAID3/D3
> 
> (we mount a few different filesystems from the climaserv3 machine,
> but they are exported separately by the server)
> 
> My system is:
> 
> [root@pc-amessina ~]# uname -a
> Linux pc-amessina.ictp.it 2.6.24.7-desktop-2mnb #1 SMP Thu Oct 30
> 18:03:14 EDT 2008 i686 Intel(R) Core(TM)2 Duo CPU     E8400  @
> 3.00GHz GNU/Linux
> 
> [root@pc-amessina ~]# cat /etc/redhat-release
> Mandriva Linux release 2008.1 (Official) for i586
> 
> [root@pc-amessina ~]# rpm -q autofs
> autofs-5.0.4-7mdv2008.1
> 
> 
> Logs from automount follows:
> 
> Sep  3 12:55:33 localhost automount[11856]: Starting automounter
> version 5.0.4, master map auto.master
> Sep  3 12:55:33 localhost automount[11856]: using kernel protocol
> version 5.00
> Sep  3 12:55:33 localhost automount[11856]: mounted indirect on
> /home with timeout 900, freq 225 seconds
> Sep  3 12:55:53 localhost automount[11856]: attempting to mount
> entry /home/RAID3-D3
> Sep  3 12:55:53 localhost automount[11856]: mount(nfs): mounted
> climaserv3:/RAID3/D3 on /home/RAID3-D3
> Sep  3 12:55:53 localhost automount[11856]: mounted /home/RAID3-D3
> Sep  3 12:55:59 localhost automount[11856]: 1 remaining in /home
> Sep  3 12:55:59 localhost automount[11856]: filesystem /home still busy
> Sep  3 12:56:04 localhost automount[11915]: Starting automounter
> version 5.0.4, master map auto.master
> Sep  3 12:56:04 localhost automount[11915]: using kernel protocol
> version 5.00
> Sep  3 12:56:04 localhost automount[11915]: mounted indirect on
> /home with timeout 900, freq 225 seconds
> Sep  3 12:56:09 localhost automount[11915]: attempting to mount
> entry /home/RAID3-D3
> Sep  3 12:56:09 localhost automount[11915]: mount(nfs): mounted
> climaserv3:/RAID3/D3 on /home/RAID3-D3
> Sep  3 12:56:09 localhost automount[11915]: mounted /home/RAID3-D3
> 
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> autofs mailing list
> autofs@linux.kernel.org
> http://linux.kernel.org/mailman/listinfo/autofs

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: autofs changes process's current working directory
  2009-10-09  5:58 ` Ian Kent
@ 2009-12-14 17:28   ` Leonardo Chiquitto
  2009-12-14 18:14     ` Ian Kent
  0 siblings, 1 reply; 7+ messages in thread
From: Leonardo Chiquitto @ 2009-12-14 17:28 UTC (permalink / raw)
  To: autofs

>> I'm experiencing a problem with autofs. It seems that when a process
>> is inside an automounted nfs filesystem, if I restart the automount
>> daemon the current working directory of the process is changed and a
>> few leading directory are removed leading to a non-existent cwd.
>
> That's right.
>
> It's because, with older user space and kernel, the mount is detached
> from the mount tree by a "umount -l" at restart when trying to cleanup
> stale mounts.
>
> Note that this is a non-trivial problem and took a long time to fix.
>
> What autofs and kernel are you using?

Ian,

I'm also getting this problem on 2.6.31 with autofs-5.0.4. Please, do you
remember when the fix was committed? Is this related to some (new)
configuration option?

Thanks!
Leonardo

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: autofs changes process's current working directory
  2009-12-14 17:28   ` Leonardo Chiquitto
@ 2009-12-14 18:14     ` Ian Kent
  2009-12-14 19:22       ` Leonardo Chiquitto
  2009-12-14 22:07       ` michael
  0 siblings, 2 replies; 7+ messages in thread
From: Ian Kent @ 2009-12-14 18:14 UTC (permalink / raw)
  To: Leonardo Chiquitto; +Cc: autofs

Leonardo Chiquitto wrote:
>>> I'm experiencing a problem with autofs. It seems that when a process
>>> is inside an automounted nfs filesystem, if I restart the automount
>>> daemon the current working directory of the process is changed and a
>>> few leading directory are removed leading to a non-existent cwd.
>> That's right.
>>
>> It's because, with older user space and kernel, the mount is detached
>> from the mount tree by a "umount -l" at restart when trying to cleanup
>> stale mounts.
>>
>> Note that this is a non-trivial problem and took a long time to fix.
>>
>> What autofs and kernel are you using?
> 
> Ian,
> 
> I'm also getting this problem on 2.6.31 with autofs-5.0.4. Please, do you
> remember when the fix was committed? Is this related to some (new)
> configuration option?

Have a look at your init script and the installed autofs configuration.

Basically you need /dev/autofs to exist (created when the autofs4 kernel
module is loaded) and that's about it. But the init script may be
removing it because it thinks you don't want to use it.

Ian

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: autofs changes process's current working directory
  2009-12-14 18:14     ` Ian Kent
@ 2009-12-14 19:22       ` Leonardo Chiquitto
  2009-12-14 22:07       ` michael
  1 sibling, 0 replies; 7+ messages in thread
From: Leonardo Chiquitto @ 2009-12-14 19:22 UTC (permalink / raw)
  To: autofs

>> I'm also getting this problem on 2.6.31 with autofs-5.0.4. Please, do you
>> remember when the fix was committed? Is this related to some (new)
>> configuration option?
>
> Have a look at your init script and the installed autofs configuration.
>
> Basically you need /dev/autofs to exist (created when the autofs4 kernel
> module is loaded) and that's about it. But the init script may be
> removing it because it thinks you don't want to use it.

Thanks, Ian. You're absolutely right. The feature/fix is there since 2.6.28
and AutoFS 5.0.4 but my distribution initscript incorrectly assumes that
the kernel doesn't support the misc device and removes /dev/autofs.

Thanks again,
Leonardo

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: autofs changes process's current working directory
  2009-12-14 18:14     ` Ian Kent
  2009-12-14 19:22       ` Leonardo Chiquitto
@ 2009-12-14 22:07       ` michael
  2009-12-15  1:18         ` Ian Kent
  1 sibling, 1 reply; 7+ messages in thread
From: michael @ 2009-12-14 22:07 UTC (permalink / raw)
  To: autofs

On 12/14/2009 11:14 AM, Ian Kent wrote:
> Leonardo Chiquitto wrote:
>>>> I'm experiencing a problem with autofs. It seems that when a process
>>>> is inside an automounted nfs filesystem, if I restart the automount
>>>> daemon the current working directory of the process is changed and a
>>>> few leading directory are removed leading to a non-existent cwd.
>>> That's right.
>>>
>>> It's because, with older user space and kernel, the mount is detached
>>> from the mount tree by a "umount -l" at restart when trying to cleanup
>>> stale mounts.
>>>
>>> Note that this is a non-trivial problem and took a long time to fix.
>>>
>>> What autofs and kernel are you using?
>>
>> Ian,
>>
>> I'm also getting this problem on 2.6.31 with autofs-5.0.4. Please, do you
>> remember when the fix was committed? Is this related to some (new)
>> configuration option?
>
> Have a look at your init script and the installed autofs configuration.
>
> Basically you need /dev/autofs to exist (created when the autofs4 kernel
> module is loaded) and that's about it. But the init script may be
> removing it because it thinks you don't want to use it.


Hi Ian,

Are you aware of any work to back port these changes into ~2.6.16?  I am 
using an enterprise distribution and this issue is causing us problems.

Michael

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: autofs changes process's current working directory
  2009-12-14 22:07       ` michael
@ 2009-12-15  1:18         ` Ian Kent
  0 siblings, 0 replies; 7+ messages in thread
From: Ian Kent @ 2009-12-15  1:18 UTC (permalink / raw)
  To: michael@kmaclub.com; +Cc: autofs

michael@kmaclub.com wrote:
> On 12/14/2009 11:14 AM, Ian Kent wrote:
>> Leonardo Chiquitto wrote:
>>>>> I'm experiencing a problem with autofs. It seems that when a process
>>>>> is inside an automounted nfs filesystem, if I restart the automount
>>>>> daemon the current working directory of the process is changed and a
>>>>> few leading directory are removed leading to a non-existent cwd.
>>>> That's right.
>>>>
>>>> It's because, with older user space and kernel, the mount is detached
>>>> from the mount tree by a "umount -l" at restart when trying to cleanup
>>>> stale mounts.
>>>>
>>>> Note that this is a non-trivial problem and took a long time to fix.
>>>>
>>>> What autofs and kernel are you using?
>>>
>>> Ian,
>>>
>>> I'm also getting this problem on 2.6.31 with autofs-5.0.4. Please, do
>>> you
>>> remember when the fix was committed? Is this related to some (new)
>>> configuration option?
>>
>> Have a look at your init script and the installed autofs configuration.
>>
>> Basically you need /dev/autofs to exist (created when the autofs4 kernel
>> module is loaded) and that's about it. But the init script may be
>> removing it because it thinks you don't want to use it.
> 
> 
> Hi Ian,
> 
> Are you aware of any work to back port these changes into ~2.6.16?  I am
> using an enterprise distribution and this issue is causing us problems.

Not sure but the patches are in the 5.0.4 tar.
There are a couple of bug fixes but nothing major.

It's present in RHEL-5.4.

Ian

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2009-12-15  1:18 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-07 11:36 autofs changes process's current working directory Antonio Messina
2009-10-09  5:58 ` Ian Kent
2009-12-14 17:28   ` Leonardo Chiquitto
2009-12-14 18:14     ` Ian Kent
2009-12-14 19:22       ` Leonardo Chiquitto
2009-12-14 22:07       ` michael
2009-12-15  1:18         ` Ian Kent

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.