alistair23-linux/fs/gfs2
Bob Peterson cc555b09d8 GFS2: Take inode off order_write list when setting jdata flag
This patch fixes a deadlock caused when the jdata flag is set for
inodes that are already on the ordered write list. Since it is
on the ordered write list, log_flush calls gfs2_ordered_write which
calls filemap_fdatawrite. But since the inode had the jdata flag
set, that calls gfs2_jdata_writepages, which tries to start a new
transaction. A new transaction cannot be started because it tries
to acquire the log_flush rwsem which is already locked by the log
flush operation.

The bottom line is: We cannot switch an inode from ordered to jdata
until we eliminate any ordered data pages (via log flush) or any
log_flush operation afterward will create the circular dependency
above. So we need to flush the log before setting the diskflags to
switch the file mode, then we need to remove the inode from the
ordered writes list.

Before this patch, the log flush was done for jdata->ordered, but
that's wrong. If we're going from jdata to ordered, we don't need
to call gfs2_log_flush because the call to filemap_fdatawrite will
do it for us:

   filemap_fdatawrite() -> __filemap_fdatawrite_range()
      __filemap_fdatawrite_range() -> do_writepages()
         do_writepages() -> gfs2_jdata_writepages()
            gfs2_jdata_writepages() -> gfs2_log_flush()

This patch modifies function do_gfs2_set_flags so that if a file
has its jdata flag set, and it's already on the ordered write list,
the log will be flushed and it will be removed from the list
before setting the flag.

Signed-off-by: Bob Peterson <rpeterso@redhat.com>
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Acked-by: Abhijith Das <adas@redhat.com>
2017-10-31 14:26:47 +01:00
..
acl.c gfs2: Always update inode ctime in set_acl 2017-09-25 12:33:19 -05:00
acl.h
aops.c gfs2: forcibly flush ail to relieve memory pressure 2017-08-10 10:51:03 -05:00
bmap.c GFS2: Implement iomap for block_map 2017-10-31 14:26:33 +01:00
bmap.h GFS2: Implement iomap for block_map 2017-10-31 14:26:33 +01:00
dentry.c
dir.c We've got a whopping 29 GFS2 patches for this merge window, mainly 2017-09-06 11:42:31 -07:00
dir.h
export.c
file.c GFS2: Take inode off order_write list when setting jdata flag 2017-10-31 14:26:47 +01:00
gfs2.h
glock.c gfs2: Fix debugfs glocks dump 2017-09-25 12:32:33 -05:00
glock.h gfs2: gfs2_evict_inode: Put glocks asynchronously 2017-08-10 10:45:21 -05:00
glops.c Merge branch 'work.mount' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2017-09-14 18:54:01 -07:00
glops.h
incore.h gfs2: Silence gcc format-truncation warning 2017-08-25 10:59:21 -05:00
inode.c gfs2: Implement SEEK_HOLE / SEEK_DATA via iomap 2017-10-31 14:26:35 +01:00
inode.h gfs2: Implement SEEK_HOLE / SEEK_DATA via iomap 2017-10-31 14:26:35 +01:00
Kconfig GFS2: Switch fiemap implementation to use iomap 2017-10-31 14:26:34 +01:00
lock_dlm.c GFS2: Fix up some sparse warnings 2017-08-25 18:47:18 -05:00
log.c GFS2: Withdraw for IO errors writing to the journal or statfs 2017-08-25 10:59:09 -05:00
log.h
lops.c Merge branch 'for-4.14/block' of git://git.kernel.dk/linux-block 2017-09-07 11:59:42 -07:00
lops.h
main.c GFS2: Remove gl_list from glock structure 2017-06-12 14:39:12 -05:00
Makefile
meta_io.c Merge branch 'for-4.14/block' of git://git.kernel.dk/linux-block 2017-09-07 11:59:42 -07:00
meta_io.h
ops_fstype.c Merge branch 'work.mount' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2017-09-14 18:54:01 -07:00
quota.c Merge branch 'work.mount' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2017-09-14 18:54:01 -07:00
quota.h
recovery.c VFS: Convert sb->s_flags & MS_RDONLY to sb_rdonly(sb) 2017-07-17 08:45:34 +01:00
recovery.h
rgrp.c GFS2: Fix gl_object warnings 2017-08-30 08:14:27 -05:00
rgrp.h GFS2: Non-recursive delete 2017-04-19 08:25:43 -04:00
super.c GFS2: flush the log and all pages for jdata as we do for WB_SYNC_ALL 2017-10-31 14:26:35 +01:00
super.h
sys.c VFS: Convert sb->s_flags & MS_RDONLY to sb_rdonly(sb) 2017-07-17 08:45:34 +01:00
sys.h
trace_gfs2.h GFS2: Implement iomap for block_map 2017-10-31 14:26:33 +01:00
trans.c GFS2: Reduce contention on gfs2_log_lock 2017-01-30 12:10:25 -05:00
trans.h
util.c Replace <asm/uaccess.h> with <linux/uaccess.h> globally 2016-12-24 11:46:01 -08:00
util.h GFS2: Fix up some sparse warnings 2017-08-25 18:47:18 -05:00
xattr.c gfs2: don't return ENODATA in __gfs2_xattr_set unless replacing 2017-08-31 07:43:03 -05:00
xattr.h