GFS2: Don't call file_accessed() with a shared glock
authorBenjamin Marzinski <bmarzins@redhat.com>
Tue, 6 Nov 2012 06:49:28 +0000 (00:49 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 26 Nov 2012 20:14:19 +0000 (12:14 -0800)
commit3707c973f834b0035e611ceb89162d3f6081e262
treef4e5a0b6c22a3ec213e149fbf927039945c03a7e
parente01d83515635e7176cb69f1ac2c59ad1e39e8a63
GFS2: Don't call file_accessed() with a shared glock

commit 3d1626889a64bd5a661544d582036a0a02104a60 upstream.

file_accessed() was being called by gfs2_mmap() with a shared glock. If it
needed to update the atime, it was crashing because it dirtied the inode in
gfs2_dirty_inode() without holding an exclusive lock. gfs2_dirty_inode()
checked if the caller was already holding a glock, but it didn't make sure that
the glock was in the exclusive state. Now, instead of calling file_accessed()
while holding the shared lock in gfs2_mmap(), file_accessed() is called after
grabbing and releasing the glock to update the inode.  If file_accessed() needs
to update the atime, it will grab an exclusive lock in gfs2_dirty_inode().

gfs2_dirty_inode() now also checks to make sure that if the calling process has
already locked the glock, it has an exclusive lock.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/gfs2/file.c
fs/gfs2/super.c