public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@infradead.org>
To: xfs@oss.sgi.com
Subject: [PATCH 12/45] xfs: do not require an ioend for new EOF calculation
Date: Fri, 28 Oct 2011 05:54:35 -0400	[thread overview]
Message-ID: <20111028100337.764643102@bombadil.infradead.org> (raw)
In-Reply-To: 20111028095423.796574703@bombadil.infradead.org

[-- Attachment #1: xfs-simplify-eof-calculation --]
[-- Type: text/plain, Size: 3075 bytes --]

Replace xfs_ioend_new_eof with a new inline xfs_new_eof helper that
doesn't require and ioend, and is available also outside of xfs_aops.c.

Also make the code a bit more clear by using a normal if statement
instead of a slightly misleading MIN().

Signed-off-by: Christoph Hellwig <hch@lst.de>

---
 fs/xfs/xfs_aops.c  |   24 ++++--------------------
 fs/xfs/xfs_inode.h |   14 ++++++++++++++
 2 files changed, 18 insertions(+), 20 deletions(-)

Index: xfs/fs/xfs/xfs_aops.c
===================================================================
--- xfs.orig/fs/xfs/xfs_aops.c	2011-10-27 22:39:57.490177027 +0200
+++ xfs/fs/xfs/xfs_aops.c	2011-10-27 22:39:58.142174495 +0200
@@ -99,23 +99,6 @@ 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 = MIN(i_size_read(VFS_I(ip)), bsize);
-	return isize > ip->i_d.di_size ? isize : 0;
-}
-
-/*
  * Fast and loose check if this write could update the on-disk inode size.
  */
 static inline bool xfs_ioend_is_append(struct xfs_ioend *ioend)
