aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_vnodeops.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/xfs/xfs_vnodeops.c')
-rw-r--r--fs/xfs/xfs_vnodeops.c165
1 files changed, 47 insertions, 118 deletions
diff --git a/fs/xfs/xfs_vnodeops.c b/fs/xfs/xfs_vnodeops.c
index efd5aff9eaf6..51305242ff8c 100644
--- a/fs/xfs/xfs_vnodeops.c
+++ b/fs/xfs/xfs_vnodeops.c
@@ -88,7 +88,7 @@ xfs_getattr(
88 bhv_vnode_t *vp = XFS_ITOV(ip); 88 bhv_vnode_t *vp = XFS_ITOV(ip);
89 xfs_mount_t *mp = ip->i_mount; 89 xfs_mount_t *mp = ip->i_mount;
90 90
91 vn_trace_entry(ip, __FUNCTION__, (inst_t *)__return_address); 91 xfs_itrace_entry(ip);
92 92
93 if (XFS_FORCED_SHUTDOWN(mp)) 93 if (XFS_FORCED_SHUTDOWN(mp))
94 return XFS_ERROR(EIO); 94 return XFS_ERROR(EIO);
@@ -136,7 +136,7 @@ xfs_getattr(
136 default: 136 default:
137 vap->va_rdev = 0; 137 vap->va_rdev = 0;
138 138
139 if (!(ip->i_d.di_flags & XFS_DIFLAG_REALTIME)) { 139 if (!(XFS_IS_REALTIME_INODE(ip))) {
140 vap->va_blocksize = xfs_preferred_iosize(mp); 140 vap->va_blocksize = xfs_preferred_iosize(mp);
141 } else { 141 } else {
142 142
@@ -228,7 +228,7 @@ xfs_setattr(
228 int file_owner; 228 int file_owner;
229 int need_iolock = 1; 229 int need_iolock = 1;
230 230
231 vn_trace_entry(ip, __FUNCTION__, (inst_t *)__return_address); 231 xfs_itrace_entry(ip);
232 232
233 if (mp->m_flags & XFS_MOUNT_RDONLY) 233 if (mp->m_flags & XFS_MOUNT_RDONLY)
234 return XFS_ERROR(EROFS); 234 return XFS_ERROR(EROFS);
@@ -508,7 +508,7 @@ xfs_setattr(
508 */ 508 */
509 if ((ip->i_d.di_nextents || ip->i_delayed_blks) && 509 if ((ip->i_d.di_nextents || ip->i_delayed_blks) &&
510 (mask & XFS_AT_XFLAGS) && 510 (mask & XFS_AT_XFLAGS) &&
511 (ip->i_d.di_flags & XFS_DIFLAG_REALTIME) != 511 (XFS_IS_REALTIME_INODE(ip)) !=
512 (vap->va_xflags & XFS_XFLAG_REALTIME)) { 512 (vap->va_xflags & XFS_XFLAG_REALTIME)) {
513 code = XFS_ERROR(EINVAL); /* EFBIG? */ 513 code = XFS_ERROR(EINVAL); /* EFBIG? */
514 goto error_return; 514 goto error_return;
@@ -520,7 +520,7 @@ xfs_setattr(
520 if ((mask & XFS_AT_EXTSIZE) && vap->va_extsize != 0) { 520 if ((mask & XFS_AT_EXTSIZE) && vap->va_extsize != 0) {
521 xfs_extlen_t size; 521 xfs_extlen_t size;
522 522
523 if ((ip->i_d.di_flags & XFS_DIFLAG_REALTIME) || 523 if (XFS_IS_REALTIME_INODE(ip) ||
524 ((mask & XFS_AT_XFLAGS) && 524 ((mask & XFS_AT_XFLAGS) &&
525 (vap->va_xflags & XFS_XFLAG_REALTIME))) { 525 (vap->va_xflags & XFS_XFLAG_REALTIME))) {
526 size = mp->m_sb.sb_rextsize << 526 size = mp->m_sb.sb_rextsize <<
@@ -804,12 +804,8 @@ xfs_setattr(
804 if (vap->va_xflags & XFS_XFLAG_EXTSZINHERIT) 804 if (vap->va_xflags & XFS_XFLAG_EXTSZINHERIT)
805 di_flags |= XFS_DIFLAG_EXTSZINHERIT; 805 di_flags |= XFS_DIFLAG_EXTSZINHERIT;
806 } else if ((ip->i_d.di_mode & S_IFMT) == S_IFREG) { 806 } else if ((ip->i_d.di_mode & S_IFMT) == S_IFREG) {
807 if (vap->va_xflags & XFS_XFLAG_REALTIME) { 807 if (vap->va_xflags & XFS_XFLAG_REALTIME)
808 di_flags |= XFS_DIFLAG_REALTIME; 808 di_flags |= XFS_DIFLAG_REALTIME;
809 ip->i_iocore.io_flags |= XFS_IOCORE_RT;
810 } else {
811 ip->i_iocore.io_flags &= ~XFS_IOCORE_RT;
812 }
813 if (vap->va_xflags & XFS_XFLAG_EXTSIZE) 809 if (vap->va_xflags & XFS_XFLAG_EXTSIZE)
814 di_flags |= XFS_DIFLAG_EXTSIZE; 810 di_flags |= XFS_DIFLAG_EXTSIZE;
815 } 811 }
@@ -902,28 +898,6 @@ xfs_setattr(
902 return code; 898 return code;
903} 899}
904 900
905
906/*
907 * xfs_access
908 * Null conversion from vnode mode bits to inode mode bits, as in efs.
909 */
910int
911xfs_access(
912 xfs_inode_t *ip,
913 int mode,
914 cred_t *credp)
915{
916 int error;
917
918 vn_trace_entry(ip, __FUNCTION__, (inst_t *)__return_address);
919
920 xfs_ilock(ip, XFS_ILOCK_SHARED);
921 error = xfs_iaccess(ip, mode, credp);
922 xfs_iunlock(ip, XFS_ILOCK_SHARED);
923 return error;
924}
925
926
927/* 901/*
928 * The maximum pathlen is 1024 bytes. Since the minimum file system 902 * The maximum pathlen is 1024 bytes. Since the minimum file system
929 * blocksize is 512 bytes, we can get a max of 2 extents back from 903 * blocksize is 512 bytes, we can get a max of 2 extents back from
@@ -987,7 +961,7 @@ xfs_readlink(
987 int pathlen; 961 int pathlen;
988 int error = 0; 962 int error = 0;
989 963
990 vn_trace_entry(ip, __FUNCTION__, (inst_t *)__return_address); 964 xfs_itrace_entry(ip);
991 965
992 if (XFS_FORCED_SHUTDOWN(mp)) 966 if (XFS_FORCED_SHUTDOWN(mp))
993 return XFS_ERROR(EIO); 967 return XFS_ERROR(EIO);
@@ -1033,7 +1007,7 @@ xfs_fsync(
1033 int error; 1007 int error;
1034 int log_flushed = 0, changed = 1; 1008 int log_flushed = 0, changed = 1;
1035 1009
1036 vn_trace_entry(ip, __FUNCTION__, (inst_t *)__return_address); 1010 xfs_itrace_entry(ip);
1037 1011
1038 ASSERT(start >= 0 && stop >= -1); 1012 ASSERT(start >= 0 && stop >= -1);
1039 1013
@@ -1149,7 +1123,7 @@ xfs_fsync(
1149 * If this inode is on the RT dev we need to flush that 1123 * If this inode is on the RT dev we need to flush that
1150 * cache as well. 1124 * cache as well.
1151 */ 1125 */
1152 if (ip->i_d.di_flags & XFS_DIFLAG_REALTIME) 1126 if (XFS_IS_REALTIME_INODE(ip))
1153 xfs_blkdev_issue_flush(ip->i_mount->m_rtdev_targp); 1127 xfs_blkdev_issue_flush(ip->i_mount->m_rtdev_targp);
1154 } 1128 }
1155 1129
@@ -1188,7 +1162,7 @@ xfs_free_eofblocks(
1188 1162
1189 nimaps = 1; 1163 nimaps = 1;
1190 xfs_ilock(ip, XFS_ILOCK_SHARED); 1164 xfs_ilock(ip, XFS_ILOCK_SHARED);
1191 error = XFS_BMAPI(mp, NULL, &ip->i_iocore, end_fsb, map_len, 0, 1165 error = xfs_bmapi(NULL, ip, end_fsb, map_len, 0,
1192 NULL, 0, &imap, &nimaps, NULL, NULL); 1166 NULL, 0, &imap, &nimaps, NULL, NULL);
1193 xfs_iunlock(ip, XFS_ILOCK_SHARED); 1167 xfs_iunlock(ip, XFS_ILOCK_SHARED);
1194 1168
@@ -1562,9 +1536,6 @@ xfs_release(
1562 error = xfs_free_eofblocks(mp, ip, XFS_FREE_EOF_LOCK); 1536 error = xfs_free_eofblocks(mp, ip, XFS_FREE_EOF_LOCK);
1563 if (error) 1537 if (error)
1564 return error; 1538 return error;
1565 /* Update linux inode block count after free above */
1566 vn_to_inode(vp)->i_blocks = XFS_FSB_TO_BB(mp,
1567 ip->i_d.di_nblocks + ip->i_delayed_blks);
1568 } 1539 }
1569 } 1540 }
1570 1541
@@ -1592,7 +1563,7 @@ xfs_inactive(
1592 int error; 1563 int error;
1593 int truncate; 1564 int truncate;
1594 1565
1595 vn_trace_entry(ip, __FUNCTION__, (inst_t *)__return_address); 1566 xfs_itrace_entry(ip);
1596 1567
1597 /* 1568 /*
1598 * If the inode is already free, then there can be nothing 1569 * If the inode is already free, then there can be nothing
@@ -1638,9 +1609,6 @@ xfs_inactive(
1638 error = xfs_free_eofblocks(mp, ip, XFS_FREE_EOF_LOCK); 1609 error = xfs_free_eofblocks(mp, ip, XFS_FREE_EOF_LOCK);
1639 if (error) 1610 if (error)
1640 return VN_INACTIVE_CACHE; 1611 return VN_INACTIVE_CACHE;
1641 /* Update linux inode block count after free above */
1642 vn_to_inode(vp)->i_blocks = XFS_FSB_TO_BB(mp,
1643 ip->i_d.di_nblocks + ip->i_delayed_blks);
1644 } 1612 }
1645 goto out; 1613 goto out;
1646 } 1614 }
@@ -1805,7 +1773,7 @@ xfs_lookup(
1805 int error; 1773 int error;
1806 uint lock_mode; 1774 uint lock_mode;
1807 1775
1808 vn_trace_entry(dp, __FUNCTION__, (inst_t *)__return_address); 1776 xfs_itrace_entry(dp);
1809 1777
1810 if (XFS_FORCED_SHUTDOWN(dp->i_mount)) 1778 if (XFS_FORCED_SHUTDOWN(dp->i_mount))
1811 return XFS_ERROR(EIO); 1779 return XFS_ERROR(EIO);
@@ -1814,7 +1782,7 @@ xfs_lookup(
1814 error = xfs_dir_lookup_int(dp, lock_mode, dentry, &e_inum, &ip); 1782 error = xfs_dir_lookup_int(dp, lock_mode, dentry, &e_inum, &ip);
1815 if (!error) { 1783 if (!error) {
1816 *vpp = XFS_ITOV(ip); 1784 *vpp = XFS_ITOV(ip);
1817 ITRACE(ip); 1785 xfs_itrace_ref(ip);
1818 } 1786 }
1819 xfs_iunlock_map_shared(dp, lock_mode); 1787 xfs_iunlock_map_shared(dp, lock_mode);
1820 return error; 1788 return error;
@@ -1848,7 +1816,7 @@ xfs_create(
1848 int namelen; 1816 int namelen;
1849 1817
1850 ASSERT(!*vpp); 1818 ASSERT(!*vpp);
1851 vn_trace_entry(dp, __FUNCTION__, (inst_t *)__return_address); 1819 xfs_itrace_entry(dp);
1852 1820
1853 namelen = VNAMELEN(dentry); 1821 namelen = VNAMELEN(dentry);
1854 1822
@@ -1930,7 +1898,7 @@ xfs_create(
1930 goto error_return; 1898 goto error_return;
1931 goto abort_return; 1899 goto abort_return;
1932 } 1900 }
1933 ITRACE(ip); 1901 xfs_itrace_ref(ip);
1934 1902
1935 /* 1903 /*
1936 * At this point, we've gotten a newly allocated inode. 1904 * At this point, we've gotten a newly allocated inode.
@@ -2098,7 +2066,7 @@ again:
2098 2066
2099 e_inum = ip->i_ino; 2067 e_inum = ip->i_ino;
2100 2068
2101 ITRACE(ip); 2069 xfs_itrace_ref(ip);
2102 2070
2103 /* 2071 /*
2104 * We want to lock in increasing inum. Since we've already 2072 * We want to lock in increasing inum. Since we've already
@@ -2321,7 +2289,7 @@ xfs_remove(
2321 uint resblks; 2289 uint resblks;
2322 int namelen; 2290 int namelen;
2323 2291
2324 vn_trace_entry(dp, __FUNCTION__, (inst_t *)__return_address); 2292 xfs_itrace_entry(dp);
2325 2293
2326 if (XFS_FORCED_SHUTDOWN(mp)) 2294 if (XFS_FORCED_SHUTDOWN(mp))
2327 return XFS_ERROR(EIO); 2295 return XFS_ERROR(EIO);
@@ -2364,9 +2332,8 @@ xfs_remove(
2364 2332
2365 dm_di_mode = ip->i_d.di_mode; 2333 dm_di_mode = ip->i_d.di_mode;
2366 2334
2367 vn_trace_entry(ip, __FUNCTION__, (inst_t *)__return_address); 2335 xfs_itrace_entry(ip);
2368 2336 xfs_itrace_ref(ip);
2369 ITRACE(ip);
2370 2337
2371 error = XFS_QM_DQATTACH(mp, dp, 0); 2338 error = XFS_QM_DQATTACH(mp, dp, 0);
2372 if (!error && dp != ip) 2339 if (!error && dp != ip)
@@ -2498,8 +2465,7 @@ xfs_remove(
2498 if (link_zero && xfs_inode_is_filestream(ip)) 2465 if (link_zero && xfs_inode_is_filestream(ip))
2499 xfs_filestream_deassociate(ip); 2466 xfs_filestream_deassociate(ip);
2500 2467
2501 vn_trace_exit(ip, __FUNCTION__, (inst_t *)__return_address); 2468 xfs_itrace_exit(ip);
2502
2503 IRELE(ip); 2469 IRELE(ip);
2504 2470
2505/* Fall through to std_return with error = 0 */ 2471/* Fall through to std_return with error = 0 */
@@ -2562,8 +2528,8 @@ xfs_link(
2562 char *target_name = VNAME(dentry); 2528 char *target_name = VNAME(dentry);
2563 int target_namelen; 2529 int target_namelen;
2564 2530
2565 vn_trace_entry(tdp, __FUNCTION__, (inst_t *)__return_address); 2531 xfs_itrace_entry(tdp);
2566 vn_trace_entry(xfs_vtoi(src_vp), __FUNCTION__, (inst_t *)__return_address); 2532 xfs_itrace_entry(xfs_vtoi(src_vp));
2567 2533
2568 target_namelen = VNAMELEN(dentry); 2534 target_namelen = VNAMELEN(dentry);
2569 ASSERT(!VN_ISDIR(src_vp)); 2535 ASSERT(!VN_ISDIR(src_vp));
@@ -2744,7 +2710,7 @@ xfs_mkdir(
2744 2710
2745 /* Return through std_return after this point. */ 2711 /* Return through std_return after this point. */
2746 2712
2747 vn_trace_entry(dp, __FUNCTION__, (inst_t *)__return_address); 2713 xfs_itrace_entry(dp);
2748 2714
2749 mp = dp->i_mount; 2715 mp = dp->i_mount;
2750 udqp = gdqp = NULL; 2716 udqp = gdqp = NULL;
@@ -2810,7 +2776,7 @@ xfs_mkdir(
2810 goto error_return; 2776 goto error_return;
2811 goto abort_return; 2777 goto abort_return;
2812 } 2778 }
2813 ITRACE(cdp); 2779 xfs_itrace_ref(cdp);
2814 2780
2815 /* 2781 /*
2816 * Now we add the directory inode to the transaction. 2782 * Now we add the directory inode to the transaction.
@@ -2936,7 +2902,7 @@ xfs_rmdir(
2936 int last_cdp_link; 2902 int last_cdp_link;
2937 uint resblks; 2903 uint resblks;
2938 2904
2939 vn_trace_entry(dp, __FUNCTION__, (inst_t *)__return_address); 2905 xfs_itrace_entry(dp);
2940 2906
2941 if (XFS_FORCED_SHUTDOWN(mp)) 2907 if (XFS_FORCED_SHUTDOWN(mp))
2942 return XFS_ERROR(EIO); 2908 return XFS_ERROR(EIO);
@@ -3041,7 +3007,7 @@ xfs_rmdir(
3041 VN_HOLD(dir_vp); 3007 VN_HOLD(dir_vp);
3042 } 3008 }
3043 3009
3044 ITRACE(cdp); 3010 xfs_itrace_ref(cdp);
3045 xfs_trans_ijoin(tp, cdp, XFS_ILOCK_EXCL); 3011 xfs_trans_ijoin(tp, cdp, XFS_ILOCK_EXCL);
3046 3012
3047 ASSERT(cdp->i_d.di_nlink >= 2); 3013 ASSERT(cdp->i_d.di_nlink >= 2);
@@ -3189,8 +3155,7 @@ xfs_symlink(
3189 ip = NULL; 3155 ip = NULL;
3190 tp = NULL; 3156 tp = NULL;
3191 3157
3192 vn_trace_entry(dp, __FUNCTION__, (inst_t *)__return_address); 3158 xfs_itrace_entry(dp);
3193
3194 3159
3195 if (XFS_FORCED_SHUTDOWN(mp)) 3160 if (XFS_FORCED_SHUTDOWN(mp))
3196 return XFS_ERROR(EIO); 3161 return XFS_ERROR(EIO);
@@ -3317,7 +3282,7 @@ xfs_symlink(
3317 goto error_return; 3282 goto error_return;
3318 goto error1; 3283 goto error1;
3319 } 3284 }
3320 ITRACE(ip); 3285 xfs_itrace_ref(ip);
3321 3286
3322 /* 3287 /*
3323 * An error after we've joined dp to the transaction will result in the 3288 * An error after we've joined dp to the transaction will result in the
@@ -3465,27 +3430,6 @@ std_return:
3465 goto std_return; 3430 goto std_return;
3466} 3431}
3467 3432
3468
3469int
3470xfs_fid2(
3471 xfs_inode_t *ip,
3472 xfs_fid_t *xfid)
3473{
3474 vn_trace_entry(ip, __FUNCTION__, (inst_t *)__return_address);
3475
3476 xfid->fid_len = sizeof(xfs_fid_t) - sizeof(xfid->fid_len);
3477 xfid->fid_pad = 0;
3478 /*
3479 * use memcpy because the inode is a long long and there's no
3480 * assurance that xfid->fid_ino is properly aligned.
3481 */
3482 memcpy(&xfid->fid_ino, &ip->i_ino, sizeof(xfid->fid_ino));
3483 xfid->fid_gen = ip->i_d.di_gen;
3484
3485 return 0;
3486}
3487
3488
3489int 3433int
3490xfs_rwlock( 3434xfs_rwlock(
3491 xfs_inode_t *ip, 3435 xfs_inode_t *ip,
@@ -3558,11 +3502,11 @@ xfs_inode_flush(
3558 if (iip && iip->ili_last_lsn) { 3502 if (iip && iip->ili_last_lsn) {
3559 xlog_t *log = mp->m_log; 3503 xlog_t *log = mp->m_log;
3560 xfs_lsn_t sync_lsn; 3504 xfs_lsn_t sync_lsn;
3561 int s, log_flags = XFS_LOG_FORCE; 3505 int log_flags = XFS_LOG_FORCE;
3562 3506
3563 s = GRANT_LOCK(log); 3507 spin_lock(&log->l_grant_lock);
3564 sync_lsn = log->l_last_sync_lsn; 3508 sync_lsn = log->l_last_sync_lsn;
3565 GRANT_UNLOCK(log, s); 3509 spin_unlock(&log->l_grant_lock);
3566 3510
3567 if ((XFS_LSN_CMP(iip->ili_last_lsn, sync_lsn) > 0)) { 3511 if ((XFS_LSN_CMP(iip->ili_last_lsn, sync_lsn) > 0)) {
3568 if (flags & FLUSH_SYNC) 3512 if (flags & FLUSH_SYNC)
@@ -3637,8 +3581,8 @@ xfs_set_dmattrs(
3637 xfs_ilock(ip, XFS_ILOCK_EXCL); 3581 xfs_ilock(ip, XFS_ILOCK_EXCL);
3638 xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL); 3582 xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
3639 3583
3640 ip->i_iocore.io_dmevmask = ip->i_d.di_dmevmask = evmask; 3584 ip->i_d.di_dmevmask = evmask;
3641 ip->i_iocore.io_dmstate = ip->i_d.di_dmstate = state; 3585 ip->i_d.di_dmstate = state;
3642 3586
3643 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); 3587 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
3644 IHOLD(ip); 3588 IHOLD(ip);
@@ -3653,7 +3597,7 @@ xfs_reclaim(
3653{ 3597{
3654 bhv_vnode_t *vp = XFS_ITOV(ip); 3598 bhv_vnode_t *vp = XFS_ITOV(ip);
3655 3599
3656 vn_trace_entry(ip, __FUNCTION__, (inst_t *)__return_address); 3600 xfs_itrace_entry(ip);
3657 3601
3658 ASSERT(!VN_MAPPED(vp)); 3602 ASSERT(!VN_MAPPED(vp));
3659 3603
@@ -3871,7 +3815,7 @@ xfs_alloc_file_space(
3871 int committed; 3815 int committed;
3872 int error; 3816 int error;
3873 3817
3874 vn_trace_entry(ip, __FUNCTION__, (inst_t *)__return_address); 3818 xfs_itrace_entry(ip);
3875 3819
3876 if (XFS_FORCED_SHUTDOWN(mp)) 3820 if (XFS_FORCED_SHUTDOWN(mp))
3877 return XFS_ERROR(EIO); 3821 return XFS_ERROR(EIO);
@@ -3976,7 +3920,7 @@ retry:
3976 * Issue the xfs_bmapi() call to allocate the blocks 3920 * Issue the xfs_bmapi() call to allocate the blocks
3977 */ 3921 */
3978 XFS_BMAP_INIT(&free_list, &firstfsb); 3922 XFS_BMAP_INIT(&free_list, &firstfsb);
3979 error = XFS_BMAPI(mp, tp, &ip->i_iocore, startoffset_fsb, 3923 error = xfs_bmapi(tp, ip, startoffset_fsb,
3980 allocatesize_fsb, bmapi_flag, 3924 allocatesize_fsb, bmapi_flag,
3981 &firstfsb, 0, imapp, &nimaps, 3925 &firstfsb, 0, imapp, &nimaps,
3982 &free_list, NULL); 3926 &free_list, NULL);
@@ -4052,13 +3996,13 @@ xfs_zero_remaining_bytes(
4052 int error = 0; 3996 int error = 0;
4053 3997
4054 bp = xfs_buf_get_noaddr(mp->m_sb.sb_blocksize, 3998 bp = xfs_buf_get_noaddr(mp->m_sb.sb_blocksize,
4055 ip->i_d.di_flags & XFS_DIFLAG_REALTIME ? 3999 XFS_IS_REALTIME_INODE(ip) ?
4056 mp->m_rtdev_targp : mp->m_ddev_targp); 4000 mp->m_rtdev_targp : mp->m_ddev_targp);
4057 4001
4058 for (offset = startoff; offset <= endoff; offset = lastoffset + 1) { 4002 for (offset = startoff; offset <= endoff; offset = lastoffset + 1) {
4059 offset_fsb = XFS_B_TO_FSBT(mp, offset); 4003 offset_fsb = XFS_B_TO_FSBT(mp, offset);
4060 nimap = 1; 4004 nimap = 1;
4061 error = XFS_BMAPI(mp, NULL, &ip->i_iocore, offset_fsb, 1, 0, 4005 error = xfs_bmapi(NULL, ip, offset_fsb, 1, 0,
4062 NULL, 0, &imap, &nimap, NULL, NULL); 4006 NULL, 0, &imap, &nimap, NULL, NULL);
4063 if (error || nimap < 1) 4007 if (error || nimap < 1)
4064 break; 4008 break;
@@ -4141,7 +4085,7 @@ xfs_free_file_space(
4141 vp = XFS_ITOV(ip); 4085 vp = XFS_ITOV(ip);
4142 mp = ip->i_mount; 4086 mp = ip->i_mount;
4143 4087
4144 vn_trace_entry(ip, __FUNCTION__, (inst_t *)__return_address); 4088 xfs_itrace_entry(ip);
4145 4089
4146 if ((error = XFS_QM_DQATTACH(mp, ip, 0))) 4090 if ((error = XFS_QM_DQATTACH(mp, ip, 0)))
4147 return error; 4091 return error;
@@ -4149,7 +4093,7 @@ xfs_free_file_space(
4149 error = 0; 4093 error = 0;
4150 if (len <= 0) /* if nothing being freed */ 4094 if (len <= 0) /* if nothing being freed */
4151 return error; 4095 return error;
4152 rt = (ip->i_d.di_flags & XFS_DIFLAG_REALTIME); 4096 rt = XFS_IS_REALTIME_INODE(ip);
4153 startoffset_fsb = XFS_B_TO_FSB(mp, offset); 4097 startoffset_fsb = XFS_B_TO_FSB(mp, offset);
4154 end_dmi_offset = offset + len; 4098 end_dmi_offset = offset + len;
4155 endoffset_fsb = XFS_B_TO_FSBT(mp, end_dmi_offset); 4099 endoffset_fsb = XFS_B_TO_FSBT(mp, end_dmi_offset);
@@ -4172,15 +4116,12 @@ xfs_free_file_space(
4172 vn_iowait(ip); /* wait for the completion of any pending DIOs */ 4116 vn_iowait(ip); /* wait for the completion of any pending DIOs */
4173 } 4117 }
4174 4118
4175 rounding = max_t(uint, 1 << mp->m_sb.sb_blocklog, NBPP); 4119 rounding = max_t(uint, 1 << mp->m_sb.sb_blocklog, PAGE_CACHE_SIZE);
4176 ioffset = offset & ~(rounding - 1); 4120 ioffset = offset & ~(rounding - 1);
4177 4121
4178 if (VN_CACHED(vp) != 0) { 4122 if (VN_CACHED(vp) != 0) {
4179 xfs_inval_cached_trace(&ip->i_iocore, ioffset, -1, 4123 xfs_inval_cached_trace(ip, ioffset, -1, ioffset, -1);
4180 ctooff(offtoct(ioffset)), -1); 4124 error = xfs_flushinval_pages(ip, ioffset, -1, FI_REMAPF_LOCKED);
4181 error = xfs_flushinval_pages(ip,
4182 ctooff(offtoct(ioffset)),
4183 -1, FI_REMAPF_LOCKED);
4184 if (error) 4125 if (error)
4185 goto out_unlock_iolock; 4126 goto out_unlock_iolock;
4186 } 4127 }
@@ -4193,7 +4134,7 @@ xfs_free_file_space(
4193 */ 4134 */
4194 if (rt && !XFS_SB_VERSION_HASEXTFLGBIT(&mp->m_sb)) { 4135 if (rt && !XFS_SB_VERSION_HASEXTFLGBIT(&mp->m_sb)) {
4195 nimap = 1; 4136 nimap = 1;
4196 error = XFS_BMAPI(mp, NULL, &ip->i_iocore, startoffset_fsb, 4137 error = xfs_bmapi(NULL, ip, startoffset_fsb,
4197 1, 0, NULL, 0, &imap, &nimap, NULL, NULL); 4138 1, 0, NULL, 0, &imap, &nimap, NULL, NULL);
4198 if (error) 4139 if (error)
4199 goto out_unlock_iolock; 4140 goto out_unlock_iolock;
@@ -4208,7 +4149,7 @@ xfs_free_file_space(
4208 startoffset_fsb += mp->m_sb.sb_rextsize - mod; 4149 startoffset_fsb += mp->m_sb.sb_rextsize - mod;
4209 } 4150 }
4210 nimap = 1; 4151 nimap = 1;
4211 error = XFS_BMAPI(mp, NULL, &ip->i_iocore, endoffset_fsb - 1, 4152 error = xfs_bmapi(NULL, ip, endoffset_fsb - 1,
4212 1, 0, NULL, 0, &imap, &nimap, NULL, NULL); 4153 1, 0, NULL, 0, &imap, &nimap, NULL, NULL);
4213 if (error) 4154 if (error)
4214 goto out_unlock_iolock; 4155 goto out_unlock_iolock;
@@ -4284,7 +4225,7 @@ xfs_free_file_space(
4284 * issue the bunmapi() call to free the blocks 4225 * issue the bunmapi() call to free the blocks
4285 */ 4226 */
4286 XFS_BMAP_INIT(&free_list, &firstfsb); 4227 XFS_BMAP_INIT(&free_list, &firstfsb);
4287 error = XFS_BUNMAPI(mp, tp, &ip->i_iocore, startoffset_fsb, 4228 error = xfs_bunmapi(tp, ip, startoffset_fsb,
4288 endoffset_fsb - startoffset_fsb, 4229 endoffset_fsb - startoffset_fsb,
4289 0, 2, &firstfsb, &free_list, NULL, &done); 4230 0, 2, &firstfsb, &free_list, NULL, &done);
4290 if (error) { 4231 if (error) {
@@ -4347,23 +4288,11 @@ xfs_change_file_space(
4347 xfs_trans_t *tp; 4288 xfs_trans_t *tp;
4348 bhv_vattr_t va; 4289 bhv_vattr_t va;
4349 4290
4350 vn_trace_entry(ip, __FUNCTION__, (inst_t *)__return_address); 4291 xfs_itrace_entry(ip);
4351 4292
4352 /*
4353 * must be a regular file and have write permission
4354 */
4355 if (!S_ISREG(ip->i_d.di_mode)) 4293 if (!S_ISREG(ip->i_d.di_mode))
4356 return XFS_ERROR(EINVAL); 4294 return XFS_ERROR(EINVAL);
4357 4295
4358 xfs_ilock(ip, XFS_ILOCK_SHARED);
4359
4360 if ((error = xfs_iaccess(ip, S_IWUSR, credp))) {
4361 xfs_iunlock(ip, XFS_ILOCK_SHARED);
4362 return error;
4363 }
4364
4365 xfs_iunlock(ip, XFS_ILOCK_SHARED);
4366
4367 switch (bf->l_whence) { 4296 switch (bf->l_whence) {
4368 case 0: /*SEEK_SET*/ 4297 case 0: /*SEEK_SET*/
4369 break; 4298 break;