From: dcg <diegocalleja@gmail.com>
To: Nick Piggin <nickpiggin@yahoo.com.au>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>,
Hisashi Hifumi <hifumi.hisashi@oss.ntt.co.jp>,
torvalds@linux-foundation.org,
Andrew Morton <akpm@linux-foundation.org>,
Andi Kleen <andi@firstfloor.org>,
linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
"Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>,
"Theodore Ts'o" <tytso@mit.edu>
Subject: [PATCH] Document file->f_pos as thread-unsafe
Date: Fri, 10 Oct 2008 21:17:59 +0200 [thread overview]
Message-ID: <20081010211759.630dfb6b@diego-desktop> (raw)
El Fri, 10 Oct 2008 13:25:15 +1100, Nick Piggin <nickpiggin@yahoo.com.au> escribió:
> Note that I don't think we'd want to explicitly guarantee that it is atomic
> on 64-bit machines either. It does happen to be, but I don't think we want
> anybody to rely on that...
Easily fixable. Performance testing of this new version didn't find
regressions.
Document that it is not safe to play with file->f_pos from multiple processes
if they aren't synchronizing themselves.
Signed-off-by: Diego Calleja <diegocg@gmail.com>
Index: 2.6/include/linux/fs.h
===================================================================
--- 2.6.orig/include/linux/fs.h 2008-10-10 21:07:29.000000000 +0200
+++ 2.6/include/linux/fs.h 2008-10-10 21:08:25.000000000 +0200
@@ -821,6 +821,17 @@
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
+ * multithreaded apps. 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 synchronize
+ * themselves when accessing a file descriptor. If an application
+ * doesn't do that, its file descriptor handling is buggy anyway and
+ * must be fixed to do its accesses to file->f_pos properly.
+ */
loff_t f_pos;
struct fown_struct f_owner;
unsigned int f_uid, f_gid;
reply other threads:[~2008-10-10 19:18 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20081010211759.630dfb6b@diego-desktop \
--to=diegocalleja@gmail.com \
--cc=a.p.zijlstra@chello.nl \
--cc=akpm@linux-foundation.org \
--cc=andi@firstfloor.org \
--cc=aneesh.kumar@linux.vnet.ibm.com \
--cc=hifumi.hisashi@oss.ntt.co.jp \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nickpiggin@yahoo.com.au \
--cc=torvalds@linux-foundation.org \
--cc=tytso@mit.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®