From owner-freebsd-arch@FreeBSD.ORG Sun Apr 13 23:16:40 2008 Return-Path: Delivered-To: arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 553D7106564A for ; Sun, 13 Apr 2008 23:16:40 +0000 (UTC) (envelope-from jroberson@jroberson.net) Received: from wa-out-1112.google.com (wa-out-1112.google.com [209.85.146.177]) by mx1.freebsd.org (Postfix) with ESMTP id 35C298FC22 for ; Sun, 13 Apr 2008 23:16:40 +0000 (UTC) (envelope-from jroberson@jroberson.net) Received: by wa-out-1112.google.com with SMTP id k17so1697119waf.3 for ; Sun, 13 Apr 2008 16:16:39 -0700 (PDT) Received: by 10.114.89.1 with SMTP id m1mr6151442wab.77.1208128599819; Sun, 13 Apr 2008 16:16:39 -0700 (PDT) Received: from ?10.0.1.199? ( [24.94.72.120]) by mx.google.com with ESMTPS id k9sm12600336wah.3.2008.04.13.16.16.37 (version=SSLv3 cipher=OTHER); Sun, 13 Apr 2008 16:16:38 -0700 (PDT) Date: Sun, 13 Apr 2008 13:16:59 -1000 (HST) From: Jeff Roberson X-X-Sender: jroberson@desktop To: David Schultz In-Reply-To: <20080413160829.GA42972@zim.MIT.EDU> Message-ID: <20080413131422.V959@desktop> References: <20080412132457.W43186@desktop> <20080413160829.GA42972@zim.MIT.EDU> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: arch@FreeBSD.ORG Subject: Re: f_offset X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 13 Apr 2008 23:16:40 -0000 On Sun, 13 Apr 2008, David Schultz wrote: > On Sat, Apr 12, 2008, Jeff Roberson wrote: >> It's worth discussing what posix actually guarantees for f_offset as well >> as what other operating systems do. POSIX actually does not guarantee any >> behavior with simultaneous access. Multiple readers may read the same >> position in the file concurrently and update the position to different >> offsets. Multiple writers may write to the same file location, although >> the io should be serialized by some other means. Posix allows for and >> Solaris, Linux, and historic implementations of f_offset work in the >> following way: > > This is not entirely true. In particular, files opened with > O_APPEND have stronger guarantees, and this behavior can be > useful. For example, I imagine that a database that opens its log > file with O_APPEND can depend on being able to write log entries > concurrently without losing any data. (There are also stronger > requirements for pipes, FIFOs, etc.) As alfred mentioned append is handled in a different way. I'm not suggesting we break posix semantics for append. Also, pipes and fifos don't have an f_offset and you can't call seek on them. > > As I recall, empiricial evidence shows that SunOS 5.10 and FreeBSD > both make stronger guarantees than Linux in the presence of > multiple concurrent writers. I haven't tested readers or looked > at the fdesc code for any of these. > Yes I slightly misspoke about solaris. They use the exclusive vnode lock to protect f_offset for writers. However, f_offset is fetched and set with a shared vnode lock for readers. These are the same semantics that I'm proposing. Thanks, Jeff