diff options
Diffstat (limited to 'fs/xfs/xfs_vnodeops.c')
| -rw-r--r-- | fs/xfs/xfs_vnodeops.c | 172 |
1 files changed, 15 insertions, 157 deletions
diff --git a/fs/xfs/xfs_vnodeops.c b/fs/xfs/xfs_vnodeops.c index c1646838898f..f6fd7502fc0e 100644 --- a/fs/xfs/xfs_vnodeops.c +++ b/fs/xfs/xfs_vnodeops.c | |||
| @@ -26,7 +26,6 @@ | |||
| 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" |
| @@ -143,16 +142,6 @@ xfs_setattr( | |||
| 143 | goto error_return; | 142 | goto error_return; |
| 144 | } | 143 | } |
| 145 | } else { | 144 | } 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) | 145 | if (need_iolock) |
| 157 | lock_flags |= XFS_IOLOCK_EXCL; | 146 | lock_flags |= XFS_IOLOCK_EXCL; |
| 158 | } | 147 | } |
| @@ -470,17 +459,10 @@ xfs_setattr( | |||
| 470 | return XFS_ERROR(code); | 459 | return XFS_ERROR(code); |
| 471 | } | 460 | } |
| 472 | 461 | ||
| 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; | 462 | return 0; |
| 480 | 463 | ||
| 481 | abort_return: | 464 | abort_return: |
| 482 | commit_flags |= XFS_TRANS_ABORT; | 465 | commit_flags |= XFS_TRANS_ABORT; |
| 483 | /* FALLTHROUGH */ | ||
| 484 | error_return: | 466 | error_return: |
| 485 | xfs_qm_dqrele(udqp); | 467 | xfs_qm_dqrele(udqp); |
| 486 | xfs_qm_dqrele(gdqp); | 468 | xfs_qm_dqrele(gdqp); |
| @@ -1060,9 +1042,6 @@ xfs_inactive( | |||
| 1060 | 1042 | ||
| 1061 | mp = ip->i_mount; | 1043 | mp = ip->i_mount; |
| 1062 | 1044 | ||
| 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; | 1045 | error = 0; |
| 1067 | 1046 | ||
| 1068 | /* If this is a read-only mount, don't do this (would generate I/O) */ | 1047 | /* If this is a read-only mount, don't do this (would generate I/O) */ |
| @@ -1314,16 +1293,6 @@ xfs_create( | |||
| 1314 | if (XFS_FORCED_SHUTDOWN(mp)) | 1293 | if (XFS_FORCED_SHUTDOWN(mp)) |
| 1315 | return XFS_ERROR(EIO); | 1294 | return XFS_ERROR(EIO); |
| 1316 | 1295 | ||
| 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) | 1296 | if (dp->i_d.di_flags & XFS_DIFLAG_PROJINHERIT) |
| 1328 | prid = dp->i_d.di_projid; | 1297 | prid = dp->i_d.di_projid; |
| 1329 | else | 1298 | else |
| @@ -1487,16 +1456,7 @@ xfs_create( | |||
| 1487 | xfs_qm_dqrele(gdqp); | 1456 | xfs_qm_dqrele(gdqp); |
| 1488 | 1457 | ||
| 1489 | *ipp = ip; | 1458 | *ipp = ip; |
| 1490 | 1459 | 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 | 1460 | ||
| 1501 | out_bmap_cancel: | 1461 | out_bmap_cancel: |
| 1502 | xfs_bmap_cancel(&free_list); | 1462 | xfs_bmap_cancel(&free_list); |
| @@ -1510,8 +1470,8 @@ xfs_create( | |||
| 1510 | 1470 | ||
| 1511 | if (unlock_dp_on_error) | 1471 | if (unlock_dp_on_error) |
| 1512 | xfs_iunlock(dp, XFS_ILOCK_EXCL); | 1472 | xfs_iunlock(dp, XFS_ILOCK_EXCL); |
| 1513 | 1473 | std_return: | |
| 1514 | goto std_return; | 1474 | return error; |
| 1515 | 1475 | ||
| 1516 | out_abort_rele: | 1476 | out_abort_rele: |
| 1517 | /* | 1477 | /* |
| @@ -1732,14 +1692,6 @@ xfs_remove( | |||
| 1732 | if (XFS_FORCED_SHUTDOWN(mp)) | 1692 | if (XFS_FORCED_SHUTDOWN(mp)) |
| 1733 | return XFS_ERROR(EIO); | 1693 | return XFS_ERROR(EIO); |
| 1734 | 1694 | ||
| 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); | 1695 | error = xfs_qm_dqattach(dp, 0); |
| 1744 | if (error) | 1696 | if (error) |
| 1745 | goto std_return; | 1697 | goto std_return; |
| @@ -1877,21 +1829,15 @@ xfs_remove( | |||
| 1877 | if (!is_dir && link_zero && xfs_inode_is_filestream(ip)) | 1829 | if (!is_dir && link_zero && xfs_inode_is_filestream(ip)) |
| 1878 | xfs_filestream_deassociate(ip); | 1830 | xfs_filestream_deassociate(ip); |
| 1879 | 1831 | ||
| 1880 | std_return: | 1832 | 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 | 1833 | ||
| 1889 | out_bmap_cancel: | 1834 | out_bmap_cancel: |
| 1890 | xfs_bmap_cancel(&free_list); | 1835 | xfs_bmap_cancel(&free_list); |
| 1891 | cancel_flags |= XFS_TRANS_ABORT; | 1836 | cancel_flags |= XFS_TRANS_ABORT; |
| 1892 | out_trans_cancel: | 1837 | out_trans_cancel: |
| 1893 | xfs_trans_cancel(tp, cancel_flags); | 1838 | xfs_trans_cancel(tp, cancel_flags); |
| 1894 | goto std_return; | 1839 | std_return: |
| 1840 | return error; | ||
| 1895 | } | 1841 | } |
| 1896 | 1842 | ||
| 1897 | int | 1843 | int |
| @@ -1917,17 +1863,6 @@ xfs_link( | |||
| 1917 | if (XFS_FORCED_SHUTDOWN(mp)) | 1863 | if (XFS_FORCED_SHUTDOWN(mp)) |
| 1918 | return XFS_ERROR(EIO); | 1864 | return XFS_ERROR(EIO); |
| 1919 | 1865 | ||
| 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); | 1866 | error = xfs_qm_dqattach(sip, 0); |
| 1932 | if (error) | 1867 | if (error) |
| 1933 | goto std_return; | 1868 | goto std_return; |
| @@ -2014,27 +1949,14 @@ xfs_link( | |||
| 2014 | goto abort_return; | 1949 | goto abort_return; |
| 2015 | } | 1950 | } |
| 2016 | 1951 | ||
| 2017 | error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES); | 1952 | 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 | 1953 | ||
| 2031 | abort_return: | 1954 | abort_return: |
| 2032 | cancel_flags |= XFS_TRANS_ABORT; | 1955 | cancel_flags |= XFS_TRANS_ABORT; |
| 2033 | /* FALLTHROUGH */ | ||
| 2034 | |||
| 2035 | error_return: | 1956 | error_return: |
| 2036 | xfs_trans_cancel(tp, cancel_flags); | 1957 | xfs_trans_cancel(tp, cancel_flags); |
| 2037 | goto std_return; | 1958 | std_return: |
| 1959 | return error; | ||
| 2038 | } | 1960 | } |
| 2039 | 1961 | ||
| 2040 | int | 1962 | int |
| @@ -2086,17 +2008,6 @@ xfs_symlink( | |||
| 2086 | if (pathlen >= MAXPATHLEN) /* total string too long */ | 2008 | if (pathlen >= MAXPATHLEN) /* total string too long */ |
| 2087 | return XFS_ERROR(ENAMETOOLONG); | 2009 | return XFS_ERROR(ENAMETOOLONG); |
| 2088 | 2010 | ||
| 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; | 2011 | udqp = gdqp = NULL; |
| 2101 | if (dp->i_d.di_flags & XFS_DIFLAG_PROJINHERIT) | 2012 | if (dp->i_d.di_flags & XFS_DIFLAG_PROJINHERIT) |
| 2102 | prid = dp->i_d.di_projid; | 2013 | prid = dp->i_d.di_projid; |
| @@ -2278,21 +2189,8 @@ xfs_symlink( | |||
| 2278 | xfs_qm_dqrele(udqp); | 2189 | xfs_qm_dqrele(udqp); |
| 2279 | xfs_qm_dqrele(gdqp); | 2190 | xfs_qm_dqrele(gdqp); |
| 2280 | 2191 | ||
| 2281 | /* Fall through to std_return with error = 0 or errno from | 2192 | *ipp = ip; |
| 2282 | * xfs_trans_commit */ | 2193 | 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 | 2194 | ||
| 2297 | error2: | 2195 | error2: |
| 2298 | IRELE(ip); | 2196 | IRELE(ip); |
| @@ -2306,8 +2204,8 @@ std_return: | |||
| 2306 | 2204 | ||
| 2307 | if (unlock_dp_on_error) | 2205 | if (unlock_dp_on_error) |
| 2308 | xfs_iunlock(dp, XFS_ILOCK_EXCL); | 2206 | xfs_iunlock(dp, XFS_ILOCK_EXCL); |
| 2309 | 2207 | std_return: | |
| 2310 | goto std_return; | 2208 | return error; |
| 2311 | } | 2209 | } |
| 2312 | 2210 | ||
| 2313 | int | 2211 | int |
| @@ -2412,25 +2310,9 @@ xfs_alloc_file_space( | |||
| 2412 | startoffset_fsb = XFS_B_TO_FSBT(mp, offset); | 2310 | startoffset_fsb = XFS_B_TO_FSBT(mp, offset); |
| 2413 | allocatesize_fsb = XFS_B_TO_FSB(mp, count); | 2311 | allocatesize_fsb = XFS_B_TO_FSB(mp, count); |
| 2414 | 2312 | ||
| 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 | /* | 2313 | /* |
| 2431 | * Allocate file space until done or until there is an error | 2314 | * Allocate file space until done or until there is an error |
| 2432 | */ | 2315 | */ |
| 2433 | retry: | ||
| 2434 | while (allocatesize_fsb && !error) { | 2316 | while (allocatesize_fsb && !error) { |
| 2435 | xfs_fileoff_t s, e; | 2317 | xfs_fileoff_t s, e; |
| 2436 | 2318 | ||
| @@ -2527,17 +2409,6 @@ retry: | |||
| 2527 | startoffset_fsb += allocated_fsb; | 2409 | startoffset_fsb += allocated_fsb; |
| 2528 | allocatesize_fsb -= allocated_fsb; | 2410 | allocatesize_fsb -= allocated_fsb; |
| 2529 | } | 2411 | } |
| 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 | 2412 | ||
| 2542 | return error; | 2413 | return error; |
| 2543 | 2414 | ||
| @@ -2548,7 +2419,7 @@ error0: /* Cancel bmap, unlock inode, unreserve quota blocks, cancel trans */ | |||
| 2548 | error1: /* Just cancel transaction */ | 2419 | error1: /* Just cancel transaction */ |
| 2549 | xfs_trans_cancel(tp, XFS_TRANS_RELEASE_LOG_RES | XFS_TRANS_ABORT); | 2420 | xfs_trans_cancel(tp, XFS_TRANS_RELEASE_LOG_RES | XFS_TRANS_ABORT); |
| 2550 | xfs_iunlock(ip, XFS_ILOCK_EXCL); | 2421 | xfs_iunlock(ip, XFS_ILOCK_EXCL); |
| 2551 | goto dmapi_enospc_check; | 2422 | return error; |
| 2552 | } | 2423 | } |
| 2553 | 2424 | ||
| 2554 | /* | 2425 | /* |
| @@ -2661,7 +2532,6 @@ xfs_free_file_space( | |||
| 2661 | { | 2532 | { |
| 2662 | int committed; | 2533 | int committed; |
| 2663 | int done; | 2534 | int done; |
| 2664 | xfs_off_t end_dmi_offset; | ||
| 2665 | xfs_fileoff_t endoffset_fsb; | 2535 | xfs_fileoff_t endoffset_fsb; |
| 2666 | int error; | 2536 | int error; |
| 2667 | xfs_fsblock_t firstfsb; | 2537 | xfs_fsblock_t firstfsb; |
| @@ -2691,19 +2561,7 @@ xfs_free_file_space( | |||
| 2691 | return error; | 2561 | return error; |
| 2692 | rt = XFS_IS_REALTIME_INODE(ip); | 2562 | rt = XFS_IS_REALTIME_INODE(ip); |
| 2693 | startoffset_fsb = XFS_B_TO_FSB(mp, offset); | 2563 | startoffset_fsb = XFS_B_TO_FSB(mp, offset); |
| 2694 | end_dmi_offset = offset + len; | 2564 | 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 | 2565 | ||
| 2708 | if (attr_flags & XFS_ATTR_NOLOCK) | 2566 | if (attr_flags & XFS_ATTR_NOLOCK) |
| 2709 | need_iolock = 0; | 2567 | need_iolock = 0; |
