Re: [RESEND] [PATCH] VFS: make file->f_pos access atomic on 32bit arch

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



El Wed, 08 Oct 2008 08:51:51 +0200, Peter Zijlstra <a.p.zijlstra@xxxxxxxxx> escribió:

> 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 brought
to the list every few months and even generates (aparently not neccesary)
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ía <diegocg@xxxxxxxxx>

Index: 2.6/include/linux/fs.h
===================================================================
--- 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 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 access file->f_pos properly.
+	 */
 	loff_t			f_pos;
 	struct fown_struct	f_owner;
 	unsigned int		f_uid, f_gid;

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux