aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs
diff options
context:
space:
mode:
Diffstat (limited to 'fs/xfs')
-rw-r--r--fs/xfs/xfs_aops.c2
-rw-r--r--fs/xfs/xfs_bmap.c15
-rw-r--r--fs/xfs/xfs_file.c45
-rw-r--r--fs/xfs/xfs_fs_subr.c2
-rw-r--r--fs/xfs/xfs_iget.c1
-rw-r--r--fs/xfs/xfs_inode.c8
-rw-r--r--fs/xfs/xfs_inode.h16
-rw-r--r--fs/xfs/xfs_iomap.c12
-rw-r--r--fs/xfs/xfs_iops.c3
-rw-r--r--fs/xfs/xfs_qm_syscalls.c1
-rw-r--r--fs/xfs/xfs_trace.h2
-rw-r--r--fs/xfs/xfs_vnodeops.c31
12 files changed, 56 insertions, 82 deletions
diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c
index 574d4ee9b625..4d27ea117e0e 100644
--- a/fs/xfs/xfs_aops.c
+++ b/fs/xfs/xfs_aops.c
@@ -111,7 +111,7 @@ xfs_ioend_new_eof(
111 xfs_fsize_t bsize; 111 xfs_fsize_t bsize;
112 112
113 bsize = ioend->io_offset + ioend->io_size; 113 bsize = ioend->io_offset + ioend->io_size;
114 isize = MAX(ip->i_size, ip->i_new_size); 114 isize = MAX(i_size_read(VFS_I(ip)), ip->i_new_size);
115 isize = MIN(isize, bsize); 115 isize = MIN(isize, bsize);
116 return isize > ip->i_d.di_size ? isize : 0; 116 return isize > ip->i_d.di_size ? isize : 0;
117} 117}
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;
diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
index f675f3d9d7b3..86d5dc260464 100644
--- a/fs/xfs/xfs_file.c
+++ b/fs/xfs/xfs_file.c
@@ -327,7 +327,7 @@ xfs_file_aio_read(
327 mp->m_rtdev_targp : mp->m_ddev_targp; 327 mp->m_rtdev_targp : mp->m_ddev_targp;
328 if ((iocb->ki_pos & target->bt_smask) || 328 if ((iocb->ki_pos & target->bt_smask) ||
329 (size & target->bt_smask)) { 329 (size & target->bt_smask)) {
330 if (iocb->ki_pos == ip->i_size) 330 if (iocb->ki_pos == i_size_read(inode))
331 return 0; 331 return 0;
332 return -XFS_ERROR(EINVAL); 332 return -XFS_ERROR(EINVAL);
333 } 333 }
@@ -412,30 +412,6 @@ xfs_file_splice_read(
412 return ret; 412 return ret;
413} 413}
414 414
415STATIC void
416xfs_aio_write_isize_update(
417 struct inode *inode,
418 loff_t *ppos,
419 ssize_t bytes_written)
420{
421 struct xfs_inode *ip = XFS_I(inode);
422 xfs_fsize_t isize = i_size_read(inode);
423
424 if (bytes_written > 0)
425 XFS_STATS_ADD(xs_write_bytes, bytes_written);
426
427 if (unlikely(bytes_written < 0 && bytes_written != -EFAULT &&
428 *ppos > isize))
429 *ppos = isize;
430
431 if (*ppos > ip->i_size) {
432 xfs_rw_ilock(ip, XFS_ILOCK_EXCL);
433 if (*ppos > ip->i_size)
434 ip->i_size = *ppos;
435 xfs_rw_iunlock(ip, XFS_ILOCK_EXCL);
436 }
437}
438
439/* 415/*
440 * If this was a direct or synchronous I/O that failed (such as ENOSPC) then 416 * If this was a direct or synchronous I/O that failed (such as ENOSPC) then
441 * part of the I/O may have been written to disk before the error occurred. In 417 * part of the I/O may have been written to disk before the error occurred. In
@@ -451,8 +427,8 @@ xfs_aio_write_newsize_update(
451 xfs_rw_ilock(ip, XFS_ILOCK_EXCL); 427 xfs_rw_ilock(ip, XFS_ILOCK_EXCL);
452 if (new_size == ip->i_new_size) 428 if (new_size == ip->i_new_size)
453 ip->i_new_size = 0; 429 ip->i_new_size = 0;
454 if (ip->i_d.di_size > ip->i_size) 430 if (ip->i_d.di_size > i_size_read(VFS_I(ip)))
455 ip->i_d.di_size = ip->i_size; 431 ip->i_d.di_size = i_size_read(VFS_I(ip));
456 xfs_rw_iunlock(ip, XFS_ILOCK_EXCL); 432 xfs_rw_iunlock(ip, XFS_ILOCK_EXCL);
457 } 433 }
458} 434}
@@ -492,15 +468,16 @@ xfs_file_splice_write(
492 new_size = *ppos + count; 468 new_size = *ppos + count;
493 469
494 xfs_ilock(ip, XFS_ILOCK_EXCL); 470 xfs_ilock(ip, XFS_ILOCK_EXCL);
495 if (new_size > ip->i_size) 471 if (new_size > i_size_read(inode))
496 ip->i_new_size = new_size; 472 ip->i_new_size = new_size;
497 xfs_iunlock(ip, XFS_ILOCK_EXCL); 473 xfs_iunlock(ip, XFS_ILOCK_EXCL);
498 474
499 trace_xfs_file_splice_write(ip, count, *ppos, ioflags); 475 trace_xfs_file_splice_write(ip, count, *ppos, ioflags);
500 476
501 ret = generic_file_splice_write(pipe, outfilp, ppos, count, flags); 477 ret = generic_file_splice_write(pipe, outfilp, ppos, count, flags);
478 if (ret > 0)
479 XFS_STATS_ADD(xs_write_bytes, ret);
502 480
503 xfs_aio_write_isize_update(inode, ppos, ret);
504 xfs_aio_write_newsize_update(ip, new_size); 481 xfs_aio_write_newsize_update(ip, new_size);
505 xfs_iunlock(ip, XFS_IOLOCK_EXCL); 482 xfs_iunlock(ip, XFS_IOLOCK_EXCL);
506 return ret; 483 return ret;
@@ -728,14 +705,14 @@ restart:
728 * values are still valid. 705 * values are still valid.
729 */ 706 */
730 if ((ip->i_new_size && *pos > ip->i_new_size) || 707 if ((ip->i_new_size && *pos > ip->i_new_size) ||
731 (!ip->i_new_size && *pos > ip->i_size)) { 708 (!ip->i_new_size && *pos > i_size_read(inode))) {
732 if (*iolock == XFS_IOLOCK_SHARED) { 709 if (*iolock == XFS_IOLOCK_SHARED) {
733 xfs_rw_iunlock(ip, XFS_ILOCK_EXCL | *iolock); 710 xfs_rw_iunlock(ip, XFS_ILOCK_EXCL | *iolock);
734 *iolock = XFS_IOLOCK_EXCL; 711 *iolock = XFS_IOLOCK_EXCL;
735 xfs_rw_ilock(ip, XFS_ILOCK_EXCL | *iolock); 712 xfs_rw_ilock(ip, XFS_ILOCK_EXCL | *iolock);
736 goto restart; 713 goto restart;
737 } 714 }
738 error = -xfs_zero_eof(ip, *pos, ip->i_size); 715 error = -xfs_zero_eof(ip, *pos, i_size_read(inode));
739 } 716 }
740 717
741 /* 718 /*
@@ -744,7 +721,7 @@ restart:
744 * ip->i_new_size if this IO ends beyond any other in-flight writes. 721 * ip->i_new_size if this IO ends beyond any other in-flight writes.
745 */ 722 */
746 new_size = *pos + *count; 723 new_size = *pos + *count;
747 if (new_size > ip->i_size) { 724 if (new_size > i_size_read(inode)) {
748 if (new_size > ip->i_new_size) 725 if (new_size > ip->i_new_size)
749 ip->i_new_size = new_size; 726 ip->i_new_size = new_size;
750 *new_sizep = new_size; 727 *new_sizep = new_size;
@@ -957,11 +934,11 @@ xfs_file_aio_write(
957 ret = xfs_file_buffered_aio_write(iocb, iovp, nr_segs, pos, 934 ret = xfs_file_buffered_aio_write(iocb, iovp, nr_segs, pos,
958 ocount, &new_size, &iolock); 935 ocount, &new_size, &iolock);
959 936
960 xfs_aio_write_isize_update(inode, &iocb->ki_pos, ret);
961
962 if (ret <= 0) 937 if (ret <= 0)
963 goto out_unlock; 938 goto out_unlock;
964 939
940 XFS_STATS_ADD(xs_write_bytes, ret);
941
965 /* Handle various SYNC-type writes */ 942 /* Handle various SYNC-type writes */
966 if ((file->f_flags & O_DSYNC) || IS_SYNC(inode)) { 943 if ((file->f_flags & O_DSYNC) || IS_SYNC(inode)) {
967 loff_t end = pos + ret - 1; 944 loff_t end = pos + ret - 1;
diff --git a/fs/xfs/xfs_fs_subr.c b/fs/xfs/xfs_fs_subr.c
index ed88ed16811c..652b875a9d4c 100644
--- a/fs/xfs/xfs_fs_subr.c
+++ b/fs/xfs/xfs_fs_subr.c
@@ -90,7 +90,7 @@ xfs_wait_on_pages(
90 90
91 if (mapping_tagged(mapping, PAGECACHE_TAG_WRITEBACK)) { 91 if (mapping_tagged(mapping, PAGECACHE_TAG_WRITEBACK)) {
92 return -filemap_fdatawait_range(mapping, first, 92 return -filemap_fdatawait_range(mapping, first,
93 last == -1 ? ip->i_size - 1 : last); 93 last == -1 ? XFS_ISIZE(ip) - 1 : last);
94 } 94 }
95 return 0; 95 return 0;
96} 96}
diff --git a/fs/xfs/xfs_iget.c b/fs/xfs/xfs_iget.c
index a7cf7139f9ad..3b5b78aa3b87 100644
--- a/fs/xfs/xfs_iget.c
+++ b/fs/xfs/xfs_iget.c
@@ -94,7 +94,6 @@ xfs_inode_alloc(
94 ip->i_update_core = 0; 94 ip->i_update_core = 0;
95 ip->i_delayed_blks = 0; 95 ip->i_delayed_blks = 0;
96 memset(&ip->i_d, 0, sizeof(xfs_icdinode_t)); 96 memset(&ip->i_d, 0, sizeof(xfs_icdinode_t));
97 ip->i_size = 0;
98 ip->i_new_size = 0; 97 ip->i_new_size = 0;
99 98
100 return ip; 99 return ip;
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index 62603369b523..b21022499c2e 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -347,7 +347,6 @@ xfs_iformat(
347 return XFS_ERROR(EFSCORRUPTED); 347 return XFS_ERROR(EFSCORRUPTED);
348 } 348 }
349 ip->i_d.di_size = 0; 349 ip->i_d.di_size = 0;
350 ip->i_size = 0;
351 ip->i_df.if_u2.if_rdev = xfs_dinode_get_rdev(dip); 350 ip->i_df.if_u2.if_rdev = xfs_dinode_get_rdev(dip);
352 break; 351 break;
353 352
@@ -853,7 +852,6 @@ xfs_iread(
853 } 852 }
854 853
855 ip->i_delayed_blks = 0; 854 ip->i_delayed_blks = 0;
856 ip->i_size = ip->i_d.di_size;
857 855
858 /* 856 /*
859 * Mark the buffer containing the inode as something to keep 857 * Mark the buffer containing the inode as something to keep
@@ -1043,7 +1041,6 @@ xfs_ialloc(
1043 } 1041 }
1044 1042
1045 ip->i_d.di_size = 0; 1043 ip->i_d.di_size = 0;
1046 ip->i_size = 0;
1047 ip->i_d.di_nextents = 0; 1044 ip->i_d.di_nextents = 0;
1048 ASSERT(ip->i_d.di_nblocks == 0); 1045 ASSERT(ip->i_d.di_nblocks == 0);
1049 1046
@@ -1198,7 +1195,7 @@ xfs_itruncate_extents(
1198 int done = 0; 1195 int done = 0;
1199 1196
1200 ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL|XFS_IOLOCK_EXCL)); 1197 ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL|XFS_IOLOCK_EXCL));
1201 ASSERT(new_size <= ip->i_size); 1198 ASSERT(new_size <= XFS_ISIZE(ip));
1202 ASSERT(tp->t_flags & XFS_TRANS_PERM_LOG_RES); 1199 ASSERT(tp->t_flags & XFS_TRANS_PERM_LOG_RES);
1203 ASSERT(ip->i_itemp != NULL); 1200 ASSERT(ip->i_itemp != NULL);
1204 ASSERT(ip->i_itemp->ili_lock_flags == 0); 1201 ASSERT(ip->i_itemp->ili_lock_flags == 0);
@@ -1712,8 +1709,7 @@ xfs_ifree(
1712 ASSERT(ip->i_d.di_nlink == 0); 1709 ASSERT(ip->i_d.di_nlink == 0);
1713 ASSERT(ip->i_d.di_nextents == 0); 1710 ASSERT(ip->i_d.di_nextents == 0);
1714 ASSERT(ip->i_d.di_anextents == 0); 1711 ASSERT(ip->i_d.di_anextents == 0);
1715 ASSERT((ip->i_d.di_size == 0 && ip->i_size == 0) || 1712 ASSERT(ip->i_d.di_size == 0 || !S_ISREG(ip->i_d.di_mode));
1716 (!S_ISREG(ip->i_d.di_mode)));
1717 ASSERT(ip->i_d.di_nblocks == 0); 1713 ASSERT(ip->i_d.di_nblocks == 0);
1718 1714
1719 /* 1715 /*
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
diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c
index a27a44659da6..246c7d57c6f9 100644
--- a/fs/xfs/xfs_iomap.c
+++ b/fs/xfs/xfs_iomap.c
@@ -74,7 +74,7 @@ xfs_iomap_eof_align_last_fsb(
74 else if (mp->m_dalign) 74 else if (mp->m_dalign)
75 align = mp->m_dalign; 75 align = mp->m_dalign;
76 76
77 if (align && ip->i_size >= XFS_FSB_TO_B(mp, align)) 77 if (align && XFS_ISIZE(ip) >= XFS_FSB_TO_B(mp, align))
78 new_last_fsb = roundup_64(*last_fsb, align); 78 new_last_fsb = roundup_64(*last_fsb, align);
79 } 79 }
80 80
@@ -154,7 +154,7 @@ xfs_iomap_write_direct(
154 154
155 offset_fsb = XFS_B_TO_FSBT(mp, offset); 155 offset_fsb = XFS_B_TO_FSBT(mp, offset);
156 last_fsb = XFS_B_TO_FSB(mp, ((xfs_ufsize_t)(offset + count))); 156 last_fsb = XFS_B_TO_FSB(mp, ((xfs_ufsize_t)(offset + count)));
157 if ((offset + count) > ip->i_size) { 157 if ((offset + count) > XFS_ISIZE(ip)) {
158 error = xfs_iomap_eof_align_last_fsb(mp, ip, extsz, &last_fsb); 158 error = xfs_iomap_eof_align_last_fsb(mp, ip, extsz, &last_fsb);
159 if (error) 159 if (error)
160 goto error_out; 160 goto error_out;
@@ -211,7 +211,7 @@ xfs_iomap_write_direct(
211 xfs_trans_ijoin(tp, ip, 0); 211 xfs_trans_ijoin(tp, ip, 0);
212 212
213 bmapi_flag = 0; 213 bmapi_flag = 0;
214 if (offset < ip->i_size || extsz) 214 if (offset < XFS_ISIZE(ip) || extsz)
215 bmapi_flag |= XFS_BMAPI_PREALLOC; 215 bmapi_flag |= XFS_BMAPI_PREALLOC;
216 216
217 /* 217 /*
@@ -286,7 +286,7 @@ xfs_iomap_eof_want_preallocate(
286 int found_delalloc = 0; 286 int found_delalloc = 0;
287 287
288 *prealloc = 0; 288 *prealloc = 0;
289 if ((offset + count) <= ip->i_size) 289 if (offset + count <= XFS_ISIZE(ip))
290 return 0; 290 return 0;
291 291
292 /* 292 /*
@@ -340,7 +340,7 @@ xfs_iomap_prealloc_size(
340 * if we pass in alloc_blocks = 0. Hence the "+ 1" to 340 * if we pass in alloc_blocks = 0. Hence the "+ 1" to
341 * ensure we always pass in a non-zero value. 341 * ensure we always pass in a non-zero value.
342 */ 342 */
343 alloc_blocks = XFS_B_TO_FSB(mp, ip->i_size) + 1; 343 alloc_blocks = XFS_B_TO_FSB(mp, XFS_ISIZE(ip)) + 1;
344 alloc_blocks = XFS_FILEOFF_MIN(MAXEXTLEN, 344 alloc_blocks = XFS_FILEOFF_MIN(MAXEXTLEN,
345 rounddown_pow_of_two(alloc_blocks)); 345 rounddown_pow_of_two(alloc_blocks));
346 346
@@ -564,7 +564,7 @@ xfs_iomap_write_allocate(
564 * back.... 564 * back....
565 */ 565 */
566 nimaps = 1; 566 nimaps = 1;
567 end_fsb = XFS_B_TO_FSB(mp, ip->i_size); 567 end_fsb = XFS_B_TO_FSB(mp, XFS_ISIZE(ip));
568 error = xfs_bmap_last_offset(NULL, ip, &last_block, 568 error = xfs_bmap_last_offset(NULL, ip, &last_block,
569 XFS_DATA_FORK); 569 XFS_DATA_FORK);
570 if (error) 570 if (error)
diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
index f02eaa298d3c..ab302539e5b9 100644
--- a/fs/xfs/xfs_iops.c
+++ b/fs/xfs/xfs_iops.c
@@ -778,7 +778,7 @@ xfs_setattr_size(
778 lock_flags |= XFS_IOLOCK_EXCL; 778 lock_flags |= XFS_IOLOCK_EXCL;
779 xfs_ilock(ip, lock_flags); 779 xfs_ilock(ip, lock_flags);
780 780
781 oldsize = ip->i_size; 781 oldsize = inode->i_size;
782 newsize = iattr->ia_size; 782 newsize = iattr->ia_size;
783 783
784 /* 784 /*
@@ -897,7 +897,6 @@ xfs_setattr_size(
897 * they get written to. 897 * they get written to.
898 */ 898 */
899 ip->i_d.di_size = newsize; 899 ip->i_d.di_size = newsize;
900 ip->i_size = newsize;
901 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); 900 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
902 901
903 if (newsize <= oldsize) { 902 if (newsize <= oldsize) {
diff --git a/fs/xfs/xfs_qm_syscalls.c b/fs/xfs/xfs_qm_syscalls.c
index 27378650b5cb..eafbcff81f3a 100644
--- a/fs/xfs/xfs_qm_syscalls.c
+++ b/fs/xfs/xfs_qm_syscalls.c
@@ -265,7 +265,6 @@ xfs_qm_scall_trunc_qfile(
265 xfs_trans_ijoin(tp, ip, 0); 265 xfs_trans_ijoin(tp, ip, 0);
266 266
267 ip->i_d.di_size = 0; 267 ip->i_d.di_size = 0;
268 ip->i_size = 0;
269 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); 268 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
270 269
271 error = xfs_itruncate_extents(&tp, ip, XFS_DATA_FORK, 0); 270 error = xfs_itruncate_extents(&tp, ip, XFS_DATA_FORK, 0);
diff --git a/fs/xfs/xfs_trace.h b/fs/xfs/xfs_trace.h
index 81efa0416173..2aabcc9c507e 100644
--- a/fs/xfs/xfs_trace.h
+++ b/fs/xfs/xfs_trace.h
@@ -1038,7 +1038,7 @@ DECLARE_EVENT_CLASS(xfs_simple_io_class,
1038 TP_fast_assign( 1038 TP_fast_assign(
1039 __entry->dev = VFS_I(ip)->i_sb->s_dev; 1039 __entry->dev = VFS_I(ip)->i_sb->s_dev;
1040 __entry->ino = ip->i_ino; 1040 __entry->ino = ip->i_ino;
1041 __entry->isize = ip->i_size; 1041 __entry->isize = VFS_I(ip)->i_size;
1042 __entry->disize = ip->i_d.di_size; 1042 __entry->disize = ip->i_d.di_size;
1043 __entry->new_size = ip->i_new_size; 1043 __entry->new_size = ip->i_new_size;
1044 __entry->offset = offset; 1044 __entry->offset = offset;
diff --git a/fs/xfs/xfs_vnodeops.c b/fs/xfs/xfs_vnodeops.c
index 96ff03421753..0cf52da9d246 100644
--- a/fs/xfs/xfs_vnodeops.c
+++ b/fs/xfs/xfs_vnodeops.c
@@ -175,7 +175,7 @@ xfs_free_eofblocks(
175 * Figure out if there are any blocks beyond the end 175 * Figure out if there are any blocks beyond the end
176 * of the file. If not, then there is nothing to do. 176 * of the file. If not, then there is nothing to do.
177 */ 177 */
178 end_fsb = XFS_B_TO_FSB(mp, ((xfs_ufsize_t)ip->i_size)); 178 end_fsb = XFS_B_TO_FSB(mp, (xfs_ufsize_t)XFS_ISIZE(ip));
179 last_fsb = XFS_B_TO_FSB(mp, (xfs_ufsize_t)XFS_MAXIOFFSET(mp)); 179 last_fsb = XFS_B_TO_FSB(mp, (xfs_ufsize_t)XFS_MAXIOFFSET(mp));
180 if (last_fsb <= end_fsb) 180 if (last_fsb <= end_fsb)
181 return 0; 181 return 0;
@@ -233,7 +233,7 @@ xfs_free_eofblocks(
233 * may be full of holes (ie NULL files bug). 233 * may be full of holes (ie NULL files bug).
234 */ 234 */
235 error = xfs_itruncate_extents(&tp, ip, XFS_DATA_FORK, 235 error = xfs_itruncate_extents(&tp, ip, XFS_DATA_FORK,
236 ip->i_size); 236 XFS_ISIZE(ip));
237 if (error) { 237 if (error) {
238 /* 238 /*
239 * If we get an error at this point we simply don't 239 * If we get an error at this point we simply don't
@@ -547,8 +547,8 @@ xfs_release(
547 return 0; 547 return 0;
548 548
549 if ((S_ISREG(ip->i_d.di_mode) && 549 if ((S_ISREG(ip->i_d.di_mode) &&
550 ((ip->i_size > 0) || (VN_CACHED(VFS_I(ip)) > 0 || 550 (VFS_I(ip)->i_size > 0 ||
551 ip->i_delayed_blks > 0)) && 551 (VN_CACHED(VFS_I(ip)) > 0 || ip->i_delayed_blks > 0)) &&
552 (ip->i_df.if_flags & XFS_IFEXTENTS)) && 552 (ip->i_df.if_flags & XFS_IFEXTENTS)) &&
553 (!(ip->i_d.di_flags & (XFS_DIFLAG_PREALLOC | XFS_DIFLAG_APPEND)))) { 553 (!(ip->i_d.di_flags & (XFS_DIFLAG_PREALLOC | XFS_DIFLAG_APPEND)))) {
554 554
@@ -625,7 +625,7 @@ xfs_inactive(
625 * only one with a reference to the inode. 625 * only one with a reference to the inode.
626 */ 626 */
627 truncate = ((ip->i_d.di_nlink == 0) && 627 truncate = ((ip->i_d.di_nlink == 0) &&
628 ((ip->i_d.di_size != 0) || (ip->i_size != 0) || 628 ((ip->i_d.di_size != 0) || XFS_ISIZE(ip) != 0 ||
629 (ip->i_d.di_nextents > 0) || (ip->i_delayed_blks > 0)) && 629 (ip->i_d.di_nextents > 0) || (ip->i_delayed_blks > 0)) &&
630 S_ISREG(ip->i_d.di_mode)); 630 S_ISREG(ip->i_d.di_mode));
631 631
@@ -639,12 +639,12 @@ xfs_inactive(
639 639
640 if (ip->i_d.di_nlink != 0) { 640 if (ip->i_d.di_nlink != 0) {
641 if ((S_ISREG(ip->i_d.di_mode) && 641 if ((S_ISREG(ip->i_d.di_mode) &&
642 ((ip->i_size > 0) || (VN_CACHED(VFS_I(ip)) > 0 || 642 (VFS_I(ip)->i_size > 0 ||
643 ip->i_delayed_blks > 0)) && 643 (VN_CACHED(VFS_I(ip)) > 0 || ip->i_delayed_blks > 0)) &&
644 (ip->i_df.if_flags & XFS_IFEXTENTS) && 644 (ip->i_df.if_flags & XFS_IFEXTENTS) &&
645 (!(ip->i_d.di_flags & 645 (!(ip->i_d.di_flags &
646 (XFS_DIFLAG_PREALLOC | XFS_DIFLAG_APPEND)) || 646 (XFS_DIFLAG_PREALLOC | XFS_DIFLAG_APPEND)) ||
647 (ip->i_delayed_blks != 0)))) { 647 ip->i_delayed_blks != 0))) {
648 error = xfs_free_eofblocks(mp, ip, 0); 648 error = xfs_free_eofblocks(mp, ip, 0);
649 if (error) 649 if (error)
650 return VN_INACTIVE_CACHE; 650 return VN_INACTIVE_CACHE;
@@ -678,7 +678,6 @@ xfs_inactive(
678 xfs_trans_ijoin(tp, ip, 0); 678 xfs_trans_ijoin(tp, ip, 0);
679 679
680 ip->i_d.di_size = 0; 680 ip->i_d.di_size = 0;
681 ip->i_size = 0;
682 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); 681 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
683 682
684 error = xfs_itruncate_extents(&tp, ip, XFS_DATA_FORK, 0); 683 error = xfs_itruncate_extents(&tp, ip, XFS_DATA_FORK, 0);
@@ -1974,11 +1973,11 @@ xfs_zero_remaining_bytes(
1974 * since nothing can read beyond eof. The space will 1973 * since nothing can read beyond eof. The space will
1975 * be zeroed when the file is extended anyway. 1974 * be zeroed when the file is extended anyway.
1976 */ 1975 */
1977 if (startoff >= ip->i_size) 1976 if (startoff >= XFS_ISIZE(ip))
1978 return 0; 1977 return 0;
1979 1978
1980 if (endoff > ip->i_size) 1979 if (endoff > XFS_ISIZE(ip))
1981 endoff = ip->i_size; 1980 endoff = XFS_ISIZE(ip);
1982 1981
1983 bp = xfs_buf_get_uncached(XFS_IS_REALTIME_INODE(ip) ? 1982 bp = xfs_buf_get_uncached(XFS_IS_REALTIME_INODE(ip) ?
1984 mp->m_rtdev_targp : mp->m_ddev_targp, 1983 mp->m_rtdev_targp : mp->m_ddev_targp,
@@ -2273,7 +2272,7 @@ xfs_change_file_space(
2273 bf->l_start += offset; 2272 bf->l_start += offset;
2274 break; 2273 break;
2275 case 2: /*SEEK_END*/ 2274 case 2: /*SEEK_END*/
2276 bf->l_start += ip->i_size; 2275 bf->l_start += XFS_ISIZE(ip);
2277 break; 2276 break;
2278 default: 2277 default:
2279 return XFS_ERROR(EINVAL); 2278 return XFS_ERROR(EINVAL);
@@ -2290,7 +2289,7 @@ xfs_change_file_space(
2290 bf->l_whence = 0; 2289 bf->l_whence = 0;
2291 2290
2292 startoffset = bf->l_start; 2291 startoffset = bf->l_start;
2293 fsize = ip->i_size; 2292 fsize = XFS_ISIZE(ip);
2294 2293
2295 /* 2294 /*
2296 * XFS_IOC_RESVSP and XFS_IOC_UNRESVSP will reserve or unreserve 2295 * XFS_IOC_RESVSP and XFS_IOC_UNRESVSP will reserve or unreserve