From mboxrd@z Thu Jan 1 00:00:00 1970 From: Trond Myklebust Subject: Re: Does mandatory locking need to be set when the file is locked? Date: 15 Dec 2003 13:09:11 -0500 Sender: linux-fsdevel-owner@vger.kernel.org Message-ID: References: <000001c3c323$24154030$0201a8c0@joe> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Return-path: Received: from pat.uio.no ([129.240.130.16]:59640 "EHLO pat.uio.no") by vger.kernel.org with ESMTP id S263873AbTLOSJ1 (ORCPT ); Mon, 15 Dec 2003 13:09:27 -0500 To: "Joseph D. Wagner" In-Reply-To: <000001c3c323$24154030$0201a8c0@joe> List-Id: linux-fsdevel.vger.kernel.org >>>>> " " == Joseph D Wagner writes: > My program DEPENDS upon mandatory locking, so I'd like a little > more info before I abandon that route entirely. Then don't be surprised if it cannot work on networked filesystems. NFS is, for instance, incapable of supporting mandatory locks in v2 and v3 (v4 will support it for ordinary files). What's more, mmap() is forbidden on on any file with mandatory locks (this is true for all filesystems). Finally, the Linux mandatory locking implementation does not eliminate all possible races: currently there is no attempt made to exclude one thread from taking a lock while another is still in the process of writing to the file, or if it already has a section of that file mmapped. In that case, the lock call may well succeed, but the other thread that is inside read/write/mmap will not see it. So if you want to DEPEND on mandatory locking to work, then you probably have some kernel debugging to do first. Cheers, Trond