From: Christoph Hellwig <hch@infradead.org>
To: aelder@sgi.com, xfs@oss.sgi.com, akpm@linux-foundation.org,
sfr@canb.auug.org.au
Cc: linux-fsdevel@vger.kernel.org, Dave Chinner <david@fromorbit.com>
Subject: [PATCH 4/5] xfs: mark inodes dirty before issuing I/O
Date: Tue, 06 Oct 2009 16:29:29 -0400 [thread overview]
Message-ID: <20091006203643.373897212@bombadil.infradead.org> (raw)
In-Reply-To: 20091006202925.459164320@bombadil.infradead.org
[-- Attachment #1: xfs-mark-inode-dirty-early --]
[-- Type: text/plain, Size: 2536 bytes --]
From: Dave Chinner <david@fromorbit.com>
To make sure they get properly waited on in sync when I/O is in flight and
we latter need to update the inode size. Requires a new helper to check if an
ioend structure is beyond the current EOF.
Signed-off-by: Dave Chinner <david@fromorbit.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Index: xfs/fs/xfs/linux-2.6/xfs_aops.c
===================================================================
--- xfs.orig/fs/xfs/linux-2.6/xfs_aops.c 2009-09-16 10:04:29.799026911 -0300
+++ xfs/fs/xfs/linux-2.6/xfs_aops.c 2009-09-16 10:04:32.153003970 -0300
@@ -186,19 +186,37 @@ xfs_destroy_ioend(
}
/*
+ * 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);
@@ -206,14 +224,9 @@ xfs_setfilesize(
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);
}
@@ -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);
next prev parent reply other threads:[~2009-10-06 20:37 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-06 20:29 [PATCH 0/5] XFS fixes for 2.6.32 Christoph Hellwig
2009-10-06 20:29 ` [PATCH 1/5] xfs: implement ->dirty_inode to fix timestamp handling Christoph Hellwig
2009-10-06 20:29 ` [PATCH 2/5] [PATCH 5/5] xfs: fix xfs_quiesce_data Christoph Hellwig
2009-10-06 20:29 ` [PATCH 3/5] [PATCH 2/5] xfs: cleanup ->sync_fs Christoph Hellwig
2009-10-06 20:29 ` Christoph Hellwig [this message]
2009-10-06 20:29 ` [PATCH 5/5] xfs: make sure xfs_sync_fsdata covers the log Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20091006203643.373897212@bombadil.infradead.org \
--to=hch@infradead.org \
--cc=aelder@sgi.com \
--cc=akpm@linux-foundation.org \
--cc=david@fromorbit.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=sfr@canb.auug.org.au \
--cc=xfs@oss.sgi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).