diff options
Diffstat (limited to 'fs/xfs/xfs_inode.c')
-rw-r--r-- | fs/xfs/xfs_inode.c | 70 |
1 files changed, 34 insertions, 36 deletions
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index bedc66163176..00e80df9dd9d 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c | |||
@@ -580,8 +580,8 @@ xfs_iformat_extents( | |||
580 | xfs_validate_extents(ifp, nex, XFS_EXTFMT_INODE(ip)); | 580 | xfs_validate_extents(ifp, nex, XFS_EXTFMT_INODE(ip)); |
581 | for (i = 0; i < nex; i++, dp++) { | 581 | for (i = 0; i < nex; i++, dp++) { |
582 | xfs_bmbt_rec_host_t *ep = xfs_iext_get_ext(ifp, i); | 582 | xfs_bmbt_rec_host_t *ep = xfs_iext_get_ext(ifp, i); |
583 | ep->l0 = be64_to_cpu(get_unaligned(&dp->l0)); | 583 | ep->l0 = get_unaligned_be64(&dp->l0); |
584 | ep->l1 = be64_to_cpu(get_unaligned(&dp->l1)); | 584 | ep->l1 = get_unaligned_be64(&dp->l1); |
585 | } | 585 | } |
586 | XFS_BMAP_TRACE_EXLIST(ip, nex, whichfork); | 586 | XFS_BMAP_TRACE_EXLIST(ip, nex, whichfork); |
587 | if (whichfork != XFS_DATA_FORK || | 587 | if (whichfork != XFS_DATA_FORK || |
@@ -835,22 +835,22 @@ xfs_iread( | |||
835 | * Do this before xfs_iformat in case it adds entries. | 835 | * Do this before xfs_iformat in case it adds entries. |
836 | */ | 836 | */ |
837 | #ifdef XFS_INODE_TRACE | 837 | #ifdef XFS_INODE_TRACE |
838 | ip->i_trace = ktrace_alloc(INODE_TRACE_SIZE, KM_SLEEP); | 838 | ip->i_trace = ktrace_alloc(INODE_TRACE_SIZE, KM_NOFS); |
839 | #endif | 839 | #endif |
840 | #ifdef XFS_BMAP_TRACE | 840 | #ifdef XFS_BMAP_TRACE |
841 | ip->i_xtrace = ktrace_alloc(XFS_BMAP_KTRACE_SIZE, KM_SLEEP); | 841 | ip->i_xtrace = ktrace_alloc(XFS_BMAP_KTRACE_SIZE, KM_NOFS); |
842 | #endif | 842 | #endif |
843 | #ifdef XFS_BMBT_TRACE | 843 | #ifdef XFS_BMBT_TRACE |
844 | ip->i_btrace = ktrace_alloc(XFS_BMBT_KTRACE_SIZE, KM_SLEEP); | 844 | ip->i_btrace = ktrace_alloc(XFS_BMBT_KTRACE_SIZE, KM_NOFS); |
845 | #endif | 845 | #endif |
846 | #ifdef XFS_RW_TRACE | 846 | #ifdef XFS_RW_TRACE |
847 | ip->i_rwtrace = ktrace_alloc(XFS_RW_KTRACE_SIZE, KM_SLEEP); | 847 | ip->i_rwtrace = ktrace_alloc(XFS_RW_KTRACE_SIZE, KM_NOFS); |
848 | #endif | 848 | #endif |
849 | #ifdef XFS_ILOCK_TRACE | 849 | #ifdef XFS_ILOCK_TRACE |
850 | ip->i_lock_trace = ktrace_alloc(XFS_ILOCK_KTRACE_SIZE, KM_SLEEP); | 850 | ip->i_lock_trace = ktrace_alloc(XFS_ILOCK_KTRACE_SIZE, KM_NOFS); |
851 | #endif | 851 | #endif |
852 | #ifdef XFS_DIR2_TRACE | 852 | #ifdef XFS_DIR2_TRACE |
853 | ip->i_dir_trace = ktrace_alloc(XFS_DIR2_KTRACE_SIZE, KM_SLEEP); | 853 | ip->i_dir_trace = ktrace_alloc(XFS_DIR2_KTRACE_SIZE, KM_NOFS); |
854 | #endif | 854 | #endif |
855 | 855 | ||
856 | /* | 856 | /* |
@@ -1046,9 +1046,9 @@ xfs_ialloc( | |||
1046 | { | 1046 | { |
1047 | xfs_ino_t ino; | 1047 | xfs_ino_t ino; |
1048 | xfs_inode_t *ip; | 1048 | xfs_inode_t *ip; |
1049 | bhv_vnode_t *vp; | ||
1050 | uint flags; | 1049 | uint flags; |
1051 | int error; | 1050 | int error; |
1051 | timespec_t tv; | ||
1052 | 1052 | ||
1053 | /* | 1053 | /* |
1054 | * Call the space management code to pick | 1054 | * Call the space management code to pick |
@@ -1077,13 +1077,12 @@ xfs_ialloc( | |||
1077 | } | 1077 | } |
1078 | ASSERT(ip != NULL); | 1078 | ASSERT(ip != NULL); |
1079 | 1079 | ||
1080 | vp = XFS_ITOV(ip); | ||
1081 | ip->i_d.di_mode = (__uint16_t)mode; | 1080 | ip->i_d.di_mode = (__uint16_t)mode; |
1082 | ip->i_d.di_onlink = 0; | 1081 | ip->i_d.di_onlink = 0; |
1083 | ip->i_d.di_nlink = nlink; | 1082 | ip->i_d.di_nlink = nlink; |
1084 | ASSERT(ip->i_d.di_nlink == nlink); | 1083 | ASSERT(ip->i_d.di_nlink == nlink); |
1085 | ip->i_d.di_uid = current_fsuid(cr); | 1084 | ip->i_d.di_uid = current_fsuid(); |
1086 | ip->i_d.di_gid = current_fsgid(cr); | 1085 | ip->i_d.di_gid = current_fsgid(); |
1087 | ip->i_d.di_projid = prid; | 1086 | ip->i_d.di_projid = prid; |
1088 | memset(&(ip->i_d.di_pad[0]), 0, sizeof(ip->i_d.di_pad)); | 1087 | memset(&(ip->i_d.di_pad[0]), 0, sizeof(ip->i_d.di_pad)); |
1089 | 1088 | ||
@@ -1130,7 +1129,13 @@ xfs_ialloc( | |||
1130 | ip->i_size = 0; | 1129 | ip->i_size = 0; |
1131 | ip->i_d.di_nextents = 0; | 1130 | ip->i_d.di_nextents = 0; |
1132 | ASSERT(ip->i_d.di_nblocks == 0); | 1131 | ASSERT(ip->i_d.di_nblocks == 0); |
1133 | xfs_ichgtime(ip, XFS_ICHGTIME_CHG|XFS_ICHGTIME_ACC|XFS_ICHGTIME_MOD); | 1132 | |
1133 | nanotime(&tv); | ||
1134 | ip->i_d.di_mtime.t_sec = (__int32_t)tv.tv_sec; | ||
1135 | ip->i_d.di_mtime.t_nsec = (__int32_t)tv.tv_nsec; | ||
1136 | ip->i_d.di_atime = ip->i_d.di_mtime; | ||
1137 | ip->i_d.di_ctime = ip->i_d.di_mtime; | ||
1138 | |||
1134 | /* | 1139 | /* |
1135 | * di_gen will have been taken care of in xfs_iread. | 1140 | * di_gen will have been taken care of in xfs_iread. |
1136 | */ | 1141 | */ |
@@ -1220,7 +1225,7 @@ xfs_ialloc( | |||
1220 | xfs_trans_log_inode(tp, ip, flags); | 1225 | xfs_trans_log_inode(tp, ip, flags); |
1221 | 1226 | ||
1222 | /* now that we have an i_mode we can setup inode ops and unlock */ | 1227 | /* now that we have an i_mode we can setup inode ops and unlock */ |
1223 | xfs_initialize_vnode(tp->t_mountp, vp, ip); | 1228 | xfs_setup_inode(ip); |
1224 | 1229 | ||
1225 | *ipp = ip; | 1230 | *ipp = ip; |
1226 | return 0; | 1231 | return 0; |
@@ -1399,7 +1404,6 @@ xfs_itruncate_start( | |||
1399 | xfs_fsize_t last_byte; | 1404 | xfs_fsize_t last_byte; |
1400 | xfs_off_t toss_start; | 1405 | xfs_off_t toss_start; |
1401 | xfs_mount_t *mp; | 1406 | xfs_mount_t *mp; |
1402 | bhv_vnode_t *vp; | ||
1403 | int error = 0; | 1407 | int error = 0; |
1404 | 1408 | ||
1405 | ASSERT(xfs_isilocked(ip, XFS_IOLOCK_EXCL)); | 1409 | ASSERT(xfs_isilocked(ip, XFS_IOLOCK_EXCL)); |
@@ -1408,7 +1412,6 @@ xfs_itruncate_start( | |||
1408 | (flags == XFS_ITRUNC_MAYBE)); | 1412 | (flags == XFS_ITRUNC_MAYBE)); |
1409 | 1413 | ||
1410 | mp = ip->i_mount; | 1414 | mp = ip->i_mount; |
1411 | vp = XFS_ITOV(ip); | ||
1412 | 1415 | ||
1413 | /* wait for the completion of any pending DIOs */ | 1416 | /* wait for the completion of any pending DIOs */ |
1414 | if (new_size < ip->i_size) | 1417 | if (new_size < ip->i_size) |
@@ -1457,7 +1460,7 @@ xfs_itruncate_start( | |||
1457 | 1460 | ||
1458 | #ifdef DEBUG | 1461 | #ifdef DEBUG |
1459 | if (new_size == 0) { | 1462 | if (new_size == 0) { |
1460 | ASSERT(VN_CACHED(vp) == 0); | 1463 | ASSERT(VN_CACHED(VFS_I(ip)) == 0); |
1461 | } | 1464 | } |
1462 | #endif | 1465 | #endif |
1463 | return error; | 1466 | return error; |
@@ -2630,7 +2633,6 @@ xfs_idestroy( | |||
2630 | xfs_idestroy_fork(ip, XFS_ATTR_FORK); | 2633 | xfs_idestroy_fork(ip, XFS_ATTR_FORK); |
2631 | mrfree(&ip->i_lock); | 2634 | mrfree(&ip->i_lock); |
2632 | mrfree(&ip->i_iolock); | 2635 | mrfree(&ip->i_iolock); |
2633 | freesema(&ip->i_flock); | ||
2634 | 2636 | ||
2635 | #ifdef XFS_INODE_TRACE | 2637 | #ifdef XFS_INODE_TRACE |
2636 | ktrace_free(ip->i_trace); | 2638 | ktrace_free(ip->i_trace); |
@@ -3048,10 +3050,10 @@ cluster_corrupt_out: | |||
3048 | /* | 3050 | /* |
3049 | * xfs_iflush() will write a modified inode's changes out to the | 3051 | * xfs_iflush() will write a modified inode's changes out to the |
3050 | * inode's on disk home. The caller must have the inode lock held | 3052 | * inode's on disk home. The caller must have the inode lock held |
3051 | * in at least shared mode and the inode flush semaphore must be | 3053 | * in at least shared mode and the inode flush completion must be |
3052 | * held as well. The inode lock will still be held upon return from | 3054 | * active as well. The inode lock will still be held upon return from |
3053 | * the call and the caller is free to unlock it. | 3055 | * the call and the caller is free to unlock it. |
3054 | * The inode flush lock will be unlocked when the inode reaches the disk. | 3056 | * The inode flush will be completed when the inode reaches the disk. |
3055 | * The flags indicate how the inode's buffer should be written out. | 3057 | * The flags indicate how the inode's buffer should be written out. |
3056 | */ | 3058 | */ |
3057 | int | 3059 | int |
@@ -3070,7 +3072,7 @@ xfs_iflush( | |||
3070 | XFS_STATS_INC(xs_iflush_count); | 3072 | XFS_STATS_INC(xs_iflush_count); |
3071 | 3073 | ||
3072 | ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL|XFS_ILOCK_SHARED)); | 3074 | ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL|XFS_ILOCK_SHARED)); |
3073 | ASSERT(issemalocked(&(ip->i_flock))); | 3075 | ASSERT(!completion_done(&ip->i_flush)); |
3074 | ASSERT(ip->i_d.di_format != XFS_DINODE_FMT_BTREE || | 3076 | ASSERT(ip->i_d.di_format != XFS_DINODE_FMT_BTREE || |
3075 | ip->i_d.di_nextents > ip->i_df.if_ext_max); | 3077 | ip->i_d.di_nextents > ip->i_df.if_ext_max); |
3076 | 3078 | ||
@@ -3233,7 +3235,7 @@ xfs_iflush_int( | |||
3233 | #endif | 3235 | #endif |
3234 | 3236 | ||
3235 | ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL|XFS_ILOCK_SHARED)); | 3237 | ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL|XFS_ILOCK_SHARED)); |
3236 | ASSERT(issemalocked(&(ip->i_flock))); | 3238 | ASSERT(!completion_done(&ip->i_flush)); |
3237 | ASSERT(ip->i_d.di_format != XFS_DINODE_FMT_BTREE || | 3239 | ASSERT(ip->i_d.di_format != XFS_DINODE_FMT_BTREE || |
3238 | ip->i_d.di_nextents > ip->i_df.if_ext_max); | 3240 | ip->i_d.di_nextents > ip->i_df.if_ext_max); |
3239 | 3241 | ||
@@ -3465,7 +3467,6 @@ xfs_iflush_all( | |||
3465 | xfs_mount_t *mp) | 3467 | xfs_mount_t *mp) |
3466 | { | 3468 | { |
3467 | xfs_inode_t *ip; | 3469 | xfs_inode_t *ip; |
3468 | bhv_vnode_t *vp; | ||
3469 | 3470 | ||
3470 | again: | 3471 | again: |
3471 | XFS_MOUNT_ILOCK(mp); | 3472 | XFS_MOUNT_ILOCK(mp); |
@@ -3480,14 +3481,13 @@ xfs_iflush_all( | |||
3480 | continue; | 3481 | continue; |
3481 | } | 3482 | } |
3482 | 3483 | ||
3483 | vp = XFS_ITOV_NULL(ip); | 3484 | if (!VFS_I(ip)) { |
3484 | if (!vp) { | ||
3485 | XFS_MOUNT_IUNLOCK(mp); | 3485 | XFS_MOUNT_IUNLOCK(mp); |
3486 | xfs_finish_reclaim(ip, 0, XFS_IFLUSH_ASYNC); | 3486 | xfs_finish_reclaim(ip, 0, XFS_IFLUSH_ASYNC); |
3487 | goto again; | 3487 | goto again; |
3488 | } | 3488 | } |
3489 | 3489 | ||
3490 | ASSERT(vn_count(vp) == 0); | 3490 | ASSERT(vn_count(VFS_I(ip)) == 0); |
3491 | 3491 | ||
3492 | ip = ip->i_mnext; | 3492 | ip = ip->i_mnext; |
3493 | } while (ip != mp->m_inodes); | 3493 | } while (ip != mp->m_inodes); |
@@ -3707,7 +3707,7 @@ xfs_iext_add_indirect_multi( | |||
3707 | * (all extents past */ | 3707 | * (all extents past */ |
3708 | if (nex2) { | 3708 | if (nex2) { |
3709 | byte_diff = nex2 * sizeof(xfs_bmbt_rec_t); | 3709 | byte_diff = nex2 * sizeof(xfs_bmbt_rec_t); |
3710 | nex2_ep = (xfs_bmbt_rec_t *) kmem_alloc(byte_diff, KM_SLEEP); | 3710 | nex2_ep = (xfs_bmbt_rec_t *) kmem_alloc(byte_diff, KM_NOFS); |
3711 | memmove(nex2_ep, &erp->er_extbuf[idx], byte_diff); | 3711 | memmove(nex2_ep, &erp->er_extbuf[idx], byte_diff); |
3712 | erp->er_extcount -= nex2; | 3712 | erp->er_extcount -= nex2; |
3713 | xfs_iext_irec_update_extoffs(ifp, erp_idx + 1, -nex2); | 3713 | xfs_iext_irec_update_extoffs(ifp, erp_idx + 1, -nex2); |
@@ -4007,8 +4007,7 @@ xfs_iext_realloc_direct( | |||
4007 | ifp->if_u1.if_extents = | 4007 | ifp->if_u1.if_extents = |
4008 | kmem_realloc(ifp->if_u1.if_extents, | 4008 | kmem_realloc(ifp->if_u1.if_extents, |
4009 | rnew_size, | 4009 | rnew_size, |
4010 | ifp->if_real_bytes, | 4010 | ifp->if_real_bytes, KM_NOFS); |
4011 | KM_SLEEP); | ||
4012 | } | 4011 | } |
4013 | if (rnew_size > ifp->if_real_bytes) { | 4012 | if (rnew_size > ifp->if_real_bytes) { |
4014 | memset(&ifp->if_u1.if_extents[ifp->if_bytes / | 4013 | memset(&ifp->if_u1.if_extents[ifp->if_bytes / |
@@ -4067,7 +4066,7 @@ xfs_iext_inline_to_direct( | |||
4067 | xfs_ifork_t *ifp, /* inode fork pointer */ | 4066 | xfs_ifork_t *ifp, /* inode fork pointer */ |
4068 | int new_size) /* number of extents in file */ | 4067 | int new_size) /* number of extents in file */ |
4069 | { | 4068 | { |
4070 | ifp->if_u1.if_extents = kmem_alloc(new_size, KM_SLEEP); | 4069 | ifp->if_u1.if_extents = kmem_alloc(new_size, KM_NOFS); |
4071 | memset(ifp->if_u1.if_extents, 0, new_size); | 4070 | memset(ifp->if_u1.if_extents, 0, new_size); |
4072 | if (ifp->if_bytes) { | 4071 | if (ifp->if_bytes) { |
4073 | memcpy(ifp->if_u1.if_extents, ifp->if_u2.if_inline_ext, | 4072 | memcpy(ifp->if_u1.if_extents, ifp->if_u2.if_inline_ext, |
@@ -4099,7 +4098,7 @@ xfs_iext_realloc_indirect( | |||
4099 | } else { | 4098 | } else { |
4100 | ifp->if_u1.if_ext_irec = (xfs_ext_irec_t *) | 4099 | ifp->if_u1.if_ext_irec = (xfs_ext_irec_t *) |
4101 | kmem_realloc(ifp->if_u1.if_ext_irec, | 4100 | kmem_realloc(ifp->if_u1.if_ext_irec, |
4102 | new_size, size, KM_SLEEP); | 4101 | new_size, size, KM_NOFS); |
4103 | } | 4102 | } |
4104 | } | 4103 | } |
4105 | 4104 | ||
@@ -4341,11 +4340,10 @@ xfs_iext_irec_init( | |||
4341 | nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t); | 4340 | nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t); |
4342 | ASSERT(nextents <= XFS_LINEAR_EXTS); | 4341 | ASSERT(nextents <= XFS_LINEAR_EXTS); |
4343 | 4342 | ||
4344 | erp = (xfs_ext_irec_t *) | 4343 | erp = kmem_alloc(sizeof(xfs_ext_irec_t), KM_NOFS); |
4345 | kmem_alloc(sizeof(xfs_ext_irec_t), KM_SLEEP); | ||
4346 | 4344 | ||
4347 | if (nextents == 0) { | 4345 | if (nextents == 0) { |
4348 | ifp->if_u1.if_extents = kmem_alloc(XFS_IEXT_BUFSZ, KM_SLEEP); | 4346 | ifp->if_u1.if_extents = kmem_alloc(XFS_IEXT_BUFSZ, KM_NOFS); |
4349 | } else if (!ifp->if_real_bytes) { | 4347 | } else if (!ifp->if_real_bytes) { |
4350 | xfs_iext_inline_to_direct(ifp, XFS_IEXT_BUFSZ); | 4348 | xfs_iext_inline_to_direct(ifp, XFS_IEXT_BUFSZ); |
4351 | } else if (ifp->if_real_bytes < XFS_IEXT_BUFSZ) { | 4349 | } else if (ifp->if_real_bytes < XFS_IEXT_BUFSZ) { |
@@ -4393,7 +4391,7 @@ xfs_iext_irec_new( | |||
4393 | 4391 | ||
4394 | /* Initialize new extent record */ | 4392 | /* Initialize new extent record */ |
4395 | erp = ifp->if_u1.if_ext_irec; | 4393 | erp = ifp->if_u1.if_ext_irec; |
4396 | erp[erp_idx].er_extbuf = kmem_alloc(XFS_IEXT_BUFSZ, KM_SLEEP); | 4394 | erp[erp_idx].er_extbuf = kmem_alloc(XFS_IEXT_BUFSZ, KM_NOFS); |
4397 | ifp->if_real_bytes = nlists * XFS_IEXT_BUFSZ; | 4395 | ifp->if_real_bytes = nlists * XFS_IEXT_BUFSZ; |
4398 | memset(erp[erp_idx].er_extbuf, 0, XFS_IEXT_BUFSZ); | 4396 | memset(erp[erp_idx].er_extbuf, 0, XFS_IEXT_BUFSZ); |
4399 | erp[erp_idx].er_extcount = 0; | 4397 | erp[erp_idx].er_extcount = 0; |