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.c109
1 files changed, 49 insertions, 60 deletions
diff --git a/fs/xfs/xfs_vnodeops.c b/fs/xfs/xfs_vnodeops.c
index 51fc429527bc..4ecf2a549060 100644
--- a/fs/xfs/xfs_vnodeops.c
+++ b/fs/xfs/xfs_vnodeops.c
@@ -72,8 +72,8 @@ xfs_readlink_bmap(
72 xfs_buf_t *bp; 72 xfs_buf_t *bp;
73 int error = 0; 73 int error = 0;
74 74
75 error = xfs_bmapi(NULL, ip, 0, XFS_B_TO_FSB(mp, pathlen), 0, NULL, 0, 75 error = xfs_bmapi_read(ip, 0, XFS_B_TO_FSB(mp, pathlen), mval, &nmaps,
76 mval, &nmaps, NULL); 76 0);
77 if (error) 77 if (error)
78 goto out; 78 goto out;
79 79
@@ -87,8 +87,7 @@ xfs_readlink_bmap(
87 return XFS_ERROR(ENOMEM); 87 return XFS_ERROR(ENOMEM);
88 error = bp->b_error; 88 error = bp->b_error;
89 if (error) { 89 if (error) {
90 xfs_ioerror_alert("xfs_readlink", 90 xfs_buf_ioerror_alert(bp, __func__);
91 ip->i_mount, bp, XFS_BUF_ADDR(bp));
92 xfs_buf_relse(bp); 91 xfs_buf_relse(bp);
93 goto out; 92 goto out;
94 } 93 }
@@ -178,8 +177,7 @@ xfs_free_eofblocks(
178 177
179 nimaps = 1; 178 nimaps = 1;
180 xfs_ilock(ip, XFS_ILOCK_SHARED); 179 xfs_ilock(ip, XFS_ILOCK_SHARED);
181 error = xfs_bmapi(NULL, ip, end_fsb, map_len, 0, 180 error = xfs_bmapi_read(ip, end_fsb, map_len, &imap, &nimaps, 0);
182 NULL, 0, &imap, &nimaps, NULL);
183 xfs_iunlock(ip, XFS_ILOCK_SHARED); 181 xfs_iunlock(ip, XFS_ILOCK_SHARED);
184 182
185 if (!error && (nimaps != 0) && 183 if (!error && (nimaps != 0) &&
@@ -220,7 +218,7 @@ xfs_free_eofblocks(
220 } 218 }
221 219
222 xfs_ilock(ip, XFS_ILOCK_EXCL); 220 xfs_ilock(ip, XFS_ILOCK_EXCL);
223 xfs_trans_ijoin(tp, ip); 221 xfs_trans_ijoin(tp, ip, 0);
224 222
225 error = xfs_itruncate_data(&tp, ip, ip->i_size); 223 error = xfs_itruncate_data(&tp, ip, ip->i_size);
226 if (error) { 224 if (error) {
@@ -289,7 +287,7 @@ xfs_inactive_symlink_rmt(
289 xfs_ilock(ip, XFS_IOLOCK_EXCL | XFS_ILOCK_EXCL); 287 xfs_ilock(ip, XFS_IOLOCK_EXCL | XFS_ILOCK_EXCL);
290 size = (int)ip->i_d.di_size; 288 size = (int)ip->i_d.di_size;
291 ip->i_d.di_size = 0; 289 ip->i_d.di_size = 0;
292 xfs_trans_ijoin(tp, ip); 290 xfs_trans_ijoin(tp, ip, 0);
293 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); 291 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
294 /* 292 /*
295 * Find the block(s) so we can inval and unmap them. 293 * Find the block(s) so we can inval and unmap them.
@@ -297,9 +295,9 @@ xfs_inactive_symlink_rmt(
297 done = 0; 295 done = 0;
298 xfs_bmap_init(&free_list, &first_block); 296 xfs_bmap_init(&free_list, &first_block);
299 nmaps = ARRAY_SIZE(mval); 297 nmaps = ARRAY_SIZE(mval);
300 if ((error = xfs_bmapi(tp, ip, 0, XFS_B_TO_FSB(mp, size), 298 error = xfs_bmapi_read(ip, 0, XFS_B_TO_FSB(mp, size),
301 XFS_BMAPI_METADATA, &first_block, 0, mval, &nmaps, 299 mval, &nmaps, 0);
302 &free_list))) 300 if (error)
303 goto error0; 301 goto error0;
304 /* 302 /*
305 * Invalidate the block(s). 303 * Invalidate the block(s).
@@ -308,6 +306,10 @@ xfs_inactive_symlink_rmt(
308 bp = xfs_trans_get_buf(tp, mp->m_ddev_targp, 306 bp = xfs_trans_get_buf(tp, mp->m_ddev_targp,
309 XFS_FSB_TO_DADDR(mp, mval[i].br_startblock), 307 XFS_FSB_TO_DADDR(mp, mval[i].br_startblock),
310 XFS_FSB_TO_BB(mp, mval[i].br_blockcount), 0); 308 XFS_FSB_TO_BB(mp, mval[i].br_blockcount), 0);
309 if (!bp) {
310 error = ENOMEM;
311 goto error1;
312 }
311 xfs_trans_binval(tp, bp); 313 xfs_trans_binval(tp, bp);
312 } 314 }
313 /* 315 /*
@@ -333,7 +335,7 @@ xfs_inactive_symlink_rmt(
333 * Mark it dirty so it will be logged and moved forward in the log as 335 * Mark it dirty so it will be logged and moved forward in the log as
334 * part of every commit. 336 * part of every commit.
335 */ 337 */
336 xfs_trans_ijoin(tp, ip); 338 xfs_trans_ijoin(tp, ip, 0);
337 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); 339 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
338 /* 340 /*
339 * Get a new, empty transaction to return to our caller. 341 * Get a new, empty transaction to return to our caller.
@@ -466,7 +468,7 @@ xfs_inactive_attrs(
466 goto error_cancel; 468 goto error_cancel;
467 469
468 xfs_ilock(ip, XFS_ILOCK_EXCL); 470 xfs_ilock(ip, XFS_ILOCK_EXCL);
469 xfs_trans_ijoin(tp, ip); 471 xfs_trans_ijoin(tp, ip, 0);
470 xfs_idestroy_fork(ip, XFS_ATTR_FORK); 472 xfs_idestroy_fork(ip, XFS_ATTR_FORK);
471 473
472 ASSERT(ip->i_d.di_anextents == 0); 474 ASSERT(ip->i_d.di_anextents == 0);
@@ -647,8 +649,6 @@ xfs_inactive(
647 if (truncate) { 649 if (truncate) {
648 xfs_ilock(ip, XFS_IOLOCK_EXCL); 650 xfs_ilock(ip, XFS_IOLOCK_EXCL);
649 651
650 xfs_ioend_wait(ip);
651
652 error = xfs_trans_reserve(tp, 0, 652 error = xfs_trans_reserve(tp, 0,
653 XFS_ITRUNCATE_LOG_RES(mp), 653 XFS_ITRUNCATE_LOG_RES(mp),
654 0, XFS_TRANS_PERM_LOG_RES, 654 0, XFS_TRANS_PERM_LOG_RES,
@@ -662,7 +662,7 @@ xfs_inactive(
662 } 662 }
663 663
664 xfs_ilock(ip, XFS_ILOCK_EXCL); 664 xfs_ilock(ip, XFS_ILOCK_EXCL);
665 xfs_trans_ijoin(tp, ip); 665 xfs_trans_ijoin(tp, ip, 0);
666 666
667 error = xfs_itruncate_data(&tp, ip, 0); 667 error = xfs_itruncate_data(&tp, ip, 0);
668 if (error) { 668 if (error) {
@@ -686,7 +686,7 @@ xfs_inactive(
686 return VN_INACTIVE_CACHE; 686 return VN_INACTIVE_CACHE;
687 } 687 }
688 688
689 xfs_trans_ijoin(tp, ip); 689 xfs_trans_ijoin(tp, ip, 0);
690 } else { 690 } else {
691 error = xfs_trans_reserve(tp, 0, 691 error = xfs_trans_reserve(tp, 0,
692 XFS_IFREE_LOG_RES(mp), 692 XFS_IFREE_LOG_RES(mp),
@@ -699,7 +699,7 @@ xfs_inactive(
699 } 699 }
700 700
701 xfs_ilock(ip, XFS_ILOCK_EXCL | XFS_IOLOCK_EXCL); 701 xfs_ilock(ip, XFS_ILOCK_EXCL | XFS_IOLOCK_EXCL);
702 xfs_trans_ijoin(tp, ip); 702 xfs_trans_ijoin(tp, ip, 0);
703 } 703 }
704 704
705 /* 705 /*
@@ -939,7 +939,7 @@ xfs_create(
939 * the transaction cancel unlocking dp so don't do it explicitly in the 939 * the transaction cancel unlocking dp so don't do it explicitly in the
940 * error path. 940 * error path.
941 */ 941 */
942 xfs_trans_ijoin_ref(tp, dp, XFS_ILOCK_EXCL); 942 xfs_trans_ijoin(tp, dp, XFS_ILOCK_EXCL);
943 unlock_dp_on_error = B_FALSE; 943 unlock_dp_on_error = B_FALSE;
944 944
945 error = xfs_dir_createname(tp, dp, name, ip->i_ino, 945 error = xfs_dir_createname(tp, dp, name, ip->i_ino,
@@ -1260,8 +1260,8 @@ xfs_remove(
1260 1260
1261 xfs_lock_two_inodes(dp, ip, XFS_ILOCK_EXCL); 1261 xfs_lock_two_inodes(dp, ip, XFS_ILOCK_EXCL);
1262 1262
1263 xfs_trans_ijoin_ref(tp, dp, XFS_ILOCK_EXCL); 1263 xfs_trans_ijoin(tp, dp, XFS_ILOCK_EXCL);
1264 xfs_trans_ijoin_ref(tp, ip, XFS_ILOCK_EXCL); 1264 xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
1265 1265
1266 /* 1266 /*
1267 * If we're removing a directory perform some additional validation. 1267 * If we're removing a directory perform some additional validation.
@@ -1406,8 +1406,8 @@ xfs_link(
1406 1406
1407 xfs_lock_two_inodes(sip, tdp, XFS_ILOCK_EXCL); 1407 xfs_lock_two_inodes(sip, tdp, XFS_ILOCK_EXCL);
1408 1408
1409 xfs_trans_ijoin_ref(tp, sip, XFS_ILOCK_EXCL); 1409 xfs_trans_ijoin(tp, sip, XFS_ILOCK_EXCL);
1410 xfs_trans_ijoin_ref(tp, tdp, XFS_ILOCK_EXCL); 1410 xfs_trans_ijoin(tp, tdp, XFS_ILOCK_EXCL);
1411 1411
1412 /* 1412 /*
1413 * If the source has too many links, we can't make any more to it. 1413 * If the source has too many links, we can't make any more to it.
@@ -1601,7 +1601,7 @@ xfs_symlink(
1601 * transaction cancel unlocking dp so don't do it explicitly in the 1601 * transaction cancel unlocking dp so don't do it explicitly in the
1602 * error path. 1602 * error path.
1603 */ 1603 */
1604 xfs_trans_ijoin_ref(tp, dp, XFS_ILOCK_EXCL); 1604 xfs_trans_ijoin(tp, dp, XFS_ILOCK_EXCL);
1605 unlock_dp_on_error = B_FALSE; 1605 unlock_dp_on_error = B_FALSE;
1606 1606
1607 /* 1607 /*
@@ -1632,10 +1632,9 @@ xfs_symlink(
1632 first_fsb = 0; 1632 first_fsb = 0;
1633 nmaps = SYMLINK_MAPS; 1633 nmaps = SYMLINK_MAPS;
1634 1634
1635 error = xfs_bmapi(tp, ip, first_fsb, fs_blocks, 1635 error = xfs_bmapi_write(tp, ip, first_fsb, fs_blocks,
1636 XFS_BMAPI_WRITE | XFS_BMAPI_METADATA, 1636 XFS_BMAPI_METADATA, &first_block, resblks,
1637 &first_block, resblks, mval, &nmaps, 1637 mval, &nmaps, &free_list);
1638 &free_list);
1639 if (error) 1638 if (error)
1640 goto error2; 1639 goto error2;
1641 1640
@@ -1650,7 +1649,10 @@ xfs_symlink(
1650 byte_cnt = XFS_FSB_TO_B(mp, mval[n].br_blockcount); 1649 byte_cnt = XFS_FSB_TO_B(mp, mval[n].br_blockcount);
1651 bp = xfs_trans_get_buf(tp, mp->m_ddev_targp, d, 1650 bp = xfs_trans_get_buf(tp, mp->m_ddev_targp, d,
1652 BTOBB(byte_cnt), 0); 1651 BTOBB(byte_cnt), 0);
1653 ASSERT(!xfs_buf_geterror(bp)); 1652 if (!bp) {
1653 error = ENOMEM;
1654 goto error2;
1655 }
1654 if (pathlen < byte_cnt) { 1656 if (pathlen < byte_cnt) {
1655 byte_cnt = pathlen; 1657 byte_cnt = pathlen;
1656 } 1658 }
@@ -1732,7 +1734,7 @@ xfs_set_dmattrs(
1732 return error; 1734 return error;
1733 } 1735 }
1734 xfs_ilock(ip, XFS_ILOCK_EXCL); 1736 xfs_ilock(ip, XFS_ILOCK_EXCL);
1735 xfs_trans_ijoin_ref(tp, ip, XFS_ILOCK_EXCL); 1737 xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
1736 1738
1737 ip->i_d.di_dmevmask = evmask; 1739 ip->i_d.di_dmevmask = evmask;
1738 ip->i_d.di_dmstate = state; 1740 ip->i_d.di_dmstate = state;
@@ -1778,7 +1780,6 @@ xfs_alloc_file_space(
1778 xfs_fileoff_t startoffset_fsb; 1780 xfs_fileoff_t startoffset_fsb;
1779 xfs_fsblock_t firstfsb; 1781 xfs_fsblock_t firstfsb;
1780 int nimaps; 1782 int nimaps;
1781 int bmapi_flag;
1782 int quota_flag; 1783 int quota_flag;
1783 int rt; 1784 int rt;
1784 xfs_trans_t *tp; 1785 xfs_trans_t *tp;
@@ -1806,7 +1807,6 @@ xfs_alloc_file_space(
1806 count = len; 1807 count = len;
1807 imapp = &imaps[0]; 1808 imapp = &imaps[0];
1808 nimaps = 1; 1809 nimaps = 1;
1809 bmapi_flag = XFS_BMAPI_WRITE | alloc_type;
1810 startoffset_fsb = XFS_B_TO_FSBT(mp, offset); 1810 startoffset_fsb = XFS_B_TO_FSBT(mp, offset);
1811 allocatesize_fsb = XFS_B_TO_FSB(mp, count); 1811 allocatesize_fsb = XFS_B_TO_FSB(mp, count);
1812 1812
@@ -1877,16 +1877,12 @@ xfs_alloc_file_space(
1877 if (error) 1877 if (error)
1878 goto error1; 1878 goto error1;
1879 1879
1880 xfs_trans_ijoin(tp, ip); 1880 xfs_trans_ijoin(tp, ip, 0);
1881 1881
1882 /*
1883 * Issue the xfs_bmapi() call to allocate the blocks
1884 */
1885 xfs_bmap_init(&free_list, &firstfsb); 1882 xfs_bmap_init(&free_list, &firstfsb);
1886 error = xfs_bmapi(tp, ip, startoffset_fsb, 1883 error = xfs_bmapi_write(tp, ip, startoffset_fsb,
1887 allocatesize_fsb, bmapi_flag, 1884 allocatesize_fsb, alloc_type, &firstfsb,
1888 &firstfsb, 0, imapp, &nimaps, 1885 0, imapp, &nimaps, &free_list);
1889 &free_list);
1890 if (error) { 1886 if (error) {
1891 goto error0; 1887 goto error0;
1892 } 1888 }
@@ -1976,8 +1972,7 @@ xfs_zero_remaining_bytes(
1976 for (offset = startoff; offset <= endoff; offset = lastoffset + 1) { 1972 for (offset = startoff; offset <= endoff; offset = lastoffset + 1) {
1977 offset_fsb = XFS_B_TO_FSBT(mp, offset); 1973 offset_fsb = XFS_B_TO_FSBT(mp, offset);
1978 nimap = 1; 1974 nimap = 1;
1979 error = xfs_bmapi(NULL, ip, offset_fsb, 1, 0, 1975 error = xfs_bmapi_read(ip, offset_fsb, 1, &imap, &nimap, 0);
1980 NULL, 0, &imap, &nimap, NULL);
1981 if (error || nimap < 1) 1976 if (error || nimap < 1)
1982 break; 1977 break;
1983 ASSERT(imap.br_blockcount >= 1); 1978 ASSERT(imap.br_blockcount >= 1);
@@ -1997,8 +1992,8 @@ xfs_zero_remaining_bytes(
1997 xfsbdstrat(mp, bp); 1992 xfsbdstrat(mp, bp);
1998 error = xfs_buf_iowait(bp); 1993 error = xfs_buf_iowait(bp);
1999 if (error) { 1994 if (error) {
2000 xfs_ioerror_alert("xfs_zero_remaining_bytes(read)", 1995 xfs_buf_ioerror_alert(bp,
2001 mp, bp, XFS_BUF_ADDR(bp)); 1996 "xfs_zero_remaining_bytes(read)");
2002 break; 1997 break;
2003 } 1998 }
2004 memset(bp->b_addr + 1999 memset(bp->b_addr +
@@ -2010,8 +2005,8 @@ xfs_zero_remaining_bytes(
2010 xfsbdstrat(mp, bp); 2005 xfsbdstrat(mp, bp);
2011 error = xfs_buf_iowait(bp); 2006 error = xfs_buf_iowait(bp);
2012 if (error) { 2007 if (error) {
2013 xfs_ioerror_alert("xfs_zero_remaining_bytes(write)", 2008 xfs_buf_ioerror_alert(bp,
2014 mp, bp, XFS_BUF_ADDR(bp)); 2009 "xfs_zero_remaining_bytes(write)");
2015 break; 2010 break;
2016 } 2011 }
2017 } 2012 }
@@ -2076,7 +2071,7 @@ xfs_free_file_space(
2076 if (need_iolock) { 2071 if (need_iolock) {
2077 xfs_ilock(ip, XFS_IOLOCK_EXCL); 2072 xfs_ilock(ip, XFS_IOLOCK_EXCL);
2078 /* wait for the completion of any pending DIOs */ 2073 /* wait for the completion of any pending DIOs */
2079 xfs_ioend_wait(ip); 2074 inode_dio_wait(VFS_I(ip));
2080 } 2075 }
2081 2076
2082 rounding = max_t(uint, 1 << mp->m_sb.sb_blocklog, PAGE_CACHE_SIZE); 2077 rounding = max_t(uint, 1 << mp->m_sb.sb_blocklog, PAGE_CACHE_SIZE);
@@ -2096,8 +2091,8 @@ xfs_free_file_space(
2096 */ 2091 */
2097 if (rt && !xfs_sb_version_hasextflgbit(&mp->m_sb)) { 2092 if (rt && !xfs_sb_version_hasextflgbit(&mp->m_sb)) {
2098 nimap = 1; 2093 nimap = 1;
2099 error = xfs_bmapi(NULL, ip, startoffset_fsb, 2094 error = xfs_bmapi_read(ip, startoffset_fsb, 1,
2100 1, 0, NULL, 0, &imap, &nimap, NULL); 2095 &imap, &nimap, 0);
2101 if (error) 2096 if (error)
2102 goto out_unlock_iolock; 2097 goto out_unlock_iolock;
2103 ASSERT(nimap == 0 || nimap == 1); 2098 ASSERT(nimap == 0 || nimap == 1);
@@ -2111,8 +2106,8 @@ xfs_free_file_space(
2111 startoffset_fsb += mp->m_sb.sb_rextsize - mod; 2106 startoffset_fsb += mp->m_sb.sb_rextsize - mod;
2112 } 2107 }
2113 nimap = 1; 2108 nimap = 1;
2114 error = xfs_bmapi(NULL, ip, endoffset_fsb - 1, 2109 error = xfs_bmapi_read(ip, endoffset_fsb - 1, 1,
2115 1, 0, NULL, 0, &imap, &nimap, NULL); 2110 &imap, &nimap, 0);
2116 if (error) 2111 if (error)
2117 goto out_unlock_iolock; 2112 goto out_unlock_iolock;
2118 ASSERT(nimap == 0 || nimap == 1); 2113 ASSERT(nimap == 0 || nimap == 1);
@@ -2180,7 +2175,7 @@ xfs_free_file_space(
2180 if (error) 2175 if (error)
2181 goto error1; 2176 goto error1;
2182 2177
2183 xfs_trans_ijoin(tp, ip); 2178 xfs_trans_ijoin(tp, ip, 0);
2184 2179
2185 /* 2180 /*
2186 * issue the bunmapi() call to free the blocks 2181 * issue the bunmapi() call to free the blocks
@@ -2353,8 +2348,7 @@ xfs_change_file_space(
2353 } 2348 }
2354 2349
2355 xfs_ilock(ip, XFS_ILOCK_EXCL); 2350 xfs_ilock(ip, XFS_ILOCK_EXCL);
2356 2351 xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
2357 xfs_trans_ijoin(tp, ip);
2358 2352
2359 if ((attr_flags & XFS_ATTR_DMI) == 0) { 2353 if ((attr_flags & XFS_ATTR_DMI) == 0) {
2360 ip->i_d.di_mode &= ~S_ISUID; 2354 ip->i_d.di_mode &= ~S_ISUID;
@@ -2379,10 +2373,5 @@ xfs_change_file_space(
2379 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); 2373 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
2380 if (attr_flags & XFS_ATTR_SYNC) 2374 if (attr_flags & XFS_ATTR_SYNC)
2381 xfs_trans_set_sync(tp); 2375 xfs_trans_set_sync(tp);
2382 2376 return xfs_trans_commit(tp, 0);
2383 error = xfs_trans_commit(tp, 0);
2384
2385 xfs_iunlock(ip, XFS_ILOCK_EXCL);
2386
2387 return error;
2388} 2377}