Commit 84803fb7 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Ben Myers

xfs: log file size updates as part of unwritten extent conversion

If we convert and unwritten extent past the current i_size log the size update
as part of the extent manipulation transactions instead of doing an unlogged
metadata update later.
Reviewed-by: default avatarDave Chinner <dchinner@redhat.com>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarMark Tinguely <tinguely@sgi.com>
Signed-off-by: default avatarBen Myers <bpm@sgi.com>
parent 6923e686
...@@ -179,13 +179,14 @@ xfs_end_io( ...@@ -179,13 +179,14 @@ xfs_end_io(
ioend->io_error = -error; ioend->io_error = -error;
goto done; goto done;
} }
} else {
/*
* We might have to update the on-disk file size after
* extending writes.
*/
xfs_setfilesize(ioend);
} }
/*
* We might have to update the on-disk file size after extending
* writes.
*/
xfs_setfilesize(ioend);
done: done:
xfs_destroy_ioend(ioend); xfs_destroy_ioend(ioend);
} }
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include "xfs_ialloc_btree.h" #include "xfs_ialloc_btree.h"
#include "xfs_dinode.h" #include "xfs_dinode.h"
#include "xfs_inode.h" #include "xfs_inode.h"
#include "xfs_inode_item.h"
#include "xfs_btree.h" #include "xfs_btree.h"
#include "xfs_bmap.h" #include "xfs_bmap.h"
#include "xfs_rtalloc.h" #include "xfs_rtalloc.h"
...@@ -645,6 +646,7 @@ xfs_iomap_write_unwritten( ...@@ -645,6 +646,7 @@ xfs_iomap_write_unwritten(
xfs_trans_t *tp; xfs_trans_t *tp;
xfs_bmbt_irec_t imap; xfs_bmbt_irec_t imap;
xfs_bmap_free_t free_list; xfs_bmap_free_t free_list;
xfs_fsize_t i_size;
uint resblks; uint resblks;
int committed; int committed;
int error; int error;
...@@ -705,7 +707,22 @@ xfs_iomap_write_unwritten( ...@@ -705,7 +707,22 @@ xfs_iomap_write_unwritten(
if (error) if (error)
goto error_on_bmapi_transaction; goto error_on_bmapi_transaction;
error = xfs_bmap_finish(&(tp), &(free_list), &committed); /*
* Log the updated inode size as we go. We have to be careful
* to only log it up to the actual write offset if it is
* halfway into a block.
*/
i_size = XFS_FSB_TO_B(mp, offset_fsb + count_fsb);
if (i_size > offset + count)
i_size = offset + count;
i_size = xfs_new_eof(ip, i_size);
if (i_size) {
ip->i_d.di_size = i_size;
xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
}
error = xfs_bmap_finish(&tp, &free_list, &committed);
if (error) if (error)
goto error_on_bmapi_transaction; goto error_on_bmapi_transaction;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment