aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_inode.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/xfs/xfs_inode.c')
-rw-r--r--fs/xfs/xfs_inode.c60
1 files changed, 22 insertions, 38 deletions
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index b76a829d7e20..68415cb4f23c 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -27,13 +27,10 @@
27#include "xfs_trans_priv.h" 27#include "xfs_trans_priv.h"
28#include "xfs_sb.h" 28#include "xfs_sb.h"
29#include "xfs_ag.h" 29#include "xfs_ag.h"
30#include "xfs_dir2.h"
31#include "xfs_dmapi.h"
32#include "xfs_mount.h" 30#include "xfs_mount.h"
33#include "xfs_bmap_btree.h" 31#include "xfs_bmap_btree.h"
34#include "xfs_alloc_btree.h" 32#include "xfs_alloc_btree.h"
35#include "xfs_ialloc_btree.h" 33#include "xfs_ialloc_btree.h"
36#include "xfs_dir2_sf.h"
37#include "xfs_attr_sf.h" 34#include "xfs_attr_sf.h"
38#include "xfs_dinode.h" 35#include "xfs_dinode.h"
39#include "xfs_inode.h" 36#include "xfs_inode.h"
@@ -44,7 +41,6 @@
44#include "xfs_alloc.h" 41#include "xfs_alloc.h"
45#include "xfs_ialloc.h" 42#include "xfs_ialloc.h"
46#include "xfs_bmap.h" 43#include "xfs_bmap.h"
47#include "xfs_rw.h"
48#include "xfs_error.h" 44#include "xfs_error.h"
49#include "xfs_utils.h" 45#include "xfs_utils.h"
50#include "xfs_quota.h" 46#include "xfs_quota.h"
@@ -426,7 +422,7 @@ xfs_iformat(
426 if (!XFS_DFORK_Q(dip)) 422 if (!XFS_DFORK_Q(dip))
427 return 0; 423 return 0;
428 ASSERT(ip->i_afp == NULL); 424 ASSERT(ip->i_afp == NULL);
429 ip->i_afp = kmem_zone_zalloc(xfs_ifork_zone, KM_SLEEP); 425 ip->i_afp = kmem_zone_zalloc(xfs_ifork_zone, KM_SLEEP | KM_NOFS);
430 ip->i_afp->if_ext_max = 426 ip->i_afp->if_ext_max =
431 XFS_IFORK_ASIZE(ip) / (uint)sizeof(xfs_bmbt_rec_t); 427 XFS_IFORK_ASIZE(ip) / (uint)sizeof(xfs_bmbt_rec_t);
432 switch (dip->di_aformat) { 428 switch (dip->di_aformat) {
@@ -509,7 +505,7 @@ xfs_iformat_local(
509 ifp->if_u1.if_data = ifp->if_u2.if_inline_data; 505 ifp->if_u1.if_data = ifp->if_u2.if_inline_data;
510 else { 506 else {
511 real_size = roundup(size, 4); 507 real_size = roundup(size, 4);
512 ifp->if_u1.if_data = kmem_alloc(real_size, KM_SLEEP); 508 ifp->if_u1.if_data = kmem_alloc(real_size, KM_SLEEP | KM_NOFS);
513 } 509 }
514 ifp->if_bytes = size; 510 ifp->if_bytes = size;
515 ifp->if_real_bytes = real_size; 511 ifp->if_real_bytes = real_size;
@@ -636,7 +632,7 @@ xfs_iformat_btree(
636 } 632 }
637 633
638 ifp->if_broot_bytes = size; 634 ifp->if_broot_bytes = size;
639 ifp->if_broot = kmem_alloc(size, KM_SLEEP); 635 ifp->if_broot = kmem_alloc(size, KM_SLEEP | KM_NOFS);
640 ASSERT(ifp->if_broot != NULL); 636 ASSERT(ifp->if_broot != NULL);
641 /* 637 /*
642 * Copy and convert from the on-disk structure 638 * Copy and convert from the on-disk structure
@@ -922,7 +918,6 @@ xfs_iread_extents(
922 int error; 918 int error;
923 xfs_ifork_t *ifp; 919 xfs_ifork_t *ifp;
924 xfs_extnum_t nextents; 920 xfs_extnum_t nextents;
925 size_t size;
926 921
927 if (unlikely(XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_BTREE)) { 922 if (unlikely(XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_BTREE)) {
928 XFS_ERROR_REPORT("xfs_iread_extents", XFS_ERRLEVEL_LOW, 923 XFS_ERROR_REPORT("xfs_iread_extents", XFS_ERRLEVEL_LOW,
@@ -930,7 +925,6 @@ xfs_iread_extents(
930 return XFS_ERROR(EFSCORRUPTED); 925 return XFS_ERROR(EFSCORRUPTED);
931 } 926 }
932 nextents = XFS_IFORK_NEXTENTS(ip, whichfork); 927 nextents = XFS_IFORK_NEXTENTS(ip, whichfork);
933 size = nextents * sizeof(xfs_bmbt_rec_t);
934 ifp = XFS_IFORK_PTR(ip, whichfork); 928 ifp = XFS_IFORK_PTR(ip, whichfork);
935 929
936 /* 930 /*
@@ -1226,7 +1220,7 @@ xfs_isize_check(
1226 (xfs_ufsize_t)XFS_MAXIOFFSET(mp)) - 1220 (xfs_ufsize_t)XFS_MAXIOFFSET(mp)) -
1227 map_first), 1221 map_first),
1228 XFS_BMAPI_ENTIRE, NULL, 0, imaps, &nimaps, 1222 XFS_BMAPI_ENTIRE, NULL, 0, imaps, &nimaps,
1229 NULL, NULL)) 1223 NULL))
1230 return; 1224 return;
1231 ASSERT(nimaps == 1); 1225 ASSERT(nimaps == 1);
1232 ASSERT(imaps[0].br_startblock == HOLESTARTBLOCK); 1226 ASSERT(imaps[0].br_startblock == HOLESTARTBLOCK);
@@ -1460,7 +1454,7 @@ xfs_itruncate_finish(
1460 ASSERT((*tp)->t_flags & XFS_TRANS_PERM_LOG_RES); 1454 ASSERT((*tp)->t_flags & XFS_TRANS_PERM_LOG_RES);
1461 ASSERT(ip->i_transp == *tp); 1455 ASSERT(ip->i_transp == *tp);
1462 ASSERT(ip->i_itemp != NULL); 1456 ASSERT(ip->i_itemp != NULL);
1463 ASSERT(ip->i_itemp->ili_flags & XFS_ILI_HOLD); 1457 ASSERT(ip->i_itemp->ili_lock_flags == 0);
1464 1458
1465 1459
1466 ntp = *tp; 1460 ntp = *tp;
@@ -1589,11 +1583,10 @@ xfs_itruncate_finish(
1589 xfs_bmap_init(&free_list, &first_block); 1583 xfs_bmap_init(&free_list, &first_block);
1590 error = xfs_bunmapi(ntp, ip, 1584 error = xfs_bunmapi(ntp, ip,
1591 first_unmap_block, unmap_len, 1585 first_unmap_block, unmap_len,
1592 xfs_bmapi_aflag(fork) | 1586 xfs_bmapi_aflag(fork),
1593 (sync ? 0 : XFS_BMAPI_ASYNC),
1594 XFS_ITRUNC_MAX_EXTENTS, 1587 XFS_ITRUNC_MAX_EXTENTS,
1595 &first_block, &free_list, 1588 &first_block, &free_list,
1596 NULL, &done); 1589 &done);
1597 if (error) { 1590 if (error) {
1598 /* 1591 /*
1599 * If the bunmapi call encounters an error, 1592 * If the bunmapi call encounters an error,
@@ -1612,12 +1605,8 @@ xfs_itruncate_finish(
1612 */ 1605 */
1613 error = xfs_bmap_finish(tp, &free_list, &committed); 1606 error = xfs_bmap_finish(tp, &free_list, &committed);
1614 ntp = *tp; 1607 ntp = *tp;
1615 if (committed) { 1608 if (committed)
1616 /* link the inode into the next xact in the chain */ 1609 xfs_trans_ijoin(ntp, ip);
1617 xfs_trans_ijoin(ntp, ip,
1618 XFS_ILOCK_EXCL | XFS_IOLOCK_EXCL);
1619 xfs_trans_ihold(ntp, ip);
1620 }
1621 1610
1622 if (error) { 1611 if (error) {
1623 /* 1612 /*
@@ -1646,9 +1635,7 @@ xfs_itruncate_finish(
1646 error = xfs_trans_commit(*tp, 0); 1635 error = xfs_trans_commit(*tp, 0);
1647 *tp = ntp; 1636 *tp = ntp;
1648 1637
1649 /* link the inode into the next transaction in the chain */ 1638 xfs_trans_ijoin(ntp, ip);
1650 xfs_trans_ijoin(ntp, ip, XFS_ILOCK_EXCL | XFS_IOLOCK_EXCL);
1651 xfs_trans_ihold(ntp, ip);
1652 1639
1653 if (error) 1640 if (error)
1654 return error; 1641 return error;
@@ -1985,7 +1972,7 @@ xfs_ifree_cluster(
1985 if (lip->li_type == XFS_LI_INODE) { 1972 if (lip->li_type == XFS_LI_INODE) {
1986 iip = (xfs_inode_log_item_t *)lip; 1973 iip = (xfs_inode_log_item_t *)lip;
1987 ASSERT(iip->ili_logged == 1); 1974 ASSERT(iip->ili_logged == 1);
1988 lip->li_cb = (void(*)(xfs_buf_t*,xfs_log_item_t*)) xfs_istale_done; 1975 lip->li_cb = xfs_istale_done;
1989 xfs_trans_ail_copy_lsn(mp->m_ail, 1976 xfs_trans_ail_copy_lsn(mp->m_ail,
1990 &iip->ili_flush_lsn, 1977 &iip->ili_flush_lsn,
1991 &iip->ili_item.li_lsn); 1978 &iip->ili_item.li_lsn);
@@ -2055,9 +2042,8 @@ xfs_ifree_cluster(
2055 xfs_trans_ail_copy_lsn(mp->m_ail, &iip->ili_flush_lsn, 2042 xfs_trans_ail_copy_lsn(mp->m_ail, &iip->ili_flush_lsn,
2056 &iip->ili_item.li_lsn); 2043 &iip->ili_item.li_lsn);
2057 2044
2058 xfs_buf_attach_iodone(bp, 2045 xfs_buf_attach_iodone(bp, xfs_istale_done,
2059 (void(*)(xfs_buf_t*,xfs_log_item_t*)) 2046 &iip->ili_item);
2060 xfs_istale_done, (xfs_log_item_t *)iip);
2061 2047
2062 if (ip != free_ip) 2048 if (ip != free_ip)
2063 xfs_iunlock(ip, XFS_ILOCK_EXCL); 2049 xfs_iunlock(ip, XFS_ILOCK_EXCL);
@@ -2203,7 +2189,7 @@ xfs_iroot_realloc(
2203 */ 2189 */
2204 if (ifp->if_broot_bytes == 0) { 2190 if (ifp->if_broot_bytes == 0) {
2205 new_size = (size_t)XFS_BMAP_BROOT_SPACE_CALC(rec_diff); 2191 new_size = (size_t)XFS_BMAP_BROOT_SPACE_CALC(rec_diff);
2206 ifp->if_broot = kmem_alloc(new_size, KM_SLEEP); 2192 ifp->if_broot = kmem_alloc(new_size, KM_SLEEP | KM_NOFS);
2207 ifp->if_broot_bytes = (int)new_size; 2193 ifp->if_broot_bytes = (int)new_size;
2208 return; 2194 return;
2209 } 2195 }
@@ -2219,7 +2205,7 @@ xfs_iroot_realloc(
2219 new_size = (size_t)XFS_BMAP_BROOT_SPACE_CALC(new_max); 2205 new_size = (size_t)XFS_BMAP_BROOT_SPACE_CALC(new_max);
2220 ifp->if_broot = kmem_realloc(ifp->if_broot, new_size, 2206 ifp->if_broot = kmem_realloc(ifp->if_broot, new_size,
2221 (size_t)XFS_BMAP_BROOT_SPACE_CALC(cur_max), /* old size */ 2207 (size_t)XFS_BMAP_BROOT_SPACE_CALC(cur_max), /* old size */
2222 KM_SLEEP); 2208 KM_SLEEP | KM_NOFS);
2223 op = (char *)XFS_BMAP_BROOT_PTR_ADDR(mp, ifp->if_broot, 1, 2209 op = (char *)XFS_BMAP_BROOT_PTR_ADDR(mp, ifp->if_broot, 1,
2224 ifp->if_broot_bytes); 2210 ifp->if_broot_bytes);
2225 np = (char *)XFS_BMAP_BROOT_PTR_ADDR(mp, ifp->if_broot, 1, 2211 np = (char *)XFS_BMAP_BROOT_PTR_ADDR(mp, ifp->if_broot, 1,
@@ -2245,7 +2231,7 @@ xfs_iroot_realloc(
2245 else 2231 else
2246 new_size = 0; 2232 new_size = 0;
2247 if (new_size > 0) { 2233 if (new_size > 0) {
2248 new_broot = kmem_alloc(new_size, KM_SLEEP); 2234 new_broot = kmem_alloc(new_size, KM_SLEEP | KM_NOFS);
2249 /* 2235 /*
2250 * First copy over the btree block header. 2236 * First copy over the btree block header.
2251 */ 2237 */
@@ -2349,7 +2335,8 @@ xfs_idata_realloc(
2349 real_size = roundup(new_size, 4); 2335 real_size = roundup(new_size, 4);
2350 if (ifp->if_u1.if_data == NULL) { 2336 if (ifp->if_u1.if_data == NULL) {
2351 ASSERT(ifp->if_real_bytes == 0); 2337 ASSERT(ifp->if_real_bytes == 0);
2352 ifp->if_u1.if_data = kmem_alloc(real_size, KM_SLEEP); 2338 ifp->if_u1.if_data = kmem_alloc(real_size,
2339 KM_SLEEP | KM_NOFS);
2353 } else if (ifp->if_u1.if_data != ifp->if_u2.if_inline_data) { 2340 } else if (ifp->if_u1.if_data != ifp->if_u2.if_inline_data) {
2354 /* 2341 /*
2355 * Only do the realloc if the underlying size 2342 * Only do the realloc if the underlying size
@@ -2360,11 +2347,12 @@ xfs_idata_realloc(
2360 kmem_realloc(ifp->if_u1.if_data, 2347 kmem_realloc(ifp->if_u1.if_data,
2361 real_size, 2348 real_size,
2362 ifp->if_real_bytes, 2349 ifp->if_real_bytes,
2363 KM_SLEEP); 2350 KM_SLEEP | KM_NOFS);
2364 } 2351 }
2365 } else { 2352 } else {
2366 ASSERT(ifp->if_real_bytes == 0); 2353 ASSERT(ifp->if_real_bytes == 0);
2367 ifp->if_u1.if_data = kmem_alloc(real_size, KM_SLEEP); 2354 ifp->if_u1.if_data = kmem_alloc(real_size,
2355 KM_SLEEP | KM_NOFS);
2368 memcpy(ifp->if_u1.if_data, ifp->if_u2.if_inline_data, 2356 memcpy(ifp->if_u1.if_data, ifp->if_u2.if_inline_data,
2369 ifp->if_bytes); 2357 ifp->if_bytes);
2370 } 2358 }
@@ -2731,7 +2719,6 @@ cluster_corrupt_out:
2731 * mark it as stale and brelse. 2719 * mark it as stale and brelse.
2732 */ 2720 */
2733 if (XFS_BUF_IODONE_FUNC(bp)) { 2721 if (XFS_BUF_IODONE_FUNC(bp)) {
2734 XFS_BUF_CLR_BDSTRAT_FUNC(bp);
2735 XFS_BUF_UNDONE(bp); 2722 XFS_BUF_UNDONE(bp);
2736 XFS_BUF_STALE(bp); 2723 XFS_BUF_STALE(bp);
2737 XFS_BUF_ERROR(bp,EIO); 2724 XFS_BUF_ERROR(bp,EIO);
@@ -3069,8 +3056,7 @@ xfs_iflush_int(
3069 * and unlock the inode's flush lock when the inode is 3056 * and unlock the inode's flush lock when the inode is
3070 * completely written to disk. 3057 * completely written to disk.
3071 */ 3058 */
3072 xfs_buf_attach_iodone(bp, (void(*)(xfs_buf_t*,xfs_log_item_t*)) 3059 xfs_buf_attach_iodone(bp, xfs_iflush_done, &iip->ili_item);
3073 xfs_iflush_done, (xfs_log_item_t *)iip);
3074 3060
3075 ASSERT(XFS_BUF_FSPRIVATE(bp, void *) != NULL); 3061 ASSERT(XFS_BUF_FSPRIVATE(bp, void *) != NULL);
3076 ASSERT(XFS_BUF_IODONE_FUNC(bp) != NULL); 3062 ASSERT(XFS_BUF_IODONE_FUNC(bp) != NULL);
@@ -3514,13 +3500,11 @@ xfs_iext_remove_indirect(
3514 xfs_extnum_t ext_diff; /* extents to remove in current list */ 3500 xfs_extnum_t ext_diff; /* extents to remove in current list */
3515 xfs_extnum_t nex1; /* number of extents before idx */ 3501 xfs_extnum_t nex1; /* number of extents before idx */
3516 xfs_extnum_t nex2; /* extents after idx + count */ 3502 xfs_extnum_t nex2; /* extents after idx + count */
3517 int nlists; /* entries in indirection array */
3518 int page_idx = idx; /* index in target extent list */ 3503 int page_idx = idx; /* index in target extent list */
3519 3504
3520 ASSERT(ifp->if_flags & XFS_IFEXTIREC); 3505 ASSERT(ifp->if_flags & XFS_IFEXTIREC);
3521 erp = xfs_iext_idx_to_irec(ifp, &page_idx, &erp_idx, 0); 3506 erp = xfs_iext_idx_to_irec(ifp, &page_idx, &erp_idx, 0);
3522 ASSERT(erp != NULL); 3507 ASSERT(erp != NULL);
3523 nlists = ifp->if_real_bytes / XFS_IEXT_BUFSZ;
3524 nex1 = page_idx; 3508 nex1 = page_idx;
3525 ext_cnt = count; 3509 ext_cnt = count;
3526 while (ext_cnt) { 3510 while (ext_cnt) {