xfs: merge fsync and O_SYNC handling

The guarantees for O_SYNC are exactly the same as the ones we need to
make for an fsync call (and given that Linux O_SYNC is O_DSYNC the
equivalent is fdadatasync, but we treat both the same in XFS), except
with a range data writeout.  Jan Kara has started unifying these two
path for filesystems using the generic helpers, and I've started to
look at XFS.

The actual transaction commited by xfs_fsync and xfs_write_sync_logforce
has a different transaction number, but actually is exactly the same.
We'll only use the fsync transaction going forward.  One major difference
is that xfs_write_sync_logforce never issues a cache flush unless we
commit a transaction causing that as a side-effect, which is an obvious
bug in the O_SYNC handling.  Second all the locking and i_update_size
vs i_update_core changes from 978b723712
never made it to xfs_write_sync_logforce, so we add them back.

To make xfs_fsync easily usable from the O_SYNC path, the filemap_fdatawait
call is moved up to xfs_file_fsync, so that we don't wait on the whole
file after we already waited for our portion in xfs_write.

We'll also use a plain call to filemap_write_and_wait_range instead
of the previous sync_page_rang which did it in two steps including
an half-hearted inode write out that doesn't help us.

Once we're done with this also remove the now useless i_update_size
tracking.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Felix Blyakher <felixb@sgi.com>
Signed-off-by: Felix Blyakher <felixb@sgi.com>
Этот коммит содержится в:
Christoph Hellwig
2009-08-31 21:00:31 -03:00
коммит произвёл Felix Blyakher
родитель bd16956599
Коммит 13e6d5cdde
10 изменённых файлов: 23 добавлений и 112 удалений

Просмотреть файл

@@ -262,14 +262,6 @@ xfs_inode_item_format(
SYNCHRONIZE();
}
/*
* We don't have to worry about re-ordering here because
* the update_size field is protected by the inode lock
* and we have that held in exclusive mode.
*/
if (ip->i_update_size)
ip->i_update_size = 0;
/*
* Make sure to get the latest atime from the Linux inode.
*/