@@ -135,7 +118,7 @@ xfs_setfilesize(
 	xfs_fsize_t		isize;
 
 	xfs_ilock(ip, XFS_ILOCK_EXCL);
-	isize = xfs_ioend_new_eof(ioend);
+	isize = xfs_new_eof(ip, ioend->io_offset + ioend->io_size);
 	if (isize) {
 		trace_xfs_setfilesize(ip, ioend->io_offset, ioend->io_size);
 		ip->i_d.di_size = isize;
@@ -357,6 +340,7 @@ xfs_submit_ioend_bio(
 	xfs_ioend_t		*ioend,
 	struct bio		*bio)
 {
+	struct xfs_inode	*ip = XFS_I(ioend->io_inode);
 	atomic_inc(&ioend->io_remaining);
 	bio->bi_private = ioend;
 	bio->bi_end_io = xfs_end_bio;
@@ -365,8 +349,8 @@ xfs_submit_ioend_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(XFS_I(ioend->io_inode));
+	if (xfs_new_eof(ip, ioend->io_offset + ioend->io_size))
+		xfs_mark_inode_dirty(ip);
 
 	submit_bio(wbc->sync_mode == WB_SYNC_ALL ? WRITE_SYNC : WRITE, bio);
 }
Index: xfs/fs/xfs/xfs_inode.h
===================================================================
--- xfs.orig/fs/xfs/xfs_inode.h	2011-10-27 22:39:56.080672114 +0200
+++ xfs/fs/xfs/xfs_inode.h	2011-10-27 22:39:58.142174495 +0200
@@ -275,6 +275,20 @@ static inline xfs_fsize_t XFS_ISIZE(stru
 }
 
 /*
+ * If this I/O goes past the on-disk inode size update it unless it would
+ * be past the current in-core inode size.
+ */
+static inline xfs_fsize_t
+xfs_new_eof(struct xfs_inode *ip, xfs_fsize_t new_size)
+{
+	xfs_fsize_t i_size = i_size_read(VFS_I(ip));
+
+	if (new_size > i_size)
+		new_size = i_size;
+	return new_size > ip->i_d.di_size ? new_size : 0;
+}
+
+/*
  * i_flags helper functions
  */
 static inline void

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

  parent reply	other threads:[~2011-10-28 10:03 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-28  9:54 [PATCH 00/45] write back all metadata via the AIL (and remove xfsbufd) Christoph Hellwig
2011-10-28  9:54 ` [PATCH 01/45] xfs: constify xfs_item_ops Christoph Hellwig
2011-10-28  9:54 ` [PATCH 02/45] xfs: make i_flags an unsigned long Christoph Hellwig
2011-10-28  9:54 ` [PATCH 03/45] xfs: replace i_flock with a sleeping bitlock Christoph Hellwig
2011-10-28  9:54 ` [PATCH 04/45] xfs: replace i_pin_wait with a bit waitqueue Christoph Hellwig
2011-10-28  9:54 ` [PATCH 05/45] xfs: remove the unused dm_attrs structure Christoph Hellwig
2011-10-28  9:54 ` [PATCH 06/45] xfs: remove xfs_itruncate_data Christoph Hellwig
2011-10-28  9:54 ` [PATCH 07/45] xfs: cleanup xfs_iomap_eof_align_last_fsb Christoph Hellwig
2011-10-28  9:54 ` [PATCH 08/45] xfs: remove the i_size field in struct xfs_inode Christoph Hellwig
2011-10-28  9:54 ` [PATCH 09/45] xfs: remove the i_new_size " Christoph Hellwig
2011-10-28  9:54 ` [PATCH 10/45] fix: force shutdown handling in xfs_end_io Christoph Hellwig
2011-11-05  8:11   ` Christoph Hellwig
2011-10-28  9:54 ` [PATCH 11/45] xfs: use per-filesystem I/O completion workqueues Christoph Hellwig
2011-10-28  9:54 ` Christoph Hellwig [this message]
2011-10-28  9:54 ` [PATCH 16/45] xfs: untange SYNC_WAIT and SYNC_TRYLOCK meanings for xfs_qm_dqflush Christoph Hellwig
2011-10-28  9:54 ` [PATCH 17/45] xfs: make sure to really flush all dquots in xfs_qm_quotacheck Christoph Hellwig
2011-10-28  9:54 ` [PATCH 18/45] xfs: remove xfs_qm_sync Christoph Hellwig
2011-10-28  9:54 ` [PATCH 19/45] xfs: remove the sync_mode argument to xfs_qm_dqflush_all Christoph Hellwig
2011-10-28  9:54 ` [PATCH 20/45] xfs: cleanup dquot locking helpers Christoph Hellwig
2011-10-28  9:54 ` [PATCH 21/45] xfs: cleanup xfs_qm_dqlookup Christoph Hellwig
2011-10-28  9:54 ` [PATCH 22/45] xfs: remove XFS_DQ_INACTIVE Christoph Hellwig
2011-10-28  9:54 ` [PATCH 23/45] xfs: implement lazy removal for the dquot freelist Christoph Hellwig
2011-10-28  9:54 ` [PATCH 24/45] xfs: flatten the dquot lock ordering Christoph Hellwig
2011-10-28  9:54 ` [PATCH 25/45] xfs: nest the qm_dqfrlist_lock insise the dquot qlock Christoph Hellwig
2011-10-28  9:54 ` [PATCH 26/45] xfs: simplify xfs_qm_dqattach_grouphint Christoph Hellwig
2011-10-28  9:54 ` [PATCH 27/45] xfs: add a xfs_dqhold helper Christoph Hellwig
2011-10-28  9:54 ` [PATCH 28/45] xfs: kill xfs_qm_dqinit_core Christoph Hellwig
2011-10-28  9:54 ` [PATCH 29/45] xfs: kill xfs_qm_idtodq Christoph Hellwig
2011-10-28  9:54 ` [PATCH 30/45] xfs: remove XFS_QMOPT_DQSUSER Christoph Hellwig
2011-10-28  9:54 ` [PATCH 31/45] xfs: simplify xfs_qm_detach_gdquots Christoph Hellwig
2011-10-28  9:54 ` [PATCH 32/45] xfs: use a normal shrinker for the dquot freelist Christoph Hellwig
2011-10-28  9:54 ` [PATCH 33/45] xfs: reclaim clean dquots first Christoph Hellwig
2011-10-28  9:54 ` [PATCH 34/45] xfs: do flush inodes during asynchronous inode reclaim Christoph Hellwig
2011-10-28  9:54 ` [PATCH 35/45] xfs: remove log item from AIL in xfs_qm_dqflush after a shutdown Christoph Hellwig
2011-10-28  9:54 ` [PATCH 36/45] xfs: remove log item from AIL in xfs_iflush " Christoph Hellwig
2011-10-28  9:55 ` [PATCH 37/45] xfs: implement freezing by emptying the AIL Christoph Hellwig
2011-10-28  9:55 ` [PATCH 38/45] xfs: explicitly empty the AIL on unmount Christoph Hellwig
2011-10-28  9:55 ` [PATCH 39/45] xfs: do not write the buffer from xfs_iflush Christoph Hellwig
2011-10-28  9:55 ` [PATCH 40/45] xfs: do not write the buffer from xfs_qm_dqflush Christoph Hellwig
2011-10-28  9:55 ` [PATCH 41/45] xfs: do not add buffers to the delwri queue until pushed Christoph Hellwig
2011-10-28  9:55 ` [PATCH 42/45] xfs: on-stack delayed write buffer lists Christoph Hellwig
2011-10-28  9:55 ` [PATCH 43/45] xfs: do not try to unpin the inode buffer in xfs_iflush Christoph Hellwig
2011-10-28  9:55 ` [PATCH 44/45] xfs: do not try to unpin the inode buffer in xfs_qm_dq_flush Christoph Hellwig
2011-10-28  9:55 ` [PATCH 45/45] xfs: force the log in xfs_buf_wait_unpin 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=20111028100337.764643102@bombadil.infradead.org \
    --to=hch@infradead.org \
    --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