From mboxrd@z Thu Jan 1 00:00:00 1970 From: dcg Subject: Re: [RESEND] [PATCH] VFS: make file->f_pos access atomic on 32bit arch Date: Thu, 9 Oct 2008 23:51:58 +0200 Message-ID: <20081009235158.7d328aa0@diego-desktop> References: <6.0.0.20.2.20081007140438.0580f110@172.19.0.2> <20081007105056.16d9e785.akpm@linux-foundation.org> <1223405963.26330.83.camel@lappy.programming.kicks-ass.net> <200810081335.44576.nickpiggin@yahoo.com.au> <6.0.0.20.2.20081008132532.056cc400@172.19.0.2> <1223448711.1378.16.camel@lappy.programming.kicks-ass.net> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: Hisashi Hifumi , Nick Piggin , torvalds@linux-foundation.org, Andrew Morton , Andi Kleen , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, "Aneesh Kumar K.V" , Theodore Ts'o To: Peter Zijlstra Return-path: In-Reply-To: <1223448711.1378.16.camel@lappy.programming.kicks-ass.net> Sender: linux-kernel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org El Wed, 08 Oct 2008 08:51:51 +0200, Peter Zijlstra escribi=C3=B3: > either dup() the fd or open() the file twice. There is absolutely no > valid reason to have two threads read from the same fd without > synchronising their access to it - never. In case this is the final consensus, I think that a topic that is broug= ht to the list every few months and even generates (aparently not neccesar= y) patches is a hint that there should be somewhere a commentary (*) like this: (*) I don't know if what I wrote is 100% correct. Signed-off-by: Diego Calleja Garc=C3=ADa Index: 2.6/include/linux/fs.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 2.6.orig/include/linux/fs.h 2008-10-09 00:06:50.000000000 +0200 +++ 2.6/include/linux/fs.h 2008-10-09 00:29:03.000000000 +0200 @@ -821,6 +821,18 @@ atomic_long_t f_count; unsigned int f_flags; mode_t f_mode; + /* + * Linux does NOT guarantee atomic reading/writing to file->f_pos in + * multithread apps running in 32 bit machines. There're several + * reasons for this behaviour: + * - Specifications don't say it must be implemented that way. + * - This behaviour is part of the Linux semantics. + * - Any application that does multithreaded access to file->f_pos + * should be doing its own locking: the processes should synchroni= ze + * themselves when accessing a file descriptor. If an application + * doesn't do that, its file descriptor handling is buggy anyway a= nd + * must be fixed to access file->f_pos properly. + */ loff_t f_pos; struct fown_struct f_owner; unsigned int f_uid, f_gid;