VFS/fs_stack: use locking around i_size_write in 32-bit systems
authorHugh Dickins <hugh@veritas.com>
Tue, 25 Dec 2007 21:39:35 +0000 (16:39 -0500)
committerErez Zadok <ezk@cs.sunysb.edu>
Mon, 12 Jan 2009 23:20:47 +0000 (18:20 -0500)
commit5fc3c34e267da233bb2e7c74eda3b498dae51ec6
tree8c7b4755a2958a2c56566052fd94a5c72b17005f
parent815602968a200c0b3ee574ad7cf79531a68952e9
VFS/fs_stack: use locking around i_size_write in 32-bit systems

LTP's iogen01 doio tests hang nicely on 32-bit SMP when /tmp is a unionfs
mount of a tmpfs.  See the comment on i_size_write in linux/fs.h: it needs
to be locked, otherwise i_size_read can spin forever waiting for a lost
seqcount update.

Most filesystems are already holding i_mutex for this, but unionfs calls
fsstack_copy_inode_size from many places, not necessarily holding i_mutex.
Use the low-level i_lock within fsstack_copy_inode_size when 32-bit SMP.

Checked the entire unionfs code to ensure this is the right fix for
i_size_write().

Also compared to what other file systems do when they have to handle inodes,
esp. not their own inodes (e.g., network file systems have to access the
exported file system's inodes).  Found out that most such file systems not just
don't lock around i_size_write, but they don't even use i_size_read or
i_size_write to access the inode's size.

CC: Mike Halcrow <mhalcrow@us.ibm.com>
Signed-off-by: Hugh Dickins <hugh@veritas.com>
Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
fs/stack.c