2002-08-27 01:02:05

by Jan Hudec

[permalink] [raw]
Subject: Question about leases

Hello all,

Please can anyone throw a bit light on file leases (fcntl F_SETLEASE
command) or at least point me to some documentation? I can't find any.

As far as I figured out process holding a lease is notified when other
process opens the leased file. But I am still not sure how the leases
should then be released and how the process knows which lease was broken
(struct siginfo does not seem to have union member for that case).

-------------------------------------------------------------------------------
Jan 'Bulb' Hudec <[email protected]>


2002-08-27 04:31:16

by Stephen Rothwell

[permalink] [raw]
Subject: Re: Question about leases

On Tue, 27 Aug 2002 03:06:16 +0200 Jan Hudec <[email protected]> wrote:
>
> Please can anyone throw a bit light on file leases (fcntl F_SETLEASE
> command) or at least point me to some documentation? I can't find any.

There isn't any (except maybe the talk I gave at Linux Kongress
last year (http://www.canb.auug.org.au/~sfr/idle.html).

> As far as I figured out process holding a lease is notified when other
> process opens the leased file. But I am still not sure how the leases
> should then be released and how the process knows which lease was broken
> (struct siginfo does not seem to have union member for that case).

To release a lease, you use fcntl(fd, F_SETLEASE, F_UNLCK). The file
descriptor of the file that the lease is on is returned in the
siginfo structure.

--
Cheers,
Stephen Rothwell [email protected]
http://www.canb.auug.org.au/~sfr/

2002-08-27 04:40:10

by Stephen Rothwell

[permalink] [raw]
Subject: Re: Question about leases

Hi again,

On Tue, 27 Aug 2002 14:35:17 +1000 Stephen Rothwell <[email protected]> wrote:
>
> On Tue, 27 Aug 2002 03:06:16 +0200 Jan Hudec <[email protected]> wrote:
> >
> > Please can anyone throw a bit light on file leases (fcntl F_SETLEASE
> > command) or at least point me to some documentation? I can't find any.
>
> There isn't any (except maybe the talk I gave at Linux Kongress
> last year (http://www.canb.auug.org.au/~sfr/idle.html).
>
> > As far as I figured out process holding a lease is notified when other
> > process opens the leased file. But I am still not sure how the leases
> > should then be released and how the process knows which lease was broken
> > (struct siginfo does not seem to have union member for that case).
>
> To release a lease, you use fcntl(fd, F_SETLEASE, F_UNLCK). The file
> descriptor of the file that the lease is on is returned in the
> siginfo structure.

You should also be aware that there are lots of bugs with file leases
before 2.4.20-pre3 and in early 2.5 kernels.
--
Cheers,
Stephen Rothwell [email protected]
http://www.canb.auug.org.au/~sfr/

2002-08-27 08:38:41

by Jan Hudec

[permalink] [raw]
Subject: Re: Question about leases

On Tue, Aug 27, 2002 at 02:35:17PM +1000, Stephen Rothwell wrote:
> > As far as I figured out process holding a lease is notified when other
> > process opens the leased file. But I am still not sure how the leases
> > should then be released and how the process knows which lease was broken
> > (struct siginfo does not seem to have union member for that case).
>
> To release a lease, you use fcntl(fd, F_SETLEASE, F_UNLCK). The file
> descriptor of the file that the lease is on is returned in the
> siginfo structure.

One more question. Does the siginfo contain information weather is's
read or write that the other process attempted? And does it contain the
operation type for directory notifications?

-------------------------------------------------------------------------------
Jan 'Bulb' Hudec <[email protected]>

2002-08-27 12:12:16

by Stephen Rothwell

[permalink] [raw]
Subject: Re: Question about leases

Hi Jan,

On Tue, 27 Aug 2002 10:42:44 +0200 Jan Hudec <[email protected]> wrote:
>
> One more question. Does the siginfo contain information weather is's
> read or write that the other process attempted? And does it contain the

No, you need to do fcntl(fd, F_GETLEASE) to find out what kind of
lease you need to set to satisfy the other process i.e. if the other
process does an open for reading then GETLEASE will return F_RDLCK
and if they attempt an open for writing the GETLEASE will return F_UNLCK.

> operation type for directory notifications?

No, sorry.

--
Cheers,
Stephen Rothwell [email protected]
http://www.canb.auug.org.au/~sfr/

2002-09-02 11:24:41

by Michael Kerrisk

[permalink] [raw]
Subject: Re: Question about leases

> On Tue, 27 Aug 2002 14:35:17 +1000 Stephen Rothwell <[email protected]>
> wrote:
> >
> > On Tue, 27 Aug 2002 03:06:16 +0200 Jan Hudec <[email protected]>
> wrote:
> > >
> > > Please can anyone throw a bit light on file leases (fcntl F_SETLEASE
> > > command) or at least point me to some documentation? I can't find any.
> >
> > There isn't any (except maybe the talk I gave at Linux Kongress
> > last year (http://www.canb.auug.org.au/~sfr/idle.html).

Not quite true. I wrote some additions to the fcntl(2) manual page
describing leases. Download a recent copy of the man pages from tldp.org.

Cheers

Michael

--
GMX - Die Kommunikationsplattform im Internet.
http://www.gmx.net