From owner-freebsd-fs@FreeBSD.ORG Mon Nov 17 10:13:06 2003 Return-Path: Delivered-To: freebsd-fs@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A3AA416A4CE; Mon, 17 Nov 2003 10:13:06 -0800 (PST) Received: from fledge.watson.org (fledge.watson.org [204.156.12.50]) by mx1.FreeBSD.org (Postfix) with ESMTP id 59B2D43FDD; Mon, 17 Nov 2003 10:13:05 -0800 (PST) (envelope-from robert@fledge.watson.org) Received: from fledge.watson.org (localhost [127.0.0.1]) by fledge.watson.org (8.12.9p2/8.12.9) with ESMTP id hAHIB1Mg067880; Mon, 17 Nov 2003 13:11:01 -0500 (EST) (envelope-from robert@fledge.watson.org) Received: from localhost (robert@localhost)hAHIB1xK067877; Mon, 17 Nov 2003 13:11:01 -0500 (EST) (envelope-from robert@fledge.watson.org) Date: Mon, 17 Nov 2003 13:11:01 -0500 (EST) From: Robert Watson X-Sender: robert@fledge.watson.org To: Alfred Perlstein In-Reply-To: <20031117052258.GB35957@elvis.mu.org> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: bp@freebsd.org cc: marcel@freebsd.org cc: fs@freebsd.org Subject: Re: open cookies X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 17 Nov 2003 18:13:06 -0000 On Sun, 16 Nov 2003, Alfred Perlstein wrote: > I'm starting to do the gruntwork of getting us per-open cookies for file > operations. If someone can explain what needs to be done that would > speed things up. :) > > If you're unclear as to what I'm talking about, what I mean is the > "private_data" field in Linux's "struct file". > > Please keep me cc'd as this is the only list I'm currently subscribed > to. > > My main question is... should the cookies be returned from VOP_CREATE, > VOP_LOOKUP, VOP_MKNOD, etc.. (all the ones that have and OUT/INOUT of > *vpp) or should we only care about VOP_OPEN? I implemented about 90% of this previously and did not commit it. In general, the notion of "session" corresponds well to the notion of "file descriptor"; I found that this meant only VOPs that could be performed on a vnode pulled out of a file descriptor were relevant. When a VOP is dual-purpose: i.e., can be called using both "by name" and "with a session", or even just "without a session", I used NULL for the cookie argument to the VOP. Since we nominally support file system stacking, I found that, much as you concluded, we needed a cookie rather than passing struct file into each VOP, which works with the top layer but not for lower layers. As we stuff a lower layer vnode reference into the per-vnode state, we now have to stuff per-open state material into each layer's per-open state. My general conclusion was that this over-complicated our VFS substantially, and that the struct file state in Linux was generally used only for multiply instantiated devices. With devfs cloning, all the cases I was interested in (things like /dev vmware nodes) are addressed. Since none of our non-specfs nodes required any notion of state, I found I was touching a lot of code to minimal benefit. What's your motivation for adding this support, and can it be added in a way that doesn't introduce new arguments to most VOPs, and introduce a host of potential bugs? I don't doubt it can be done right, but it's a fairly complex solution that has to be motivated by complex requirements... Robert N M Watson FreeBSD Core Team, TrustedBSD Projects robert@fledge.watson.org Network Associates Laboratories