2004-05-24 17:16:08

by David Dougall

[permalink] [raw]
Subject: NFS locking question

I am having a somewhat weird problem with nfs locking. My servers are
linux version 2.4.21. The server filesystems are xfs. My clients are
HPUX 11i and linux(tested with 2.4.21 and 2.4.25 stock kernels).
When I try to use fcntl, the HPUX client will always fail to lock unless
the file is world readable. Even if the user is the owner with rwx, the
lock will fail. As soon as I chmod a+r on the file, the lock will
succeed.
On linux clients, I have not been able to get the file to lock at all.
The fcntl returns EBADF which implies I passed a bad file descriptor, but
I have verified that it is a valid file descriptor.
Are there any issues with the linux NFS locking code that I am obviously
overlooking? I know in the past there was some discussion about some
locking techniques that were supported or not supported. Am I facing one
of these?
Thanks.
--David Dougall



-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g.
Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs


2004-05-24 17:53:01

by Ara.T.Howard

[permalink] [raw]
Subject: Re: NFS locking question

On Mon, 24 May 2004, David Dougall wrote:

> On linux clients, I have not been able to get the file to lock at all. The
> fcntl returns EBADF which implies I passed a bad file descriptor, but I have
> verified that it is a valid file descriptor.

is the file open is a mode consistent with the lock request? eg. are you
asking for an exclusive lock when the file is only open for reading? if so
you'll get EBADF... you must open a file for writing if you want an exclusive
lock...

-a
--
===============================================================================
| EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
| PHONE :: 303.497.6469
| ADDRESS :: E/GC2 325 Broadway, Boulder, CO 80305-3328
| URL :: http://www.ngdc.noaa.gov/stp/
| "640K ought to be enough for anybody." - Bill Gates, 1981
===============================================================================



-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g.
Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

2004-05-24 18:02:56

by David Dougall

[permalink] [raw]
Subject: Re: NFS locking question

OK, I don't think this is what I have done:
fd=open(infilename,O_RDONLY);
flk.l_type=F_RDLCK;
return_code=fcntl(fd,F_SETLK,&flk);

If this is wrong, let me know.
--David Dougall



On Mon, 24 May 2004, Ara.T.Howard wrote:

> On Mon, 24 May 2004, David Dougall wrote:
>
> > On linux clients, I have not been able to get the file to lock at all. The
> > fcntl returns EBADF which implies I passed a bad file descriptor, but I have
> > verified that it is a valid file descriptor.
>
> is the file open is a mode consistent with the lock request? eg. are you
> asking for an exclusive lock when the file is only open for reading? if so
> you'll get EBADF... you must open a file for writing if you want an exclusive
> lock...
>
> -a
> --
> ===============================================================================
> | EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
> | PHONE :: 303.497.6469
> | ADDRESS :: E/GC2 325 Broadway, Boulder, CO 80305-3328
> | URL :: http://www.ngdc.noaa.gov/stp/
> | "640K ought to be enough for anybody." - Bill Gates, 1981
> ===============================================================================
>
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by: Oracle 10g
> Get certified on the hottest thing ever to hit the market... Oracle 10g.
> Take an Oracle 10g class now, and we'll give you the exam FREE.
> http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click
> _______________________________________________
> NFS maillist - [email protected]
> https://lists.sourceforge.net/lists/listinfo/nfs
>
>


-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g.
Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs