aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_inode.h
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_inode.h
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_inode.h')
-rw-r--r--fs/xfs/xfs_inode.h16
1 files changed, 12 insertions, 4 deletions
diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
index 4acbe740be46..cd99e43fa8f0 100644
--- a/fs/xfs/xfs_inode.h
+++ b/fs/xfs/xfs_inode.h
@@ -246,16 +246,12 @@ typedef struct xfs_inode {
246 246
247 xfs_icdinode_t i_d; /* most of ondisk inode */ 247 xfs_icdinode_t i_d; /* most of ondisk inode */
248 248
249 xfs_fsize_t i_size; /* in-memory size */
250 xfs_fsize_t i_new_size; /* size when write completes */ 249 xfs_fsize_t i_new_size; /* size when write completes */
251 250
252 /* VFS inode */ 251 /* VFS inode */
253 struct inode i_vnode; /* embedded VFS inode */ 252 struct inode i_vnode; /* embedded VFS inode */
254} xfs_inode_t; 253} xfs_inode_t;
255 254
256#define XFS_ISIZE(ip) S_ISREG((ip)->i_d.di_mode) ? \
257 (ip)->i_size : (ip)->i_d.di_size;
258
259/* Convert from vfs inode to xfs inode */ 255/* Convert from vfs inode to xfs inode */
260static inline struct xfs_inode *XFS_I(struct inode *inode) 256static inline struct xfs_inode *XFS_I(struct inode *inode)
261{ 257{
@@ -269,6 +265,18 @@ static inline struct inode *VFS_I(struct xfs_inode *ip)
269} 265}
270 266
271/* 267/*
268 * For regular files we only update the on-disk filesize when actually
269 * writing data back to disk. Until then only the copy in the VFS inode
270 * is uptodate.
271 */
272static inline xfs_fsize_t XFS_ISIZE(struct xfs_inode *ip)
273{
274 if (S_ISREG(ip->i_d.di_mode))
275 return i_size_read(VFS_I(ip));
276 return ip->i_d.di_size;
277}
278
279/*
272 * i_flags helper functions 280 * i_flags helper functions
273 */ 281 */
274static inline void 282static inline void