aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_bmap.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@infradead.org>2011-12-18 15:00:11 -0500
committerBen Myers <bpm@sgi.com>2012-01-17 16:08:53 -0500
commitce7ae151ddada3dbf67301464343c154903166b3 (patch)
treedb56a153e7ae07aa5103d001a7d7252dc0891c7e /fs/xfs/xfs_bmap.c
parentf392e6319a4e9a028b0c8b48f000bb01d660ad53 (diff)
xfs: remove the i_size field in struct xfs_inode
There is no fundamental need to keep an in-memory inode size copy in the XFS inode. We already have the on-disk value in the dinode, and the separate in-memory copy that we need for regular files only in the XFS inode. Remove the xfs_inode i_size field and change the XFS_ISIZE macro to use the VFS inode i_size field for regular files. Switch code that was directly accessing the i_size field in the xfs_inode to XFS_ISIZE, or in cases where we are limited to regular files direct access of the VFS inode i_size field. This also allows dropping some fairly complicated code in the write path which dealt with keeping the xfs_inode i_size uptodate with the VFS i_size that is getting updated inside ->write_end. Note that we do not bother resetting the VFS i_size when truncating a file that gets freed to zero as there is no point in doing so because the VFS inode is no longer in use at this point. Just relax the assert in xfs_ifree to only check the on-disk size instead. Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Ben Myers <bpm@sgi.com>
Diffstat (limited to 'fs/xfs/xfs_bmap.c')
-rw-r--r--fs/xfs/xfs_bmap.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c
index 7a888ca2f7f6..188ef2fbd628 100644
--- a/fs/xfs/xfs_bmap.c
+++ b/fs/xfs/xfs_bmap.c
@@ -3997,11 +3997,8 @@ xfs_bmap_one_block(
3997 xfs_bmbt_irec_t s; /* internal version of extent */ 3997 xfs_bmbt_irec_t s; /* internal version of extent */
3998 3998
3999#ifndef DEBUG 3999#ifndef DEBUG
4000 if (whichfork == XFS_DATA_FORK) { 4000 if (whichfork == XFS_DATA_FORK)
4001 return S_ISREG(ip->i_d.di_mode) ? 4001 return XFS_ISIZE(ip) == ip->i_mount->m_sb.sb_blocksize;
4002 (ip->i_size == ip->i_mount->m_sb.sb_blocksize) :
4003 (ip->i_d.di_size == ip->i_mount->m_sb.sb_blocksize);
4004 }
4005#endif /* !DEBUG */ 4002#endif /* !DEBUG */
4006 if (XFS_IFORK_NEXTENTS(ip, whichfork) != 1) 4003 if (XFS_IFORK_NEXTENTS(ip, whichfork) != 1)
4007 return 0; 4004 return 0;
@@ -4013,7 +4010,7 @@ xfs_bmap_one_block(
4013 xfs_bmbt_get_all(ep, &s); 4010 xfs_bmbt_get_all(ep, &s);
4014 rval = s.br_startoff == 0 && s.br_blockcount == 1; 4011 rval = s.br_startoff == 0 && s.br_blockcount == 1;
4015 if (rval && whichfork == XFS_DATA_FORK) 4012 if (rval && whichfork == XFS_DATA_FORK)
4016 ASSERT(ip->i_size == ip->i_mount->m_sb.sb_blocksize); 4013 ASSERT(XFS_ISIZE(ip) == ip->i_mount->m_sb.sb_blocksize);
4017 return rval; 4014 return rval;
4018} 4015}
4019 4016
@@ -5427,7 +5424,7 @@ xfs_getbmapx_fix_eof_hole(
5427 if (startblock == HOLESTARTBLOCK) { 5424 if (startblock == HOLESTARTBLOCK) {
5428 mp = ip->i_mount; 5425 mp = ip->i_mount;
5429 out->bmv_block = -1; 5426 out->bmv_block = -1;
5430 fixlen = XFS_FSB_TO_BB(mp, XFS_B_TO_FSB(mp, ip->i_size)); 5427 fixlen = XFS_FSB_TO_BB(mp, XFS_B_TO_FSB(mp, XFS_ISIZE(ip)));
5431 fixlen -= out->bmv_offset; 5428 fixlen -= out->bmv_offset;
5432 if (prealloced && out->bmv_offset + out->bmv_length == end) { 5429 if (prealloced && out->bmv_offset + out->bmv_length == end) {
5433 /* Came to hole at EOF. Trim it. */ 5430 /* Came to hole at EOF. Trim it. */
@@ -5515,7 +5512,7 @@ xfs_getbmap(
5515 fixlen = XFS_MAXIOFFSET(mp); 5512 fixlen = XFS_MAXIOFFSET(mp);
5516 } else { 5513 } else {
5517 prealloced = 0; 5514 prealloced = 0;
5518 fixlen = ip->i_size; 5515 fixlen = XFS_ISIZE(ip);
5519 } 5516 }
5520 } 5517 }
5521 5518
@@ -5544,7 +5541,7 @@ xfs_getbmap(
5544 5541
5545 xfs_ilock(ip, XFS_IOLOCK_SHARED); 5542 xfs_ilock(ip, XFS_IOLOCK_SHARED);
5546 if (whichfork == XFS_DATA_FORK && !(iflags & BMV_IF_DELALLOC)) { 5543 if (whichfork == XFS_DATA_FORK && !(iflags & BMV_IF_DELALLOC)) {
5547 if (ip->i_delayed_blks || ip->i_size > ip->i_d.di_size) { 5544 if (ip->i_delayed_blks || XFS_ISIZE(ip) > ip->i_d.di_size) {
5548 error = xfs_flush_pages(ip, 0, -1, 0, FI_REMAPF); 5545 error = xfs_flush_pages(ip, 0, -1, 0, FI_REMAPF);
5549 if (error) 5546 if (error)
5550 goto out_unlock_iolock; 5547 goto out_unlock_iolock;