read/write delegation, share deny

Trond Myklebust trond.myklebust at fys.uio.no
Fri Aug 10 16:37:41 EDT 2007


On Fri, 2007-08-10 at 14:59 -0500, Shirish Pargaonkar wrote:
> I have a small program like this
> 
> #include <stdio.h>
> #include <fcntl.h>
> 
> 
> #define FILE1NAME "/mnt/fs1/file1"
> #define BUFSIZE 5
> 
> main()
> {
>         int fd1, fd2;
>         int rc1, rc2;
>         char buf[BUFSIZE+1] = {};
> 
>         fd1 = open(FILE1NAME, O_RDWR);
>         read(fd1, buf, BUFSIZE);
>         fd2 = open(FILE1NAME, O_RDWR);
>         write(fd1, "something", sizeof("something"));
>         rc1 = close(fd1);
>         rc2 = close(fd2);
> }
> 
> In tcpdump, all I see is OPEN_DELGATION_NONE being sent by server, twice,
> for both the open I guess!
> How do I make server issue READ/WRITE delegation during the first open?
> I have just mounted the filesystem on the client.

The server can't issue a delegation on the very first open after a mount
since it will usually need to request an OPEN_CONFIRM in order to
establish an open owner. The protocol doesn't allow it to send a
delegation in that case.

> I would like to see read/write delegation revoked when I issue open for the
> very same file on the server from another client, which I can't verify
> unless I can see first client receiving read/write open delegation I guess.
> I am trying to verify what kinds of open delegations Linux server
> issues to clients.

Check using ethereal or wireshark that your SETCLIENTID call is indeed
sending the correct callback address. In some cases, 'mount' gets it
wrong, and tells the server to call the client back on address
127.0.0.1: in that case you can correct it using the "clientaddr" mount
option (see 'man 5 nfs').

> Also, instead of this during open
>             share_access: OPEN4_SHARE_ACCESS_BOTH (3)
>             share_deny: OPEN4_SHARE_DENY_NONE (0)
> I want something to have something like this
>             share_access: OPEN4_SHARE_ACCESS_BOTH (3)
>             share_deny: OPEN4_SHARE_DENY_WRITE  or READ or BOTH
> How do I go about doing that? During open call?  How?
> Did not find relevant info on open manpage on the linux box.

Neither the POSIX spec nor the Single Unix Spec. allow for the concept
of deny shares: in general, UNIX systems consider mandatory locks to be
a nuisance at best, and a security problem at worst (imagine allowing
someone to set a DENY_READ on /etc/passwd for instance). There are
therefore no plans to implement support for it.

Trond



More information about the NFSv4 mailing list