X-Spam-Checker-Version: SpamAssassin 3.4.0-r929098 (2010-03-30) on oss.sgi.com X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham version=3.4.0-r929098 Received: from cuda.sgi.com (cuda2.sgi.com [192.48.176.25]) by oss.sgi.com (8.14.3/8.14.3/SuSE Linux 0.8) with ESMTP id pAFKESaS067876 for ; Tue, 15 Nov 2011 14:14:29 -0600 X-ASG-Debug-ID: 1321388067-0dfe00ee0000-NocioJ X-Barracuda-URL: http://cuda.sgi.com:80/cgi-bin/mark.cgi Received: from bombadil.infradead.org (localhost [127.0.0.1]) by cuda.sgi.com (Spam Firewall) with ESMTP id A84F324FCAF for ; Tue, 15 Nov 2011 12:14:27 -0800 (PST) Received: from bombadil.infradead.org (173-166-109-252-newengland.hfc.comcastbusiness.net [173.166.109.252]) by cuda.sgi.com with ESMTP id F7B4s6ssfFZEfZov for ; Tue, 15 Nov 2011 12:14:27 -0800 (PST) Received: from hch by bombadil.infradead.org with local (Exim 4.76 #1 (Red Hat Linux)) id 1RQPOl-0007Ss-4S for xfs@oss.sgi.com; Tue, 15 Nov 2011 20:14:27 +0000 Message-Id: <20111115201427.104680606@bombadil.infradead.org> User-Agent: quilt/0.48-1 Date: Tue, 15 Nov 2011 15:14:11 -0500 From: Christoph Hellwig To: xfs@oss.sgi.com X-ASG-Orig-Subj: [PATCH 4/5] xfs: log file size updates as part of unwritten extent conversion Subject: [PATCH 4/5] xfs: log file size updates as part of unwritten extent conversion References: <20111115201407.038216766@bombadil.infradead.org> Content-Disposition: inline; filename=xfs-piggy-back-unwritten-size-updates X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org See http://www.infradead.org/rpr.html X-Barracuda-Connect: 173-166-109-252-newengland.hfc.comcastbusiness.net[173.166.109.252] X-Barracuda-Start-Time: 1321388067 X-Barracuda-Bayes: INNOCENT GLOBAL 0.0000 1.0000 -2.0210 X-Barracuda-Virus-Scanned: by cuda.sgi.com at sgi.com X-Barracuda-Spam-Score: -1.42 X-Barracuda-Spam-Status: No, SCORE=-1.42 using per-user scores of TAG_LEVEL=2.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=2.1 tests=BSF_SC5_MJ1963, RDNS_DYNAMIC X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.2.80344 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- 0.10 RDNS_DYNAMIC Delivered to trusted network by host with dynamic-looking rDNS 0.50 BSF_SC5_MJ1963 Custom Rule MJ1963 X-Virus-Scanned: ClamAV version 0.94.2, clamav-milter version 0.94.2 on oss.sgi.com X-Virus-Status: Clean 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. Signed-off-by: Christoph Hellwig --- fs/xfs/xfs_aops.c | 11 ++++++----- fs/xfs/xfs_iomap.c | 19 ++++++++++++++++++- 2 files changed, 24 insertions(+), 6 deletions(-) Index: linux-2.6/fs/xfs/xfs_iomap.c =================================================================== --- linux-2.6.orig/fs/xfs/xfs_iomap.c 2011-11-08 08:02:50.234386118 +0100 +++ linux-2.6/fs/xfs/xfs_iomap.c 2011-11-08 08:14:04.319888994 +0100 @@ -31,6 +31,7 @@ #include "xfs_ialloc_btree.h" #include "xfs_dinode.h" #include "xfs_inode.h" +#include "xfs_inode_item.h" #include "xfs_btree.h" #include "xfs_bmap.h" #include "xfs_rtalloc.h" @@ -645,6 +646,7 @@ xfs_iomap_write_unwritten( xfs_trans_t *tp; xfs_bmbt_irec_t imap; xfs_bmap_free_t free_list; + xfs_fsize_t i_size; uint resblks; int committed; int error; @@ -705,7 +707,22 @@ xfs_iomap_write_unwritten( if (error) 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) goto error_on_bmapi_transaction; Index: linux-2.6/fs/xfs/xfs_aops.c =================================================================== --- linux-2.6.orig/fs/xfs/xfs_aops.c 2011-11-08 08:12:31.586400976 +0100 +++ linux-2.6/fs/xfs/xfs_aops.c 2011-11-08 08:14:04.319888994 +0100 @@ -183,13 +183,14 @@ xfs_end_io( ioend->io_error = -error; 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: xfs_destroy_ioend(ioend); }