2007-05-22 10:37:40

by Tomasz Chmielewski

[permalink] [raw]
Subject: how to execute a script from NFS mount (which disconnected)?

This question may sound silly, but I didn't find a proper solution to it.

I have a script on a NFS share. The purpose of this script is to do some
network reconfiguration for Xen.

Unfortunately, it fails to execute somewhere in the middle.

Basically, the script brings the network interface down, does a bit of
reconfiguring, and then, the interface is brought up.


In a short form, the script looks like that:

#!/bin/bash

echo Start

ifdown bond0

echo Step 1...
sleep 4s

echo Step 2...
sleep 4s

echo Step 3...
sleep 4s

echo Step 4...
sleep 4s

echo Step 5...
sleep 4s

ifup bond0

echo End



Unfortunately, when I execute it locally, the script freezes somewhere
about step 2 or 3. Which I could perfectly understand - as the system
can't read it.
But I did a "cat script" just before running it - so the system should
have it cached, right?
Sometimes only, the script executes fully.


How can I execute a script from NSF mount - a script which reconfigures
a network interface, and there is a period of network disconnection?


--
Tomasz Chmielewski
http://wpkg.org

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs


2007-05-22 12:10:21

by Trond Myklebust

[permalink] [raw]
Subject: Re: how to execute a script from NFS mount (which disconnected)?

On Tue, 2007-05-22 at 12:37 +0200, Tomasz Chmielewski wrote:
> How can I execute a script from NSF mount - a script which reconfigures
> a network interface, and there is a period of network disconnection?

Copy it to a RAMFS partition and execute it there.

Trond


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

2007-05-22 12:18:06

by Tomasz Chmielewski

[permalink] [raw]
Subject: Re: how to execute a script from NFS mount (which disconnected)?

Trond Myklebust schrieb:
> On Tue, 2007-05-22 at 12:37 +0200, Tomasz Chmielewski wrote:
>> How can I execute a script from NSF mount - a script which reconfigures
>> a network interface, and there is a period of network disconnection?
>
> Copy it to a RAMFS partition and execute it there.

No, that's not a good solution. Or a solution I would want to use.

I use the same script on systems having rootfs on iSCSI. And they also
disconnect for a brief period of time.
There, everything works properly if I just "preload"/cache the
script/programs with something like:

cat script &>/dev/null
program --help &>/dev/null

Then, I can disconnect the station for several minutes, but the system
will have the programs/scripts cached, and will be able to use them.


I would like to do something similar with NFS. Isn't there a
"disconnected" mode for NSF (or "cached", etc.)?


--
Tomasz Chmielewski
http://wpkg.org

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

2007-05-22 12:26:02

by Jeff Layton

[permalink] [raw]
Subject: Re: how to execute a script from NFS mount (which disconnected)?

On Tue, 22 May 2007 14:17:49 +0200
Tomasz Chmielewski <[email protected]> wrote:

> Trond Myklebust schrieb:
> > On Tue, 2007-05-22 at 12:37 +0200, Tomasz Chmielewski wrote:
> >> How can I execute a script from NSF mount - a script which reconfigures
> >> a network interface, and there is a period of network disconnection?
> >
> > Copy it to a RAMFS partition and execute it there.
>
> No, that's not a good solution. Or a solution I would want to use.
>
> I use the same script on systems having rootfs on iSCSI. And they also
> disconnect for a brief period of time.
> There, everything works properly if I just "preload"/cache the
> script/programs with something like:
>
> cat script &>/dev/null
> program --help &>/dev/null
>
> Then, I can disconnect the station for several minutes, but the system
> will have the programs/scripts cached, and will be able to use them.
>
>
> I would like to do something similar with NFS. Isn't there a
> "disconnected" mode for NSF (or "cached", etc.)?
>

Nope. NFS will (likely) want to check the attributes on the file to make sure
it's not changed before executing it. Copying it to a secondary location is
what you'll want to do.

<idle speculation>
I wonder if you could do something like this on NFSv4 with delegations?
</idle speculation>

>
> --
> Tomasz Chmielewski
> http://wpkg.org
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> NFS maillist - [email protected]
> https://lists.sourceforge.net/lists/listinfo/nfs
>


--
Jeff Layton <[email protected]>

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

2007-05-22 12:29:53

by Jeff Layton

[permalink] [raw]
Subject: Re: how to execute a script from NFS mount (which disconnected)?

On Tue, 22 May 2007 08:25:54 -0400
Jeff Layton <[email protected]> wrote:

