From: Petr Vandrovec Subject: Re: CIFS VFS Date: Wed, 2 Oct 2002 04:45:35 +0200 Sender: linux-fsdevel-owner@vger.kernel.org Message-ID: <20021002024535.GC1491@ppc.vc.cvut.cz> References: <363C9E44237@vcnet.vc.cvut.cz> <20021002031743.Y18377@parcelfarce.linux.theplanet.co.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Christoph Hellwig , linux-fsdevel@vger.kernel.org, sfrench@us.ibm.com Return-path: To: Matthew Wilcox Content-Disposition: inline In-Reply-To: <20021002031743.Y18377@parcelfarce.linux.theplanet.co.uk> List-Id: linux-fsdevel.vger.kernel.org On Wed, Oct 02, 2002 at 03:17:43AM +0100, Matthew Wilcox wrote: > On Tue, Oct 01, 2002 at 10:00:39PM +0200, Petr Vandrovec wrote: > > > (2) first resolve locks locally, and then, if you succesfully obtained > > lock locally, consult filesystem's lock method; ncpfs must do it > > that way because of there is only one server filehandle for each > > opened file, and so from server's view there is only one entity on > > connection. > > How about this: if filesystem provides its own ->lock method, locks.c > promises to leave i_flock member alone? That way your ->lock method > can do all this by itself. Yes, it would work. Although same as for CIFS applies - all locks are mandatory, not advisory - but it should not matter for locking, as properly written apps work same way on both system, and if someone tries to read locked file, he'll get what he deserves... > The major problem with this is removing locks on file close. Either we > need a magic value for PID that means PID_ANY or we need a new f_op method. > I favour the magic PID_ANY flag myself. ncpfs can be happy with "standardized" contents of i_flock, so VFS can peek at list of locks placed on file by local workstation. > > If current method (first call filesystem, then obtain lock locally) is > > going to stay, then I believe that we should call F_UNLOCK when > > filesystem's lock succeeded, but local posix_lock_file failed (either > > due to EAGAIN or EINTR or ...). Otherwise server is never notified > > that lock was not acquired by workstation, and will be never released. > > I think the scheme I propose will work fine for you, since you'll still > be able to call the local file locking code so you have a record of what > locks you've set on the server (necessary for crash recovery, i guess?) Just make sure that if you call filesystem's lock, you do not call posix_lock_file. As there is currently only one lock's user (nfs), it should cause no problems to move posix_lock_file at the end of nfs_lock instead of doing it in caller. > I'm not averse to having some kind of split/merge lock library functions > in fs/locks.c either, even if they're not directly used by the local > file locking code. I think several network filesystems will need this > behaviour. Petr Vandrovec vandrove@vc.cvut.cz