Просмотр исходного кода

[GFS2] Change gfs2_fsync() to use write_inode_now()

This is a bit better than the previous version of gfs2_fsync()
although it would be better still if we were able to call a
function which only wrote the inode & metadata. Its no big deal
though that this will potentially write the data as well since
the VFS has already done that before calling gfs2_fsync(). I've
also added a comment to explain whats going on here.

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Cc: Andrew Morton <akpm@osdl.org>
Steven Whitehouse 18 лет назад
Родитель
Сommit
34126f9f41
1 измененных файлов с 6 добавлено и 5 удалено
  1. 6 5
      fs/gfs2/ops_file.c

+ 6 - 5
fs/gfs2/ops_file.c

@@ -510,6 +510,11 @@ static int gfs2_close(struct inode *inode, struct file *file)
  * is set. For stuffed inodes we must flush the log in order to
  * is set. For stuffed inodes we must flush the log in order to
  * ensure that all data is on disk.
  * ensure that all data is on disk.
  *
  *
+ * The call to write_inode_now() is there to write back metadata and
+ * the inode itself. It does also try and write the data, but thats
+ * (hopefully) a no-op due to the VFS having already called filemap_fdatawrite()
+ * for us.
+ *
  * Returns: errno
  * Returns: errno
  */
  */
 
 
@@ -518,10 +523,6 @@ static int gfs2_fsync(struct file *file, struct dentry *dentry, int datasync)
 	struct inode *inode = dentry->d_inode;
 	struct inode *inode = dentry->d_inode;
 	int sync_state = inode->i_state & (I_DIRTY_SYNC|I_DIRTY_DATASYNC);
 	int sync_state = inode->i_state & (I_DIRTY_SYNC|I_DIRTY_DATASYNC);
 	int ret = 0;
 	int ret = 0;
-	struct writeback_control wbc = {
-		.sync_mode = WB_SYNC_ALL,
-		.nr_to_write = 0,
-	};
 
 
 	if (gfs2_is_jdata(GFS2_I(inode))) {
 	if (gfs2_is_jdata(GFS2_I(inode))) {
 		gfs2_log_flush(GFS2_SB(inode), GFS2_I(inode)->i_gl);
 		gfs2_log_flush(GFS2_SB(inode), GFS2_I(inode)->i_gl);
@@ -530,7 +531,7 @@ static int gfs2_fsync(struct file *file, struct dentry *dentry, int datasync)
 
 
 	if (sync_state != 0) {
 	if (sync_state != 0) {
 		if (!datasync)
 		if (!datasync)
-			ret = sync_inode(inode, &wbc);
+			ret = write_inode_now(inode, 0);
 
 
 		if (gfs2_is_stuffed(GFS2_I(inode)))
 		if (gfs2_is_stuffed(GFS2_I(inode)))
 			gfs2_log_flush(GFS2_SB(inode), GFS2_I(inode)->i_gl);
 			gfs2_log_flush(GFS2_SB(inode), GFS2_I(inode)->i_gl);