Re: Race in open(O_CREAT|O_EXCL) and network filesystem

Trond Myklebust (trond.myklebust@fys.uio.no)
29 Jul 2002 13:45:52 +0200


>>>>> " " == Jan Hudec <bulb@ucw.cz> writes:

> Hi all, maybe I'm blind, but I think there is a race featuring
> open(O_CREAT|O_EXCL) and nfs or any other network fs.

> 1) Is there some reason this can't happen that I overlooked?

No. It can indeed happen, and it is one of my pet peeves in the
current open_namei() layout. The VFS seems all too often to assume
that a semaphore suffices to ensure atomicity. This is obviously not
the case for networked filesystems.

> 2) If it is a problem (comment in NFS suggest so), I can see
> two ways of
> handling this. Either pass the flags to the create method, or
> restart the open when create returns EEXISTS. Which one would
> be prefered?

I'd rather like to see some method by which we could merge the
lookup() and create() calls.

Given its support for exclusive create, there is no reason why we
should be doing the lookup in the first place on NFSv3. It's just a
waste of an RPC call...
IIRC, the NFSv4 client actually has to work around the whole
open_namei() thingy with a new 'open()' method in order to conform to
the RFCs.

The minimum change I'd need, though, is for vfs_create() to actually
pass me the O_EXCL flag.

Cheers,
Trond
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/