diff options
Diffstat (limited to 'fs/xfs/xfs_vnodeops.c')
| -rw-r--r-- | fs/xfs/xfs_vnodeops.c | 331 |
1 files changed, 75 insertions, 256 deletions
diff --git a/fs/xfs/xfs_vnodeops.c b/fs/xfs/xfs_vnodeops.c index c1646838898f..66d585c6917c 100644 --- a/fs/xfs/xfs_vnodeops.c +++ b/fs/xfs/xfs_vnodeops.c | |||
| @@ -26,19 +26,14 @@ | |||
| 26 | #include "xfs_sb.h" | 26 | #include "xfs_sb.h" |
| 27 | #include "xfs_ag.h" | 27 | #include "xfs_ag.h" |
| 28 | #include "xfs_dir2.h" | 28 | #include "xfs_dir2.h" |
| 29 | #include "xfs_dmapi.h" | ||
| 30 | #include "xfs_mount.h" | 29 | #include "xfs_mount.h" |
| 31 | #include "xfs_da_btree.h" | 30 | #include "xfs_da_btree.h" |
| 32 | #include "xfs_bmap_btree.h" | 31 | #include "xfs_bmap_btree.h" |
| 33 | #include "xfs_alloc_btree.h" | ||
| 34 | #include "xfs_ialloc_btree.h" | 32 | #include "xfs_ialloc_btree.h" |
| 35 | #include "xfs_dir2_sf.h" | ||
| 36 | #include "xfs_attr_sf.h" | ||
| 37 | #include "xfs_dinode.h" | 33 | #include "xfs_dinode.h" |
| 38 | #include "xfs_inode.h" | 34 | #include "xfs_inode.h" |
| 39 | #include "xfs_inode_item.h" | 35 | #include "xfs_inode_item.h" |
| 40 | #include "xfs_itable.h" | 36 | #include "xfs_itable.h" |
| 41 | #include "xfs_btree.h" | ||
| 42 | #include "xfs_ialloc.h" | 37 | #include "xfs_ialloc.h" |
| 43 | #include "xfs_alloc.h" | 38 | #include "xfs_alloc.h" |
| 44 | #include "xfs_bmap.h" | 39 | #include "xfs_bmap.h" |
| @@ -73,7 +68,7 @@ xfs_setattr( | |||
| 73 | struct xfs_dquot *udqp, *gdqp, *olddquot1, *olddquot2; | 68 | struct xfs_dquot *udqp, *gdqp, *olddquot1, *olddquot2; |
| 74 | int need_iolock = 1; | 69 | int need_iolock = 1; |
| 75 | 70 | ||
| 76 | xfs_itrace_entry(ip); | 71 | trace_xfs_setattr(ip); |
| 77 | 72 | ||
| 78 | if (mp->m_flags & XFS_MOUNT_RDONLY) | 73 | if (mp->m_flags & XFS_MOUNT_RDONLY) |
| 79 | return XFS_ERROR(EROFS); | 74 | return XFS_ERROR(EROFS); |
| @@ -143,16 +138,6 @@ xfs_setattr( | |||
| 143 | goto error_return; | 138 | goto error_return; |
| 144 | } | 139 | } |
| 145 | } else { | 140 | } else { |
| 146 | if (DM_EVENT_ENABLED(ip, DM_EVENT_TRUNCATE) && | ||
| 147 | !(flags & XFS_ATTR_DMI)) { | ||
| 148 | int dmflags = AT_DELAY_FLAG(flags) | DM_SEM_FLAG_WR; | ||
| 149 | code = XFS_SEND_DATA(mp, DM_EVENT_TRUNCATE, ip, | ||
| 150 | iattr->ia_size, 0, dmflags, NULL); | ||
| 151 | if (code) { | ||
| 152 | lock_flags = 0; | ||
| 153 | goto error_return; | ||
| 154 | } | ||
| 155 | } | ||
| 156 | if (need_iolock) | 141 | if (need_iolock) |
| 157 | lock_flags |= XFS_IOLOCK_EXCL; | 142 | lock_flags |= XFS_IOLOCK_EXCL; |
| 158 | } | 143 | } |
| @@ -236,8 +221,11 @@ xfs_setattr( | |||
| 236 | * transaction to modify the i_size. | 221 | * transaction to modify the i_size. |
| 237 | */ | 222 | */ |
| 238 | code = xfs_zero_eof(ip, iattr->ia_size, ip->i_size); | 223 | code = xfs_zero_eof(ip, iattr->ia_size, ip->i_size); |
| 224 | if (code) | ||
| 225 | goto error_return; | ||
| 239 | } | 226 | } |
| 240 | xfs_iunlock(ip, XFS_ILOCK_EXCL); | 227 | xfs_iunlock(ip, XFS_ILOCK_EXCL); |
| 228 | lock_flags &= ~XFS_ILOCK_EXCL; | ||
| 241 | 229 | ||
| 242 | /* | 230 | /* |
| 243 | * We are going to log the inode size change in this | 231 | * We are going to log the inode size change in this |
| @@ -251,40 +239,38 @@ xfs_setattr( | |||
| 251 | * really care about here and prevents waiting for other data | 239 | * really care about here and prevents waiting for other data |
| 252 | * not within the range we care about here. | 240 | * not within the range we care about here. |
| 253 | */ | 241 | */ |
| 254 | if (!code && | 242 | if (ip->i_size != ip->i_d.di_size && |
| 255 | ip->i_size != ip->i_d.di_size && | ||
| 256 | iattr->ia_size > ip->i_d.di_size) { | 243 | iattr->ia_size > ip->i_d.di_size) { |
| 257 | code = xfs_flush_pages(ip, | 244 | code = xfs_flush_pages(ip, |
| 258 | ip->i_d.di_size, iattr->ia_size, | 245 | ip->i_d.di_size, iattr->ia_size, |
| 259 | XBF_ASYNC, FI_NONE); | 246 | XBF_ASYNC, FI_NONE); |
| 247 | if (code) | ||
| 248 | goto error_return; | ||
| 260 | } | 249 | } |
| 261 | 250 | ||
| 262 | /* wait for all I/O to complete */ | 251 | /* wait for all I/O to complete */ |
| 263 | xfs_ioend_wait(ip); | 252 | xfs_ioend_wait(ip); |
| 264 | 253 | ||
| 265 | if (!code) | 254 | code = -block_truncate_page(inode->i_mapping, iattr->ia_size, |
| 266 | code = xfs_itruncate_data(ip, iattr->ia_size); | 255 | xfs_get_blocks); |
| 267 | if (code) { | 256 | if (code) |
| 268 | ASSERT(tp == NULL); | ||
| 269 | lock_flags &= ~XFS_ILOCK_EXCL; | ||
| 270 | ASSERT(lock_flags == XFS_IOLOCK_EXCL || !need_iolock); | ||
| 271 | goto error_return; | 257 | goto error_return; |
| 272 | } | 258 | |
| 273 | tp = xfs_trans_alloc(mp, XFS_TRANS_SETATTR_SIZE); | 259 | tp = xfs_trans_alloc(mp, XFS_TRANS_SETATTR_SIZE); |
| 274 | if ((code = xfs_trans_reserve(tp, 0, | 260 | code = xfs_trans_reserve(tp, 0, XFS_ITRUNCATE_LOG_RES(mp), 0, |
| 275 | XFS_ITRUNCATE_LOG_RES(mp), 0, | 261 | XFS_TRANS_PERM_LOG_RES, |
| 276 | XFS_TRANS_PERM_LOG_RES, | 262 | XFS_ITRUNCATE_LOG_COUNT); |
| 277 | XFS_ITRUNCATE_LOG_COUNT))) { | 263 | if (code) |
| 278 | xfs_trans_cancel(tp, 0); | 264 | goto error_return; |
| 279 | if (need_iolock) | 265 | |
| 280 | xfs_iunlock(ip, XFS_IOLOCK_EXCL); | 266 | truncate_setsize(inode, iattr->ia_size); |
| 281 | return code; | 267 | |
| 282 | } | ||
| 283 | commit_flags = XFS_TRANS_RELEASE_LOG_RES; | 268 | commit_flags = XFS_TRANS_RELEASE_LOG_RES; |
| 269 | lock_flags |= XFS_ILOCK_EXCL; | ||
| 270 | |||
| 284 | xfs_ilock(ip, XFS_ILOCK_EXCL); | 271 | xfs_ilock(ip, XFS_ILOCK_EXCL); |
| 285 | 272 | ||
| 286 | xfs_trans_ijoin(tp, ip, lock_flags); | 273 | xfs_trans_ijoin(tp, ip); |
| 287 | xfs_trans_ihold(tp, ip); | ||
| 288 | 274 | ||
| 289 | /* | 275 | /* |
| 290 | * Only change the c/mtime if we are changing the size | 276 | * Only change the c/mtime if we are changing the size |
| @@ -334,8 +320,7 @@ xfs_setattr( | |||
| 334 | xfs_iflags_set(ip, XFS_ITRUNCATED); | 320 | xfs_iflags_set(ip, XFS_ITRUNCATED); |
| 335 | } | 321 | } |
| 336 | } else if (tp) { | 322 | } else if (tp) { |
| 337 | xfs_trans_ijoin(tp, ip, lock_flags); | 323 | xfs_trans_ijoin(tp, ip); |
| 338 | xfs_trans_ihold(tp, ip); | ||
| 339 | } | 324 | } |
| 340 | 325 | ||
| 341 | /* | 326 | /* |
| @@ -470,17 +455,10 @@ xfs_setattr( | |||
| 470 | return XFS_ERROR(code); | 455 | return XFS_ERROR(code); |
| 471 | } | 456 | } |
| 472 | 457 | ||
| 473 | if (DM_EVENT_ENABLED(ip, DM_EVENT_ATTRIBUTE) && | ||
| 474 | !(flags & XFS_ATTR_DMI)) { | ||
| 475 | (void) XFS_SEND_NAMESP(mp, DM_EVENT_ATTRIBUTE, ip, DM_RIGHT_NULL, | ||
| 476 | NULL, DM_RIGHT_NULL, NULL, NULL, | ||
| 477 | 0, 0, AT_DELAY_FLAG(flags)); | ||
| 478 | } | ||
| 479 | return 0; | 458 | return 0; |
| 480 | 459 | ||
| 481 | abort_return: | 460 | abort_return: |
| 482 | commit_flags |= XFS_TRANS_ABORT; | 461 | commit_flags |= XFS_TRANS_ABORT; |
| 483 | /* FALLTHROUGH */ | ||
| 484 | error_return: | 462 | error_return: |
| 485 | xfs_qm_dqrele(udqp); | 463 | xfs_qm_dqrele(udqp); |
| 486 | xfs_qm_dqrele(gdqp); | 464 | xfs_qm_dqrele(gdqp); |
| @@ -516,7 +494,7 @@ xfs_readlink_bmap( | |||
| 516 | int error = 0; | 494 | int error = 0; |
| 517 | 495 | ||
| 518 | error = xfs_bmapi(NULL, ip, 0, XFS_B_TO_FSB(mp, pathlen), 0, NULL, 0, | 496 | error = xfs_bmapi(NULL, ip, 0, XFS_B_TO_FSB(mp, pathlen), 0, NULL, 0, |
| 519 | mval, &nmaps, NULL, NULL); | 497 | mval, &nmaps, NULL); |
| 520 | if (error) | 498 | if (error) |
| 521 | goto out; | 499 | goto out; |
| 522 | 500 | ||
| @@ -557,7 +535,7 @@ xfs_readlink( | |||
| 557 | int pathlen; | 535 | int pathlen; |
| 558 | int error = 0; | 536 | int error = 0; |
| 559 | 537 | ||
| 560 | xfs_itrace_entry(ip); | 538 | trace_xfs_readlink(ip); |
| 561 | 539 | ||
| 562 | if (XFS_FORCED_SHUTDOWN(mp)) | 540 | if (XFS_FORCED_SHUTDOWN(mp)) |
| 563 | return XFS_ERROR(EIO); | 541 | return XFS_ERROR(EIO); |
| @@ -613,14 +591,14 @@ xfs_free_eofblocks( | |||
| 613 | */ | 591 | */ |
| 614 | end_fsb = XFS_B_TO_FSB(mp, ((xfs_ufsize_t)ip->i_size)); | 592 | end_fsb = XFS_B_TO_FSB(mp, ((xfs_ufsize_t)ip->i_size)); |
| 615 | last_fsb = XFS_B_TO_FSB(mp, (xfs_ufsize_t)XFS_MAXIOFFSET(mp)); | 593 | last_fsb = XFS_B_TO_FSB(mp, (xfs_ufsize_t)XFS_MAXIOFFSET(mp)); |
| 616 | map_len = last_fsb - end_fsb; | 594 | if (last_fsb <= end_fsb) |
| 617 | if (map_len <= 0) | ||
| 618 | return 0; | 595 | return 0; |
| 596 | map_len = last_fsb - end_fsb; | ||
| 619 | 597 | ||
| 620 | nimaps = 1; | 598 | nimaps = 1; |
| 621 | xfs_ilock(ip, XFS_ILOCK_SHARED); | 599 | xfs_ilock(ip, XFS_ILOCK_SHARED); |
| 622 | error = xfs_bmapi(NULL, ip, end_fsb, map_len, 0, | 600 | error = xfs_bmapi(NULL, ip, end_fsb, map_len, 0, |
| 623 | NULL, 0, &imap, &nimaps, NULL, NULL); | 601 | NULL, 0, &imap, &nimaps, NULL); |
| 624 | xfs_iunlock(ip, XFS_ILOCK_SHARED); | 602 | xfs_iunlock(ip, XFS_ILOCK_SHARED); |
| 625 | 603 | ||
| 626 | if (!error && (nimaps != 0) && | 604 | if (!error && (nimaps != 0) && |
| @@ -675,10 +653,7 @@ xfs_free_eofblocks( | |||
| 675 | } | 653 | } |
| 676 | 654 | ||
| 677 | xfs_ilock(ip, XFS_ILOCK_EXCL); | 655 | xfs_ilock(ip, XFS_ILOCK_EXCL); |
| 678 | xfs_trans_ijoin(tp, ip, | 656 | xfs_trans_ijoin(tp, ip); |
| 679 | XFS_IOLOCK_EXCL | | ||
| 680 | XFS_ILOCK_EXCL); | ||
| 681 | xfs_trans_ihold(tp, ip); | ||
| 682 | 657 | ||
| 683 | error = xfs_itruncate_finish(&tp, ip, | 658 | error = xfs_itruncate_finish(&tp, ip, |
| 684 | ip->i_size, | 659 | ip->i_size, |
| @@ -750,8 +725,7 @@ xfs_inactive_symlink_rmt( | |||
| 750 | xfs_ilock(ip, XFS_IOLOCK_EXCL | XFS_ILOCK_EXCL); | 725 | xfs_ilock(ip, XFS_IOLOCK_EXCL | XFS_ILOCK_EXCL); |
| 751 | size = (int)ip->i_d.di_size; | 726 | size = (int)ip->i_d.di_size; |
| 752 | ip->i_d.di_size = 0; | 727 | ip->i_d.di_size = 0; |
| 753 | xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL | XFS_IOLOCK_EXCL); | 728 | xfs_trans_ijoin(tp, ip); |
| 754 | xfs_trans_ihold(tp, ip); | ||
| 755 | xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); | 729 | xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); |
| 756 | /* | 730 | /* |
| 757 | * Find the block(s) so we can inval and unmap them. | 731 | * Find the block(s) so we can inval and unmap them. |
| @@ -761,7 +735,7 @@ xfs_inactive_symlink_rmt( | |||
| 761 | nmaps = ARRAY_SIZE(mval); | 735 | nmaps = ARRAY_SIZE(mval); |
| 762 | if ((error = xfs_bmapi(tp, ip, 0, XFS_B_TO_FSB(mp, size), | 736 | if ((error = xfs_bmapi(tp, ip, 0, XFS_B_TO_FSB(mp, size), |
| 763 | XFS_BMAPI_METADATA, &first_block, 0, mval, &nmaps, | 737 | XFS_BMAPI_METADATA, &first_block, 0, mval, &nmaps, |
| 764 | &free_list, NULL))) | 738 | &free_list))) |
| 765 | goto error0; | 739 | goto error0; |
| 766 | /* | 740 | /* |
| 767 | * Invalidate the block(s). | 741 | * Invalidate the block(s). |
| @@ -776,7 +750,7 @@ xfs_inactive_symlink_rmt( | |||
| 776 | * Unmap the dead block(s) to the free_list. | 750 | * Unmap the dead block(s) to the free_list. |
| 777 | */ | 751 | */ |
| 778 | if ((error = xfs_bunmapi(tp, ip, 0, size, XFS_BMAPI_METADATA, nmaps, | 752 | if ((error = xfs_bunmapi(tp, ip, 0, size, XFS_BMAPI_METADATA, nmaps, |
| 779 | &first_block, &free_list, NULL, &done))) | 753 | &first_block, &free_list, &done))) |
| 780 | goto error1; | 754 | goto error1; |
| 781 | ASSERT(done); | 755 | ASSERT(done); |
| 782 | /* | 756 | /* |
| @@ -795,8 +769,7 @@ xfs_inactive_symlink_rmt( | |||
| 795 | * Mark it dirty so it will be logged and moved forward in the log as | 769 | * Mark it dirty so it will be logged and moved forward in the log as |
| 796 | * part of every commit. | 770 | * part of every commit. |
| 797 | */ | 771 | */ |
| 798 | xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL | XFS_IOLOCK_EXCL); | 772 | xfs_trans_ijoin(tp, ip); |
| 799 | xfs_trans_ihold(tp, ip); | ||
| 800 | xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); | 773 | xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); |
| 801 | /* | 774 | /* |
| 802 | * Get a new, empty transaction to return to our caller. | 775 | * Get a new, empty transaction to return to our caller. |
| @@ -929,8 +902,7 @@ xfs_inactive_attrs( | |||
| 929 | goto error_cancel; | 902 | goto error_cancel; |
| 930 | 903 | ||
| 931 | xfs_ilock(ip, XFS_ILOCK_EXCL); | 904 | xfs_ilock(ip, XFS_ILOCK_EXCL); |
| 932 | xfs_trans_ijoin(tp, ip, XFS_IOLOCK_EXCL | XFS_ILOCK_EXCL); | 905 | xfs_trans_ijoin(tp, ip); |
| 933 | xfs_trans_ihold(tp, ip); | ||
| 934 | xfs_idestroy_fork(ip, XFS_ATTR_FORK); | 906 | xfs_idestroy_fork(ip, XFS_ATTR_FORK); |
| 935 | 907 | ||
| 936 | ASSERT(ip->i_d.di_anextents == 0); | 908 | ASSERT(ip->i_d.di_anextents == 0); |
| @@ -1035,8 +1007,6 @@ xfs_inactive( | |||
| 1035 | int error; | 1007 | int error; |
| 1036 | int truncate; | 1008 | int truncate; |
| 1037 | 1009 | ||
| 1038 | xfs_itrace_entry(ip); | ||
| 1039 | |||
| 1040 | /* | 1010 | /* |
| 1041 | * If the inode is already free, then there can be nothing | 1011 | * If the inode is already free, then there can be nothing |
| 1042 | * to clean up here. | 1012 | * to clean up here. |
| @@ -1060,9 +1030,6 @@ xfs_inactive( | |||
| 1060 | 1030 | ||
| 1061 | mp = ip->i_mount; | 1031 | mp = ip->i_mount; |
| 1062 | 1032 | ||
| 1063 | if (ip->i_d.di_nlink == 0 && DM_EVENT_ENABLED(ip, DM_EVENT_DESTROY)) | ||
| 1064 | XFS_SEND_DESTROY(mp, ip, DM_RIGHT_NULL); | ||
| 1065 | |||
| 1066 | error = 0; | 1033 | error = 0; |
| 1067 | 1034 | ||
| 1068 | /* If this is a read-only mount, don't do this (would generate I/O) */ | 1035 | /* If this is a read-only mount, don't do this (would generate I/O) */ |
| @@ -1120,8 +1087,7 @@ xfs_inactive( | |||
| 1120 | } | 1087 | } |
| 1121 | 1088 | ||
| 1122 | xfs_ilock(ip, XFS_ILOCK_EXCL); | 1089 | xfs_ilock(ip, XFS_ILOCK_EXCL); |
| 1123 | xfs_trans_ijoin(tp, ip, XFS_IOLOCK_EXCL | XFS_ILOCK_EXCL); | 1090 | xfs_trans_ijoin(tp, ip); |
| 1124 | xfs_trans_ihold(tp, ip); | ||
| 1125 | 1091 | ||
| 1126 | /* | 1092 | /* |
| 1127 | * normally, we have to run xfs_itruncate_finish sync. | 1093 | * normally, we have to run xfs_itruncate_finish sync. |
| @@ -1154,8 +1120,7 @@ xfs_inactive( | |||
| 1154 | return VN_INACTIVE_CACHE; | 1120 | return VN_INACTIVE_CACHE; |
| 1155 | } | 1121 | } |
| 1156 | 1122 | ||
| 1157 | xfs_trans_ijoin(tp, ip, XFS_IOLOCK_EXCL | XFS_ILOCK_EXCL); | 1123 | xfs_trans_ijoin(tp, ip); |
| 1158 | xfs_trans_ihold(tp, ip); | ||
| 1159 | } else { | 1124 | } else { |
| 1160 | error = xfs_trans_reserve(tp, 0, | 1125 | error = xfs_trans_reserve(tp, 0, |
| 1161 | XFS_IFREE_LOG_RES(mp), | 1126 | XFS_IFREE_LOG_RES(mp), |
| @@ -1168,8 +1133,7 @@ xfs_inactive( | |||
| 1168 | } | 1133 | } |
| 1169 | 1134 | ||
| 1170 | xfs_ilock(ip, XFS_ILOCK_EXCL | XFS_IOLOCK_EXCL); | 1135 | xfs_ilock(ip, XFS_ILOCK_EXCL | XFS_IOLOCK_EXCL); |
| 1171 | xfs_trans_ijoin(tp, ip, XFS_IOLOCK_EXCL | XFS_ILOCK_EXCL); | 1136 | xfs_trans_ijoin(tp, ip); |
| 1172 | xfs_trans_ihold(tp, ip); | ||
| 1173 | } | 1137 | } |
| 1174 | 1138 | ||
| 1175 | /* | 1139 | /* |
| @@ -1257,7 +1221,7 @@ xfs_lookup( | |||
| 1257 | int error; | 1221 | int error; |
| 1258 | uint lock_mode; | 1222 | uint lock_mode; |
| 1259 | 1223 | ||
| 1260 | xfs_itrace_entry(dp); | 1224 | trace_xfs_lookup(dp, name); |
| 1261 | 1225 | ||
| 1262 | if (XFS_FORCED_SHUTDOWN(dp->i_mount)) | 1226 | if (XFS_FORCED_SHUTDOWN(dp->i_mount)) |
| 1263 | return XFS_ERROR(EIO); | 1227 | return XFS_ERROR(EIO); |
| @@ -1309,21 +1273,11 @@ xfs_create( | |||
| 1309 | uint log_res; | 1273 | uint log_res; |
| 1310 | uint log_count; | 1274 | uint log_count; |
| 1311 | 1275 | ||
| 1312 | xfs_itrace_entry(dp); | 1276 | trace_xfs_create(dp, name); |
| 1313 | 1277 | ||
| 1314 | if (XFS_FORCED_SHUTDOWN(mp)) | 1278 | if (XFS_FORCED_SHUTDOWN(mp)) |
| 1315 | return XFS_ERROR(EIO); | 1279 | return XFS_ERROR(EIO); |
| 1316 | 1280 | ||
| 1317 | if (DM_EVENT_ENABLED(dp, DM_EVENT_CREATE)) { | ||
| 1318 | error = XFS_SEND_NAMESP(mp, DM_EVENT_CREATE, | ||
| 1319 | dp, DM_RIGHT_NULL, NULL, | ||
| 1320 | DM_RIGHT_NULL, name->name, NULL, | ||
| 1321 | mode, 0, 0); | ||
| 1322 | |||
| 1323 | if (error) | ||
| 1324 | return error; | ||
| 1325 | } | ||
| 1326 | |||
| 1327 | if (dp->i_d.di_flags & XFS_DIFLAG_PROJINHERIT) | 1281 | if (dp->i_d.di_flags & XFS_DIFLAG_PROJINHERIT) |
| 1328 | prid = dp->i_d.di_projid; | 1282 | prid = dp->i_d.di_projid; |
| 1329 | else | 1283 | else |
| @@ -1427,8 +1381,7 @@ xfs_create( | |||
| 1427 | * the transaction cancel unlocking dp so don't do it explicitly in the | 1381 | * the transaction cancel unlocking dp so don't do it explicitly in the |
| 1428 | * error path. | 1382 | * error path. |
| 1429 | */ | 1383 | */ |
| 1430 | IHOLD(dp); | 1384 | xfs_trans_ijoin_ref(tp, dp, XFS_ILOCK_EXCL); |
| 1431 | xfs_trans_ijoin(tp, dp, XFS_ILOCK_EXCL); | ||
| 1432 | unlock_dp_on_error = B_FALSE; | 1385 | unlock_dp_on_error = B_FALSE; |
| 1433 | 1386 | ||
| 1434 | error = xfs_dir_createname(tp, dp, name, ip->i_ino, | 1387 | error = xfs_dir_createname(tp, dp, name, ip->i_ino, |
| @@ -1487,16 +1440,7 @@ xfs_create( | |||
| 1487 | xfs_qm_dqrele(gdqp); | 1440 | xfs_qm_dqrele(gdqp); |
| 1488 | 1441 | ||
| 1489 | *ipp = ip; | 1442 | *ipp = ip; |
| 1490 | 1443 | return 0; | |
| 1491 | /* Fallthrough to std_return with error = 0 */ | ||
| 1492 | std_return: | ||
| 1493 | if (DM_EVENT_ENABLED(dp, DM_EVENT_POSTCREATE)) { | ||
| 1494 | XFS_SEND_NAMESP(mp, DM_EVENT_POSTCREATE, dp, DM_RIGHT_NULL, | ||
| 1495 | ip, DM_RIGHT_NULL, name->name, NULL, mode, | ||
| 1496 | error, 0); | ||
| 1497 | } | ||
| 1498 | |||
| 1499 | return error; | ||
| 1500 | 1444 | ||
| 1501 | out_bmap_cancel: | 1445 | out_bmap_cancel: |
| 1502 | xfs_bmap_cancel(&free_list); | 1446 | xfs_bmap_cancel(&free_list); |
| @@ -1510,8 +1454,8 @@ xfs_create( | |||
| 1510 | 1454 | ||
| 1511 | if (unlock_dp_on_error) | 1455 | if (unlock_dp_on_error) |
| 1512 | xfs_iunlock(dp, XFS_ILOCK_EXCL); | 1456 | xfs_iunlock(dp, XFS_ILOCK_EXCL); |
| 1513 | 1457 | std_return: | |
| 1514 | goto std_return; | 1458 | return error; |
| 1515 | 1459 | ||
| 1516 | out_abort_rele: | 1460 | out_abort_rele: |
| 1517 | /* | 1461 | /* |
| @@ -1726,20 +1670,11 @@ xfs_remove( | |||
| 1726 | uint resblks; | 1670 | uint resblks; |
| 1727 | uint log_count; | 1671 | uint log_count; |
| 1728 | 1672 | ||
| 1729 | xfs_itrace_entry(dp); | 1673 | trace_xfs_remove(dp, name); |
| 1730 | xfs_itrace_entry(ip); | ||
| 1731 | 1674 | ||
| 1732 | if (XFS_FORCED_SHUTDOWN(mp)) | 1675 | if (XFS_FORCED_SHUTDOWN(mp)) |
| 1733 | return XFS_ERROR(EIO); | 1676 | return XFS_ERROR(EIO); |
| 1734 | 1677 | ||
| 1735 | if (DM_EVENT_ENABLED(dp, DM_EVENT_REMOVE)) { | ||
| 1736 | error = XFS_SEND_NAMESP(mp, DM_EVENT_REMOVE, dp, DM_RIGHT_NULL, | ||
| 1737 | NULL, DM_RIGHT_NULL, name->name, NULL, | ||
| 1738 | ip->i_d.di_mode, 0, 0); | ||
| 1739 | if (error) | ||
| 1740 | return error; | ||
| 1741 | } | ||
| 1742 | |||
| 1743 | error = xfs_qm_dqattach(dp, 0); | 1678 | error = xfs_qm_dqattach(dp, 0); |
| 1744 | if (error) | 1679 | if (error) |
| 1745 | goto std_return; | 1680 | goto std_return; |
| @@ -1782,15 +1717,8 @@ xfs_remove( | |||
| 1782 | 1717 | ||
| 1783 | xfs_lock_two_inodes(dp, ip, XFS_ILOCK_EXCL); | 1718 | xfs_lock_two_inodes(dp, ip, XFS_ILOCK_EXCL); |
| 1784 | 1719 | ||
| 1785 | /* | 1720 | xfs_trans_ijoin_ref(tp, dp, XFS_ILOCK_EXCL); |
| 1786 | * At this point, we've gotten both the directory and the entry | 1721 | xfs_trans_ijoin_ref(tp, ip, XFS_ILOCK_EXCL); |
| 1787 | * inodes locked. | ||
| 1788 | */ | ||
| 1789 | IHOLD(ip); | ||
| 1790 | xfs_trans_ijoin(tp, dp, XFS_ILOCK_EXCL); | ||
| 1791 | |||
| 1792 | IHOLD(dp); | ||
| 1793 | xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL); | ||
| 1794 | 1722 | ||
| 1795 | /* | 1723 | /* |
| 1796 | * If we're removing a directory perform some additional validation. | 1724 | * If we're removing a directory perform some additional validation. |
| @@ -1877,21 +1805,15 @@ xfs_remove( | |||
| 1877 | if (!is_dir && link_zero && xfs_inode_is_filestream(ip)) | 1805 | if (!is_dir && link_zero && xfs_inode_is_filestream(ip)) |
| 1878 | xfs_filestream_deassociate(ip); | 1806 | xfs_filestream_deassociate(ip); |
| 1879 | 1807 | ||
| 1880 | std_return: | 1808 | return 0; |
| 1881 | if (DM_EVENT_ENABLED(dp, DM_EVENT_POSTREMOVE)) { | ||
| 1882 | XFS_SEND_NAMESP(mp, DM_EVENT_POSTREMOVE, dp, DM_RIGHT_NULL, | ||
| 1883 | NULL, DM_RIGHT_NULL, name->name, NULL, | ||
| 1884 | ip->i_d.di_mode, error, 0); | ||
| 1885 | } | ||
| 1886 | |||
| 1887 | return error; | ||
| 1888 | 1809 | ||
| 1889 | out_bmap_cancel: | 1810 | out_bmap_cancel: |
| 1890 | xfs_bmap_cancel(&free_list); | 1811 | xfs_bmap_cancel(&free_list); |
| 1891 | cancel_flags |= XFS_TRANS_ABORT; | 1812 | cancel_flags |= XFS_TRANS_ABORT; |
| 1892 | out_trans_cancel: | 1813 | out_trans_cancel: |
| 1893 | xfs_trans_cancel(tp, cancel_flags); | 1814 | xfs_trans_cancel(tp, cancel_flags); |
| 1894 | goto std_return; | 1815 | std_return: |
| 1816 | return error; | ||
| 1895 | } | 1817 | } |
| 1896 | 1818 | ||
| 1897 | int | 1819 | int |
| @@ -1909,25 +1831,13 @@ xfs_link( | |||
| 1909 | int committed; | 1831 | int committed; |
| 1910 | int resblks; | 1832 | int resblks; |
| 1911 | 1833 | ||
| 1912 | xfs_itrace_entry(tdp); | 1834 | trace_xfs_link(tdp, target_name); |
| 1913 | xfs_itrace_entry(sip); | ||
| 1914 | 1835 | ||
| 1915 | ASSERT(!S_ISDIR(sip->i_d.di_mode)); | 1836 | ASSERT(!S_ISDIR(sip->i_d.di_mode)); |
| 1916 | 1837 | ||
| 1917 | if (XFS_FORCED_SHUTDOWN(mp)) | 1838 | if (XFS_FORCED_SHUTDOWN(mp)) |
| 1918 | return XFS_ERROR(EIO); | 1839 | return XFS_ERROR(EIO); |
| 1919 | 1840 | ||
| 1920 | if (DM_EVENT_ENABLED(tdp, DM_EVENT_LINK)) { | ||
| 1921 | error = XFS_SEND_NAMESP(mp, DM_EVENT_LINK, | ||
| 1922 | tdp, DM_RIGHT_NULL, | ||
| 1923 | sip, DM_RIGHT_NULL, | ||
| 1924 | target_name->name, NULL, 0, 0, 0); | ||
| 1925 | if (error) | ||
| 1926 | return error; | ||
| 1927 | } | ||
| 1928 | |||
| 1929 | /* Return through std_return after this point. */ | ||
| 1930 | |||
| 1931 | error = xfs_qm_dqattach(sip, 0); | 1841 | error = xfs_qm_dqattach(sip, 0); |
| 1932 | if (error) | 1842 | if (error) |
| 1933 | goto std_return; | 1843 | goto std_return; |
| @@ -1953,15 +1863,8 @@ xfs_link( | |||
| 1953 | 1863 | ||
| 1954 | xfs_lock_two_inodes(sip, tdp, XFS_ILOCK_EXCL); | 1864 | xfs_lock_two_inodes(sip, tdp, XFS_ILOCK_EXCL); |
| 1955 | 1865 | ||
| 1956 | /* | 1866 | xfs_trans_ijoin_ref(tp, sip, XFS_ILOCK_EXCL); |
| 1957 | * Increment vnode ref counts since xfs_trans_commit & | 1867 | xfs_trans_ijoin_ref(tp, tdp, XFS_ILOCK_EXCL); |
| 1958 | * xfs_trans_cancel will both unlock the inodes and | ||
| 1959 | * decrement the associated ref counts. | ||
| 1960 | */ | ||
| 1961 | IHOLD(sip); | ||
| 1962 | IHOLD(tdp); | ||
| 1963 | xfs_trans_ijoin(tp, sip, XFS_ILOCK_EXCL); | ||
| 1964 | xfs_trans_ijoin(tp, tdp, XFS_ILOCK_EXCL); | ||
| 1965 | 1868 | ||
| 1966 | /* | 1869 | /* |
| 1967 | * If the source has too many links, we can't make any more to it. | 1870 | * If the source has too many links, we can't make any more to it. |
| @@ -2014,27 +1917,14 @@ xfs_link( | |||
| 2014 | goto abort_return; | 1917 | goto abort_return; |
| 2015 | } | 1918 | } |
| 2016 | 1919 | ||
| 2017 | error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES); | 1920 | return xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES); |
| 2018 | if (error) | ||
| 2019 | goto std_return; | ||
| 2020 | |||
| 2021 | /* Fall through to std_return with error = 0. */ | ||
| 2022 | std_return: | ||
| 2023 | if (DM_EVENT_ENABLED(sip, DM_EVENT_POSTLINK)) { | ||
| 2024 | (void) XFS_SEND_NAMESP(mp, DM_EVENT_POSTLINK, | ||
| 2025 | tdp, DM_RIGHT_NULL, | ||
| 2026 | sip, DM_RIGHT_NULL, | ||
| 2027 | target_name->name, NULL, 0, error, 0); | ||
| 2028 | } | ||
| 2029 | return error; | ||
| 2030 | 1921 | ||
| 2031 | abort_return: | 1922 | abort_return: |
| 2032 | cancel_flags |= XFS_TRANS_ABORT; | 1923 | cancel_flags |= XFS_TRANS_ABORT; |
| 2033 | /* FALLTHROUGH */ | ||
| 2034 | |||
| 2035 | error_return: | 1924 | error_return: |
| 2036 | xfs_trans_cancel(tp, cancel_flags); | 1925 | xfs_trans_cancel(tp, cancel_flags); |
| 2037 | goto std_return; | 1926 | std_return: |
| 1927 | return error; | ||
| 2038 | } | 1928 | } |
| 2039 | 1929 | ||
| 2040 | int | 1930 | int |
| @@ -2074,7 +1964,7 @@ xfs_symlink( | |||
| 2074 | ip = NULL; | 1964 | ip = NULL; |
| 2075 | tp = NULL; | 1965 | tp = NULL; |
| 2076 | 1966 | ||
| 2077 | xfs_itrace_entry(dp); | 1967 | trace_xfs_symlink(dp, link_name); |
| 2078 | 1968 | ||
| 2079 | if (XFS_FORCED_SHUTDOWN(mp)) | 1969 | if (XFS_FORCED_SHUTDOWN(mp)) |
| 2080 | return XFS_ERROR(EIO); | 1970 | return XFS_ERROR(EIO); |
| @@ -2086,17 +1976,6 @@ xfs_symlink( | |||
| 2086 | if (pathlen >= MAXPATHLEN) /* total string too long */ | 1976 | if (pathlen >= MAXPATHLEN) /* total string too long */ |
| 2087 | return XFS_ERROR(ENAMETOOLONG); | 1977 | return XFS_ERROR(ENAMETOOLONG); |
| 2088 | 1978 | ||
| 2089 | if (DM_EVENT_ENABLED(dp, DM_EVENT_SYMLINK)) { | ||
| 2090 | error = XFS_SEND_NAMESP(mp, DM_EVENT_SYMLINK, dp, | ||
| 2091 | DM_RIGHT_NULL, NULL, DM_RIGHT_NULL, | ||
| 2092 | link_name->name, | ||
| 2093 | (unsigned char *)target_path, 0, 0, 0); | ||
| 2094 | if (error) | ||
| 2095 | return error; | ||
| 2096 | } | ||
| 2097 | |||
| 2098 | /* Return through std_return after this point. */ | ||
| 2099 | |||
| 2100 | udqp = gdqp = NULL; | 1979 | udqp = gdqp = NULL; |
| 2101 | if (dp->i_d.di_flags & XFS_DIFLAG_PROJINHERIT) | 1980 | if (dp->i_d.di_flags & XFS_DIFLAG_PROJINHERIT) |
| 2102 | prid = dp->i_d.di_projid; | 1981 | prid = dp->i_d.di_projid; |
| @@ -2180,8 +2059,7 @@ xfs_symlink( | |||
| 2180 | * transaction cancel unlocking dp so don't do it explicitly in the | 2059 | * transaction cancel unlocking dp so don't do it explicitly in the |
| 2181 | * error path. | 2060 | * error path. |
| 2182 | */ | 2061 | */ |
| 2183 | IHOLD(dp); | 2062 | xfs_trans_ijoin_ref(tp, dp, XFS_ILOCK_EXCL); |
| 2184 | xfs_trans_ijoin(tp, dp, XFS_ILOCK_EXCL); | ||
| 2185 | unlock_dp_on_error = B_FALSE; | 2063 | unlock_dp_on_error = B_FALSE; |
| 2186 | 2064 | ||
| 2187 | /* | 2065 | /* |
| @@ -2215,7 +2093,7 @@ xfs_symlink( | |||
| 2215 | error = xfs_bmapi(tp, ip, first_fsb, fs_blocks, | 2093 | error = xfs_bmapi(tp, ip, first_fsb, fs_blocks, |
| 2216 | XFS_BMAPI_WRITE | XFS_BMAPI_METADATA, | 2094 | XFS_BMAPI_WRITE | XFS_BMAPI_METADATA, |
| 2217 | &first_block, resblks, mval, &nmaps, | 2095 | &first_block, resblks, mval, &nmaps, |
| 2218 | &free_list, NULL); | 2096 | &free_list); |
| 2219 | if (error) { | 2097 | if (error) { |
| 2220 | goto error1; | 2098 | goto error1; |
| 2221 | } | 2099 | } |
| @@ -2278,21 +2156,8 @@ xfs_symlink( | |||
| 2278 | xfs_qm_dqrele(udqp); | 2156 | xfs_qm_dqrele(udqp); |
| 2279 | xfs_qm_dqrele(gdqp); | 2157 | xfs_qm_dqrele(gdqp); |
| 2280 | 2158 | ||
| 2281 | /* Fall through to std_return with error = 0 or errno from | 2159 | *ipp = ip; |
| 2282 | * xfs_trans_commit */ | 2160 | return 0; |
| 2283 | std_return: | ||
| 2284 | if (DM_EVENT_ENABLED(dp, DM_EVENT_POSTSYMLINK)) { | ||
| 2285 | (void) XFS_SEND_NAMESP(mp, DM_EVENT_POSTSYMLINK, | ||
| 2286 | dp, DM_RIGHT_NULL, | ||
| 2287 | error ? NULL : ip, | ||
| 2288 | DM_RIGHT_NULL, link_name->name, | ||
| 2289 | (unsigned char *)target_path, | ||
| 2290 | 0, error, 0); | ||
| 2291 | } | ||
| 2292 | |||
| 2293 | if (!error) | ||
| 2294 | *ipp = ip; | ||
| 2295 | return error; | ||
| 2296 | 2161 | ||
| 2297 | error2: | 2162 | error2: |
| 2298 | IRELE(ip); | 2163 | IRELE(ip); |
| @@ -2306,8 +2171,8 @@ std_return: | |||
| 2306 | 2171 | ||
| 2307 | if (unlock_dp_on_error) | 2172 | if (unlock_dp_on_error) |
| 2308 | xfs_iunlock(dp, XFS_ILOCK_EXCL); | 2173 | xfs_iunlock(dp, XFS_ILOCK_EXCL); |
| 2309 | 2174 | std_return: | |
| 2310 | goto std_return; | 2175 | return error; |
| 2311 | } | 2176 | } |
| 2312 | 2177 | ||
| 2313 | int | 2178 | int |
| @@ -2333,13 +2198,12 @@ xfs_set_dmattrs( | |||
| 2333 | return error; | 2198 | return error; |
| 2334 | } | 2199 | } |
| 2335 | xfs_ilock(ip, XFS_ILOCK_EXCL); | 2200 | xfs_ilock(ip, XFS_ILOCK_EXCL); |
| 2336 | xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL); | 2201 | xfs_trans_ijoin_ref(tp, ip, XFS_ILOCK_EXCL); |
| 2337 | 2202 | ||
| 2338 | ip->i_d.di_dmevmask = evmask; | 2203 | ip->i_d.di_dmevmask = evmask; |
| 2339 | ip->i_d.di_dmstate = state; | 2204 | ip->i_d.di_dmstate = state; |
| 2340 | 2205 | ||
| 2341 | xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); | 2206 | xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); |
| 2342 | IHOLD(ip); | ||
| 2343 | error = xfs_trans_commit(tp, 0); | 2207 | error = xfs_trans_commit(tp, 0); |
| 2344 | 2208 | ||
| 2345 | return error; | 2209 | return error; |
| @@ -2390,7 +2254,7 @@ xfs_alloc_file_space( | |||
| 2390 | int committed; | 2254 | int committed; |
| 2391 | int error; | 2255 | int error; |
| 2392 | 2256 | ||
| 2393 | xfs_itrace_entry(ip); | 2257 | trace_xfs_alloc_file_space(ip); |
| 2394 | 2258 | ||
| 2395 | if (XFS_FORCED_SHUTDOWN(mp)) | 2259 | if (XFS_FORCED_SHUTDOWN(mp)) |
| 2396 | return XFS_ERROR(EIO); | 2260 | return XFS_ERROR(EIO); |
| @@ -2412,25 +2276,9 @@ xfs_alloc_file_space( | |||
| 2412 | startoffset_fsb = XFS_B_TO_FSBT(mp, offset); | 2276 | startoffset_fsb = XFS_B_TO_FSBT(mp, offset); |
| 2413 | allocatesize_fsb = XFS_B_TO_FSB(mp, count); | 2277 | allocatesize_fsb = XFS_B_TO_FSB(mp, count); |
| 2414 | 2278 | ||
| 2415 | /* Generate a DMAPI event if needed. */ | ||
| 2416 | if (alloc_type != 0 && offset < ip->i_size && | ||
| 2417 | (attr_flags & XFS_ATTR_DMI) == 0 && | ||
| 2418 | DM_EVENT_ENABLED(ip, DM_EVENT_WRITE)) { | ||
| 2419 | xfs_off_t end_dmi_offset; | ||
| 2420 | |||
| 2421 | end_dmi_offset = offset+len; | ||
| 2422 | if (end_dmi_offset > ip->i_size) | ||
| 2423 | end_dmi_offset = ip->i_size; | ||
| 2424 | error = XFS_SEND_DATA(mp, DM_EVENT_WRITE, ip, offset, | ||
| 2425 | end_dmi_offset - offset, 0, NULL); | ||
| 2426 | if (error) | ||
| 2427 | return error; | ||
| 2428 | } | ||
| 2429 | |||
| 2430 | /* | 2279 | /* |
| 2431 | * Allocate file space until done or until there is an error | 2280 | * Allocate file space until done or until there is an error |
| 2432 | */ | 2281 | */ |
| 2433 | retry: | ||
| 2434 | while (allocatesize_fsb && !error) { | 2282 | while (allocatesize_fsb && !error) { |
| 2435 | xfs_fileoff_t s, e; | 2283 | xfs_fileoff_t s, e; |
| 2436 | 2284 | ||
| @@ -2488,8 +2336,7 @@ retry: | |||
| 2488 | if (error) | 2336 | if (error) |
| 2489 | goto error1; | 2337 | goto error1; |
| 2490 | 2338 | ||
| 2491 | xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL); | 2339 | xfs_trans_ijoin(tp, ip); |
| 2492 | xfs_trans_ihold(tp, ip); | ||
| 2493 | 2340 | ||
| 2494 | /* | 2341 | /* |
| 2495 | * Issue the xfs_bmapi() call to allocate the blocks | 2342 | * Issue the xfs_bmapi() call to allocate the blocks |
| @@ -2498,7 +2345,7 @@ retry: | |||
| 2498 | error = xfs_bmapi(tp, ip, startoffset_fsb, | 2345 | error = xfs_bmapi(tp, ip, startoffset_fsb, |
| 2499 | allocatesize_fsb, bmapi_flag, | 2346 | allocatesize_fsb, bmapi_flag, |
| 2500 | &firstfsb, 0, imapp, &nimaps, | 2347 | &firstfsb, 0, imapp, &nimaps, |
| 2501 | &free_list, NULL); | 2348 | &free_list); |
| 2502 | if (error) { | 2349 | if (error) { |
| 2503 | goto error0; | 2350 | goto error0; |
| 2504 | } | 2351 | } |
| @@ -2527,17 +2374,6 @@ retry: | |||
| 2527 | startoffset_fsb += allocated_fsb; | 2374 | startoffset_fsb += allocated_fsb; |
| 2528 | allocatesize_fsb -= allocated_fsb; | 2375 | allocatesize_fsb -= allocated_fsb; |
| 2529 | } | 2376 | } |
| 2530 | dmapi_enospc_check: | ||
| 2531 | if (error == ENOSPC && (attr_flags & XFS_ATTR_DMI) == 0 && | ||
| 2532 | DM_EVENT_ENABLED(ip, DM_EVENT_NOSPACE)) { | ||
| 2533 | error = XFS_SEND_NAMESP(mp, DM_EVENT_NOSPACE, | ||
| 2534 | ip, DM_RIGHT_NULL, | ||
| 2535 | ip, DM_RIGHT_NULL, | ||
| 2536 | NULL, NULL, 0, 0, 0); /* Delay flag intentionally unused */ | ||
| 2537 | if (error == 0) | ||
| 2538 | goto retry; /* Maybe DMAPI app. has made space */ | ||
| 2539 | /* else fall through with error from XFS_SEND_DATA */ | ||
| 2540 | } | ||
| 2541 | 2377 | ||
| 2542 | return error; | 2378 | return error; |
| 2543 | 2379 | ||
| @@ -2548,7 +2384,7 @@ error0: /* Cancel bmap, unlock inode, unreserve quota blocks, cancel trans */ | |||
| 2548 | error1: /* Just cancel transaction */ | 2384 | error1: /* Just cancel transaction */ |
| 2549 | xfs_trans_cancel(tp, XFS_TRANS_RELEASE_LOG_RES | XFS_TRANS_ABORT); | 2385 | xfs_trans_cancel(tp, XFS_TRANS_RELEASE_LOG_RES | XFS_TRANS_ABORT); |
| 2550 | xfs_iunlock(ip, XFS_ILOCK_EXCL); | 2386 | xfs_iunlock(ip, XFS_ILOCK_EXCL); |
| 2551 | goto dmapi_enospc_check; | 2387 | return error; |
| 2552 | } | 2388 | } |
| 2553 | 2389 | ||
| 2554 | /* | 2390 | /* |
| @@ -2598,7 +2434,7 @@ xfs_zero_remaining_bytes( | |||
| 2598 | offset_fsb = XFS_B_TO_FSBT(mp, offset); | 2434 | offset_fsb = XFS_B_TO_FSBT(mp, offset); |
| 2599 | nimap = 1; | 2435 | nimap = 1; |
| 2600 | error = xfs_bmapi(NULL, ip, offset_fsb, 1, 0, | 2436 | error = xfs_bmapi(NULL, ip, offset_fsb, 1, 0, |
| 2601 | NULL, 0, &imap, &nimap, NULL, NULL); | 2437 | NULL, 0, &imap, &nimap, NULL); |
| 2602 | if (error || nimap < 1) | 2438 | if (error || nimap < 1) |
| 2603 | break; | 2439 | break; |
| 2604 | ASSERT(imap.br_blockcount >= 1); | 2440 | ASSERT(imap.br_blockcount >= 1); |
| @@ -2661,7 +2497,6 @@ xfs_free_file_space( | |||
| 2661 | { | 2497 | { |
| 2662 | int committed; | 2498 | int committed; |
| 2663 | int done; | 2499 | int done; |
| 2664 | xfs_off_t end_dmi_offset; | ||
| 2665 | xfs_fileoff_t endoffset_fsb; | 2500 | xfs_fileoff_t endoffset_fsb; |
| 2666 | int error; | 2501 | int error; |
| 2667 | xfs_fsblock_t firstfsb; | 2502 | xfs_fsblock_t firstfsb; |
| @@ -2680,7 +2515,7 @@ xfs_free_file_space( | |||
| 2680 | 2515 | ||
| 2681 | mp = ip->i_mount; | 2516 | mp = ip->i_mount; |
| 2682 | 2517 | ||
| 2683 | xfs_itrace_entry(ip); | 2518 | trace_xfs_free_file_space(ip); |
| 2684 | 2519 | ||
| 2685 | error = xfs_qm_dqattach(ip, 0); | 2520 | error = xfs_qm_dqattach(ip, 0); |
| 2686 | if (error) | 2521 | if (error) |
| @@ -2691,19 +2526,7 @@ xfs_free_file_space( | |||
| 2691 | return error; | 2526 | return error; |
| 2692 | rt = XFS_IS_REALTIME_INODE(ip); | 2527 | rt = XFS_IS_REALTIME_INODE(ip); |
| 2693 | startoffset_fsb = XFS_B_TO_FSB(mp, offset); | 2528 | startoffset_fsb = XFS_B_TO_FSB(mp, offset); |
| 2694 | end_dmi_offset = offset + len; | 2529 | endoffset_fsb = XFS_B_TO_FSBT(mp, offset + len); |
| 2695 | endoffset_fsb = XFS_B_TO_FSBT(mp, end_dmi_offset); | ||
| 2696 | |||
| 2697 | if (offset < ip->i_size && (attr_flags & XFS_ATTR_DMI) == 0 && | ||
| 2698 | DM_EVENT_ENABLED(ip, DM_EVENT_WRITE)) { | ||
| 2699 | if (end_dmi_offset > ip->i_size) | ||
| 2700 | end_dmi_offset = ip->i_size; | ||
| 2701 | error = XFS_SEND_DATA(mp, DM_EVENT_WRITE, ip, | ||
| 2702 | offset, end_dmi_offset - offset, | ||
| 2703 | AT_DELAY_FLAG(attr_flags), NULL); | ||
| 2704 | if (error) | ||
| 2705 | return error; | ||
| 2706 | } | ||
| 2707 | 2530 | ||
| 2708 | if (attr_flags & XFS_ATTR_NOLOCK) | 2531 | if (attr_flags & XFS_ATTR_NOLOCK) |
| 2709 | need_iolock = 0; | 2532 | need_iolock = 0; |
| @@ -2731,7 +2554,7 @@ xfs_free_file_space( | |||
| 2731 | if (rt && !xfs_sb_version_hasextflgbit(&mp->m_sb)) { | 2554 | if (rt && !xfs_sb_version_hasextflgbit(&mp->m_sb)) { |
| 2732 | nimap = 1; | 2555 | nimap = 1; |
| 2733 | error = xfs_bmapi(NULL, ip, startoffset_fsb, | 2556 | error = xfs_bmapi(NULL, ip, startoffset_fsb, |
| 2734 | 1, 0, NULL, 0, &imap, &nimap, NULL, NULL); | 2557 | 1, 0, NULL, 0, &imap, &nimap, NULL); |
| 2735 | if (error) | 2558 | if (error) |
| 2736 | goto out_unlock_iolock; | 2559 | goto out_unlock_iolock; |
| 2737 | ASSERT(nimap == 0 || nimap == 1); | 2560 | ASSERT(nimap == 0 || nimap == 1); |
| @@ -2746,7 +2569,7 @@ xfs_free_file_space( | |||
| 2746 | } | 2569 | } |
| 2747 | nimap = 1; | 2570 | nimap = 1; |
| 2748 | error = xfs_bmapi(NULL, ip, endoffset_fsb - 1, | 2571 | error = xfs_bmapi(NULL, ip, endoffset_fsb - 1, |
| 2749 | 1, 0, NULL, 0, &imap, &nimap, NULL, NULL); | 2572 | 1, 0, NULL, 0, &imap, &nimap, NULL); |
| 2750 | if (error) | 2573 | if (error) |
| 2751 | goto out_unlock_iolock; | 2574 | goto out_unlock_iolock; |
| 2752 | ASSERT(nimap == 0 || nimap == 1); | 2575 | ASSERT(nimap == 0 || nimap == 1); |
| @@ -2814,8 +2637,7 @@ xfs_free_file_space( | |||
| 2814 | if (error) | 2637 | if (error) |
| 2815 | goto error1; | 2638 | goto error1; |
| 2816 | 2639 | ||
| 2817 | xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL); | 2640 | xfs_trans_ijoin(tp, ip); |
| 2818 | xfs_trans_ihold(tp, ip); | ||
| 2819 | 2641 | ||
| 2820 | /* | 2642 | /* |
| 2821 | * issue the bunmapi() call to free the blocks | 2643 | * issue the bunmapi() call to free the blocks |
| @@ -2823,7 +2645,7 @@ xfs_free_file_space( | |||
| 2823 | xfs_bmap_init(&free_list, &firstfsb); | 2645 | xfs_bmap_init(&free_list, &firstfsb); |
| 2824 | error = xfs_bunmapi(tp, ip, startoffset_fsb, | 2646 | error = xfs_bunmapi(tp, ip, startoffset_fsb, |
| 2825 | endoffset_fsb - startoffset_fsb, | 2647 | endoffset_fsb - startoffset_fsb, |
| 2826 | 0, 2, &firstfsb, &free_list, NULL, &done); | 2648 | 0, 2, &firstfsb, &free_list, &done); |
| 2827 | if (error) { | 2649 | if (error) { |
| 2828 | goto error0; | 2650 | goto error0; |
| 2829 | } | 2651 | } |
| @@ -2883,8 +2705,6 @@ xfs_change_file_space( | |||
| 2883 | xfs_trans_t *tp; | 2705 | xfs_trans_t *tp; |
| 2884 | struct iattr iattr; | 2706 | struct iattr iattr; |
| 2885 | 2707 | ||
| 2886 | xfs_itrace_entry(ip); | ||
| 2887 | |||
| 2888 | if (!S_ISREG(ip->i_d.di_mode)) | 2708 | if (!S_ISREG(ip->i_d.di_mode)) |
| 2889 | return XFS_ERROR(EINVAL); | 2709 | return XFS_ERROR(EINVAL); |
| 2890 | 2710 | ||
| @@ -2985,8 +2805,7 @@ xfs_change_file_space( | |||
| 2985 | 2805 | ||
| 2986 | xfs_ilock(ip, XFS_ILOCK_EXCL); | 2806 | xfs_ilock(ip, XFS_ILOCK_EXCL); |
| 2987 | 2807 | ||
| 2988 | xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL); | 2808 | xfs_trans_ijoin(tp, ip); |
| 2989 | xfs_trans_ihold(tp, ip); | ||
| 2990 | 2809 | ||
| 2991 | if ((attr_flags & XFS_ATTR_DMI) == 0) { | 2810 | if ((attr_flags & XFS_ATTR_DMI) == 0) { |
| 2992 | ip->i_d.di_mode &= ~S_ISUID; | 2811 | ip->i_d.di_mode &= ~S_ISUID; |
