kernel-ark/fs/gfs2
Andi Kleen ef3d0fd27e vfs: do (nearly) lockless generic_file_llseek
The i_mutex lock use of generic _file_llseek hurts.  Independent processes
accessing the same file synchronize over a single lock, even though
they have no need for synchronization at all.

Under high utilization this can cause llseek to scale very poorly on larger
systems.

This patch does some rethinking of the llseek locking model:

First the 64bit f_pos is not necessarily atomic without locks
on 32bit systems. This can already cause races with read() today.
This was discussed on linux-kernel in the past and deemed acceptable.
The patch does not change that.

Let's look at the different seek variants:

SEEK_SET: Doesn't really need any locking.
If there's a race one writer wins, the other loses.

For 32bit the non atomic update races against read()
stay the same. Without a lock they can also happen
against write() now.  The read() race was deemed
acceptable in past discussions, and I think if it's
ok for read it's ok for write too.

=> Don't need a lock.

SEEK_END: This behaves like SEEK_SET plus it reads
the maximum size too. Reading the maximum size would have the
32bit atomic problem. But luckily we already have a way to read
the maximum size without locking (i_size_read), so we
can just use that instead.

Without i_mutex there is no synchronization with write() anymore,
however since the write() update is atomic on 64bit it just behaves
like another racy SEEK_SET.  On non atomic 32bit it's the same
as SEEK_SET.

=> Don't need a lock, but need to use i_size_read()

SEEK_CUR: This has a read-modify-write race window
on the same file. One could argue that any application
doing unsynchronized seeks on the same file is already broken.
But for the sake of not adding a regression here I'm
using the file->f_lock to synchronize this. Using this
lock is much better than the inode mutex because it doesn't
synchronize between processes.

=> So still need a lock, but can use a f_lock.

This patch implements this new scheme in generic_file_llseek.
I dropped generic_file_llseek_unlocked and changed all callers.

Signed-off-by: Andi Kleen <ak@linux.intel.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
2011-10-28 14:58:58 +02:00
..
acl.c switch posix_acl_equiv_mode() to umode_t * 2011-08-01 02:10:06 -04:00
acl.h fs: take the ACL checks to common code 2011-07-25 14:30:23 -04:00
aops.c GFS2: Resolve inode eviction and ail list interaction bug 2011-07-14 08:59:44 +01:00
bmap.c Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs-2.6 2011-07-22 19:02:39 -07:00
bmap.h GFS2: New truncate sequence 2010-09-20 11:18:16 +01:00
dentry.c gfs2: fix d_revalidate oopsen on NFS exports 2011-03-10 03:44:48 -05:00
dir.c GFS2: Cache dir hash table in a contiguous buffer 2011-07-15 09:31:48 +01:00
dir.h GFS2: Cache dir hash table in a contiguous buffer 2011-07-15 09:31:48 +01:00
export.c GFS2: Make writeback more responsive to system conditions 2011-04-20 09:01:37 +01:00
file.c vfs: do (nearly) lockless generic_file_llseek 2011-10-28 14:58:58 +02:00
gfs2.h
glock.c GFS2: Automatically adjust glock min hold time 2011-07-15 09:32:11 +01:00
glock.h GFS2: Automatically adjust glock min hold time 2011-07-15 09:32:11 +01:00
glops.c GFS2: Add S_NOSEC support 2011-07-15 09:32:35 +01:00
glops.h GFS2: Clean up fsync() 2011-04-20 09:00:41 +01:00
incore.h GFS2: Automatically adjust glock min hold time 2011-07-15 09:32:11 +01:00
inode.c fs: take the ACL checks to common code 2011-07-25 14:30:23 -04:00
inode.h ->permission() sanitizing: don't pass flags to ->permission() 2011-07-20 01:43:24 -04:00
Kconfig GFS2: No longer experimental 2010-09-20 11:18:46 +01:00
lock_dlm.c GFS2: Fix glock deallocation race 2011-03-09 10:58:04 +00:00
log.c block: separate priority boosting from REQ_META 2011-08-23 14:50:29 +02:00
log.h GFS2: Make writeback more responsive to system conditions 2011-04-20 09:01:37 +01:00
lops.c GFS2: Optimise glock lru and end of life inodes 2011-04-20 09:01:17 +01:00
lops.h
main.c atomic: use <linux/atomic.h> 2011-07-26 16:49:47 -07:00
Makefile GFS2: Rename ops_inode.c to inode.c 2011-05-10 13:12:49 +01:00
meta_io.c block: separate priority boosting from REQ_META 2011-08-23 14:50:29 +02:00
meta_io.h GFS2: Remove unused macro 2011-04-20 09:00:24 +01:00
ops_fstype.c block: separate priority boosting from REQ_META 2011-08-23 14:50:29 +02:00
quota.c block: separate priority boosting from REQ_META 2011-08-23 14:50:29 +02:00
quota.h vmscan: change shrinker API by passing shrink_control struct 2011-05-25 08:39:26 -07:00
recovery.c GFS2: Fix spectator umount issue 2010-09-29 14:20:52 +01:00
recovery.h gfs2: use workqueue instead of slow-work 2010-07-23 13:14:25 +02:00
rgrp.c GFS2: combine duplicated block freeing routines 2011-07-15 09:32:52 +01:00
rgrp.h GFS2: combine duplicated block freeing routines 2011-07-15 09:32:52 +01:00
super.c GFS2: Cache dir hash table in a contiguous buffer 2011-07-15 09:31:48 +01:00
super.h gfs: constify xattr_handler 2010-05-21 18:31:20 -04:00
sys.c GFS2: Fix race during filesystem mount 2011-07-12 09:15:46 +01:00
sys.h
trace_gfs2.h GFS2: Add an AIL writeback tracepoint 2011-04-20 09:01:58 +01:00
trans.c GFS2: Various gfs2_logd improvements 2010-05-05 09:39:18 +01:00
trans.h GFS2: reserve more blocks for transactions 2010-09-28 09:44:24 +01:00
util.c include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h 2010-03-30 22:02:32 +09:00
util.h GFS2: Metadata address space clean up 2010-03-01 14:07:37 +00:00
xattr.c GFS2: Clean up duplicated setattr code 2010-11-30 10:30:19 +00:00
xattr.h sanitize xattr handler prototypes 2009-12-16 12:16:49 -05:00