> On Tue, 22 May 2007 14:17:49 +0200
> Tomasz Chmielewski <[email protected]> wrote:
>
> > Trond Myklebust schrieb:
> > > On Tue, 2007-05-22 at 12:37 +0200, Tomasz Chmielewski wrote:
> > >> How can I execute a script from NSF mount - a script which reconfigures
> > >> a network interface, and there is a period of network disconnection?
> > >
> > > Copy it to a RAMFS partition and execute it there.
> >
> > No, that's not a good solution. Or a solution I would want to use.
> >
> > I use the same script on systems having rootfs on iSCSI. And they also
> > disconnect for a brief period of time.
> > There, everything works properly if I just "preload"/cache the
> > script/programs with something like:
> >
> > cat script &>/dev/null
> > program --help &>/dev/null
> >
> > Then, I can disconnect the station for several minutes, but the system
> > will have the programs/scripts cached, and will be able to use them.
> >
> >
> > I would like to do something similar with NFS. Isn't there a
> > "disconnected" mode for NSF (or "cached", etc.)?
> >
>
> Nope. NFS will (likely) want to check the attributes on the file to make sure
> it's not changed before executing it. Copying it to a secondary location is
> what you'll want to do.
>
> <idle speculation>
> I wonder if you could do something like this on NFSv4 with delegations?
> </idle speculation>
>

If it's falling down in the middle of execution, however, the problem may be
that the path or something is crossing onto an NFS mount, or it could be
hanging on something like NIS. You may want to try stracing it to see what
system call it's trying to execute when the hang occurs...

> >
> > --
> > Tomasz Chmielewski
> > http://wpkg.org
> >
> > -------------------------------------------------------------------------
> > This SF.net email is sponsored by DB2 Express
> > Download DB2 Express C - the FREE version of DB2 express and take
> > control of your XML. No limits. Just data. Click to get it now.
> > http://sourceforge.net/powerbar/db2/
> > _______________________________________________
> > NFS maillist - [email protected]
> > https://lists.sourceforge.net/lists/listinfo/nfs
> >
>
>
> --
> Jeff Layton <[email protected]>
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> NFS maillist - [email protected]
> https://lists.sourceforge.net/lists/listinfo/nfs
>


--
Jeff Layton <[email protected]>

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

2007-05-22 12:41:55

by Trond Myklebust

[permalink] [raw]
Subject: Re: how to execute a script from NFS mount (which disconnected)?

On Tue, 2007-05-22 at 14:17 +0200, Tomasz Chmielewski wrote:
> Trond Myklebust schrieb:
> > On Tue, 2007-05-22 at 12:37 +0200, Tomasz Chmielewski wrote:
> >> How can I execute a script from NSF mount - a script which reconfigures
> >> a network interface, and there is a period of network disconnection?
> >
> > Copy it to a RAMFS partition and execute it there.
>
> No, that's not a good solution. Or a solution I would want to use.
>
> I use the same script on systems having rootfs on iSCSI. And they also
> disconnect for a brief period of time.
> There, everything works properly if I just "preload"/cache the
> script/programs with something like:
>
> cat script &>/dev/null
> program --help &>/dev/null
>
> Then, I can disconnect the station for several minutes, but the system
> will have the programs/scripts cached, and will be able to use them.
>
>
> I would like to do something similar with NFS. Isn't there a
> "disconnected" mode for NSF (or "cached", etc.)?

Feel free to write one. Otherwise, the only solution I can propose for
you is the one I just mentioned.

Trond


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

2007-05-22 12:42:33

by NeilBrown

[permalink] [raw]
Subject: Re: how to execute a script from NFS mount (which disconnected)?

On Tuesday May 22, [email protected] wrote:
> This question may sound silly, but I didn't find a proper solution to it.
>
> I have a script on a NFS share. The purpose of this script is to do some
> network reconfiguration for Xen.
>
> Unfortunately, it fails to execute somewhere in the middle.
>
> Basically, the script brings the network interface down, does a bit of
> reconfiguring, and then, the interface is brought up.
...
>
>
> Unfortunately, when I execute it locally, the script freezes somewhere
> about step 2 or 3. Which I could perfectly understand - as the system
> can't read it.

Not really. bash reads the whole script before executing it - or at
least it did in my limited tests. strace would confirm.

My guess is that your $PATH includes a directory that is on the NFS
mounted volume - so when bash looks for e.g. 'sleep', it looks on the
NFS mounted volume and hangs.
Try running the script with "strace -f". It might be noisy, but it
will show you what is blocking.

NeilBrown

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs