diff options
author | Christoph Hellwig <hch@lst.de> | 2009-08-31 20:00:31 -0400 |
---|---|---|
committer | Felix Blyakher <felixb@sgi.com> | 2009-09-01 13:45:57 -0400 |
commit | 13e6d5cdde0e785aa943810f08b801cadd0935df (patch) | |
tree | 72b62d1e3e4b35f1613458b6e1dbbadd74534a92 /fs/xfs/xfs_vnodeops.c | |
parent | bd169565993b39b9b4b102cdac8b13e0a259ce2f (diff) |
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 978b7237123d007b9fa983af6e0e2fa8f97f9934
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>
Diffstat (limited to 'fs/xfs/xfs_vnodeops.c')
-rw-r--r-- | fs/xfs/xfs_vnodeops.c | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/fs/xfs/xfs_vnodeops.c b/fs/xfs/xfs_vnodeops.c index ceecafd1f9c1..03d3100559ac 100644 --- a/fs/xfs/xfs_vnodeops.c +++ b/fs/xfs/xfs_vnodeops.c | |||
@@ -611,7 +611,7 @@ xfs_fsync( | |||
611 | xfs_inode_t *ip) | 611 | xfs_inode_t *ip) |
612 | { | 612 | { |
613 | xfs_trans_t *tp; | 613 | xfs_trans_t *tp; |
614 | int error; | 614 | int error = 0; |
615 | int log_flushed = 0, changed = 1; | 615 | int log_flushed = 0, changed = 1; |
616 | 616 | ||
617 | xfs_itrace_entry(ip); | 617 | xfs_itrace_entry(ip); |
@@ -619,14 +619,9 @@ xfs_fsync( | |||
619 | if (XFS_FORCED_SHUTDOWN(ip->i_mount)) | 619 | if (XFS_FORCED_SHUTDOWN(ip->i_mount)) |
620 | return XFS_ERROR(EIO); | 620 | return XFS_ERROR(EIO); |
621 | 621 | ||
622 | /* capture size updates in I/O completion before writing the inode. */ | ||
623 | error = xfs_wait_on_pages(ip, 0, -1); | ||
624 | if (error) | ||
625 | return XFS_ERROR(error); | ||
626 | |||
627 | /* | 622 | /* |
628 | * We always need to make sure that the required inode state is safe on | 623 | * We always need to make sure that the required inode state is safe on |
629 | * disk. The vnode might be clean but we still might need to force the | 624 | * disk. The inode might be clean but we still might need to force the |
630 | * log because of committed transactions that haven't hit the disk yet. | 625 | * log because of committed transactions that haven't hit the disk yet. |
631 | * Likewise, there could be unflushed non-transactional changes to the | 626 | * Likewise, there could be unflushed non-transactional changes to the |
632 | * inode core that have to go to disk and this requires us to issue | 627 | * inode core that have to go to disk and this requires us to issue |
@@ -638,7 +633,7 @@ xfs_fsync( | |||
638 | */ | 633 | */ |
639 | xfs_ilock(ip, XFS_ILOCK_SHARED); | 634 | xfs_ilock(ip, XFS_ILOCK_SHARED); |
640 | 635 | ||
641 | if (!(ip->i_update_size || ip->i_update_core)) { | 636 | if (!ip->i_update_core) { |
642 | /* | 637 | /* |
643 | * Timestamps/size haven't changed since last inode flush or | 638 | * Timestamps/size haven't changed since last inode flush or |
644 | * inode transaction commit. That means either nothing got | 639 | * inode transaction commit. That means either nothing got |