Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 167173
b: refs/heads/master
c: 932640e
h: refs/heads/master
i:
  167171: 5b47f5e
v: v3
  • Loading branch information
Dave Chinner authored and Alex Elder committed Oct 8, 2009
1 parent f71ce8f commit 67aabb2
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 10 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 69961a26b82931601e07c9e3656bd90c598f2395
refs/heads/master: 932640e8adaff3d0c28ee32d4863c7a7a74df055
37 changes: 28 additions & 9 deletions trunk/fs/xfs/linux-2.6/xfs_aops.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,35 +185,48 @@ xfs_destroy_ioend(
mempool_free(ioend, xfs_ioend_pool);
}

/*
* If the end of the current ioend is beyond the current EOF,
* return the new EOF value, otherwise zero.
*/
STATIC xfs_fsize_t
xfs_ioend_new_eof(
xfs_ioend_t *ioend)
{
xfs_inode_t *ip = XFS_I(ioend->io_inode);
xfs_fsize_t isize;
xfs_fsize_t bsize;

bsize = ioend->io_offset + ioend->io_size;
isize = MAX(ip->i_size, ip->i_new_size);
isize = MIN(isize, bsize);
return isize > ip->i_d.di_size ? isize : 0;
}

/*
* Update on-disk file size now that data has been written to disk.
* The current in-memory file size is i_size. If a write is beyond
* eof i_new_size will be the intended file size until i_size is
* updated. If this write does not extend all the way to the valid
* file size then restrict this update to the end of the write.
*/

STATIC void
xfs_setfilesize(
xfs_ioend_t *ioend)
{
xfs_inode_t *ip = XFS_I(ioend->io_inode);
xfs_fsize_t isize;
xfs_fsize_t bsize;

ASSERT((ip->i_d.di_mode & S_IFMT) == S_IFREG);
ASSERT(ioend->io_type != IOMAP_READ);

if (unlikely(ioend->io_error))
return;

bsize = ioend->io_offset + ioend->io_size;

xfs_ilock(ip, XFS_ILOCK_EXCL);

isize = MAX(ip->i_size, ip->i_new_size);
isize = MIN(isize, bsize);

if (ip->i_d.di_size < isize) {
isize = xfs_ioend_new_eof(ioend);
if (isize) {
ip->i_d.di_size = isize;
xfs_mark_inode_dirty_sync(ip);
}
Expand Down Expand Up @@ -403,10 +416,16 @@ xfs_submit_ioend_bio(
struct bio *bio)
{
atomic_inc(&ioend->io_remaining);

bio->bi_private = ioend;
bio->bi_end_io = xfs_end_bio;

/*
* If the I/O is beyond EOF we mark the inode dirty immediately
* but don't update the inode size until I/O completion.
*/
if (xfs_ioend_new_eof(ioend))
xfs_mark_inode_dirty_sync(XFS_I(ioend->io_inode));

submit_bio(WRITE, bio);
ASSERT(!bio_flagged(bio, BIO_EOPNOTSUPP));
bio_put(bio);
Expand Down

0 comments on commit 67aabb2

Please sign in to comment.