GFS2: Fix bug trap and journaled data fsync
Journaled data requires that a complete flush of all dirty data for
the file is done, in order that the ail flush which comes after
will succeed.
Also the recently enhanced bug trap can trigger falsely in case
an ail flush from fsync races with a page read. This updates the
bug trap such that it will ignore buffers which are locked and
only trigger on dirty and/or pinned buffers when the ail flush
is run from fsync. The original bug trap is retained when ail
flush is run from ->go_sync()
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c
index 92c3db4..9d12286 100644
--- a/fs/gfs2/file.c
+++ b/fs/gfs2/file.c
@@ -590,6 +590,8 @@
mutex_unlock(&inode->i_mutex);
return ret;
}
+ if (gfs2_is_jdata(ip))
+ filemap_write_and_wait(mapping);
gfs2_ail_flush(ip->i_gl);
mutex_unlock(&inode->i_mutex);
}