[XFS] ensure file size is logged on synchronous writes
Synchronous writes currently log inode changes before syncing pages to disk. Since the file size is updated on I/O completion we wont be writing out the updated file size and if we crash the file will have the wrong size. This change moves the logging after the syncing of the pages to ensure we log the correct file size. SGI-PV: 970334 SGI-Modid: xfs-linux-melb:xfs-kern:29649a Signed-off-by: Lachlan McIlroy <lachlan@sgi.com> Signed-off-by: Christoph Hellwig <hch@infradead.org> Signed-off-by: Tim Shimmin <tes@sgi.com>
This commit is contained in:
committed by
Tim Shimmin
parent
cc92e7ac8d
commit
5903c4956f
@@ -838,20 +838,19 @@ retry:
|
|||||||
|
|
||||||
/* Handle various SYNC-type writes */
|
/* Handle various SYNC-type writes */
|
||||||
if ((file->f_flags & O_SYNC) || IS_SYNC(inode)) {
|
if ((file->f_flags & O_SYNC) || IS_SYNC(inode)) {
|
||||||
error = xfs_write_sync_logforce(mp, xip);
|
int error2;
|
||||||
if (error)
|
|
||||||
goto out_unlock_internal;
|
|
||||||
|
|
||||||
xfs_rwunlock(xip, locktype);
|
xfs_rwunlock(xip, locktype);
|
||||||
if (need_i_mutex)
|
if (need_i_mutex)
|
||||||
mutex_unlock(&inode->i_mutex);
|
mutex_unlock(&inode->i_mutex);
|
||||||
|
error2 = sync_page_range(inode, mapping, pos, ret);
|
||||||
error = sync_page_range(inode, mapping, pos, ret);
|
|
||||||
if (!error)
|
if (!error)
|
||||||
error = -ret;
|
error = error2;
|
||||||
if (need_i_mutex)
|
if (need_i_mutex)
|
||||||
mutex_lock(&inode->i_mutex);
|
mutex_lock(&inode->i_mutex);
|
||||||
xfs_rwlock(xip, locktype);
|
xfs_rwlock(xip, locktype);
|
||||||
|
error2 = xfs_write_sync_logforce(mp, xip);
|
||||||
|
if (!error)
|
||||||
|
error = error2;
|
||||||
}
|
}
|
||||||
|
|
||||||
out_unlock_internal:
|
out_unlock_internal:
|
||||||
|
Reference in New Issue
Block a user