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.c99
1 files changed, 51 insertions, 48 deletions
diff --git a/fs/xfs/xfs_vnodeops.c b/fs/xfs/xfs_vnodeops.c
index 19cf90a9c762..b56321b2b9f0 100644
--- a/fs/xfs/xfs_vnodeops.c
+++ b/fs/xfs/xfs_vnodeops.c
@@ -118,7 +118,7 @@ xfs_setattr(
118 */ 118 */
119 ASSERT(udqp == NULL); 119 ASSERT(udqp == NULL);
120 ASSERT(gdqp == NULL); 120 ASSERT(gdqp == NULL);
121 code = XFS_QM_DQVOPALLOC(mp, ip, uid, gid, ip->i_d.di_projid, 121 code = xfs_qm_vop_dqalloc(ip, uid, gid, ip->i_d.di_projid,
122 qflags, &udqp, &gdqp); 122 qflags, &udqp, &gdqp);
123 if (code) 123 if (code)
124 return code; 124 return code;
@@ -180,10 +180,11 @@ xfs_setattr(
180 * Do a quota reservation only if uid/gid is actually 180 * Do a quota reservation only if uid/gid is actually
181 * going to change. 181 * going to change.
182 */ 182 */
183 if ((XFS_IS_UQUOTA_ON(mp) && iuid != uid) || 183 if (XFS_IS_QUOTA_RUNNING(mp) &&
184 (XFS_IS_GQUOTA_ON(mp) && igid != gid)) { 184 ((XFS_IS_UQUOTA_ON(mp) && iuid != uid) ||
185 (XFS_IS_GQUOTA_ON(mp) && igid != gid))) {
185 ASSERT(tp); 186 ASSERT(tp);
186 code = XFS_QM_DQVOPCHOWNRESV(mp, tp, ip, udqp, gdqp, 187 code = xfs_qm_vop_chown_reserve(tp, ip, udqp, gdqp,
187 capable(CAP_FOWNER) ? 188 capable(CAP_FOWNER) ?
188 XFS_QMOPT_FORCE_RES : 0); 189 XFS_QMOPT_FORCE_RES : 0);
189 if (code) /* out of quota */ 190 if (code) /* out of quota */
@@ -217,7 +218,7 @@ xfs_setattr(
217 /* 218 /*
218 * Make sure that the dquots are attached to the inode. 219 * Make sure that the dquots are attached to the inode.
219 */ 220 */
220 code = XFS_QM_DQATTACH(mp, ip, XFS_QMOPT_ILOCKED); 221 code = xfs_qm_dqattach_locked(ip, 0);
221 if (code) 222 if (code)
222 goto error_return; 223 goto error_return;
223 224
@@ -351,21 +352,21 @@ xfs_setattr(
351 * in the transaction. 352 * in the transaction.
352 */ 353 */
353 if (iuid != uid) { 354 if (iuid != uid) {
354 if (XFS_IS_UQUOTA_ON(mp)) { 355 if (XFS_IS_QUOTA_RUNNING(mp) && XFS_IS_UQUOTA_ON(mp)) {
355 ASSERT(mask & ATTR_UID); 356 ASSERT(mask & ATTR_UID);
356 ASSERT(udqp); 357 ASSERT(udqp);
357 olddquot1 = XFS_QM_DQVOPCHOWN(mp, tp, ip, 358 olddquot1 = xfs_qm_vop_chown(tp, ip,
358 &ip->i_udquot, udqp); 359 &ip->i_udquot, udqp);
359 } 360 }
360 ip->i_d.di_uid = uid; 361 ip->i_d.di_uid = uid;
361 inode->i_uid = uid; 362 inode->i_uid = uid;
362 } 363 }
363 if (igid != gid) { 364 if (igid != gid) {
364 if (XFS_IS_GQUOTA_ON(mp)) { 365 if (XFS_IS_QUOTA_RUNNING(mp) && XFS_IS_GQUOTA_ON(mp)) {
365 ASSERT(!XFS_IS_PQUOTA_ON(mp)); 366 ASSERT(!XFS_IS_PQUOTA_ON(mp));
366 ASSERT(mask & ATTR_GID); 367 ASSERT(mask & ATTR_GID);
367 ASSERT(gdqp); 368 ASSERT(gdqp);
368 olddquot2 = XFS_QM_DQVOPCHOWN(mp, tp, ip, 369 olddquot2 = xfs_qm_vop_chown(tp, ip,
369 &ip->i_gdquot, gdqp); 370 &ip->i_gdquot, gdqp);
370 } 371 }
371 ip->i_d.di_gid = gid; 372 ip->i_d.di_gid = gid;
@@ -461,10 +462,10 @@ xfs_setattr(
461 /* 462 /*
462 * Release any dquot(s) the inode had kept before chown. 463 * Release any dquot(s) the inode had kept before chown.
463 */ 464 */
464 XFS_QM_DQRELE(mp, olddquot1); 465 xfs_qm_dqrele(olddquot1);
465 XFS_QM_DQRELE(mp, olddquot2); 466 xfs_qm_dqrele(olddquot2);
466 XFS_QM_DQRELE(mp, udqp); 467 xfs_qm_dqrele(udqp);
467 XFS_QM_DQRELE(mp, gdqp); 468 xfs_qm_dqrele(gdqp);
468 469
469 if (code) { 470 if (code) {
470 return code; 471 return code;
@@ -482,8 +483,8 @@ xfs_setattr(
482 commit_flags |= XFS_TRANS_ABORT; 483 commit_flags |= XFS_TRANS_ABORT;
483 /* FALLTHROUGH */ 484 /* FALLTHROUGH */
484 error_return: 485 error_return:
485 XFS_QM_DQRELE(mp, udqp); 486 xfs_qm_dqrele(udqp);
486 XFS_QM_DQRELE(mp, gdqp); 487 xfs_qm_dqrele(gdqp);
487 if (tp) { 488 if (tp) {
488 xfs_trans_cancel(tp, commit_flags); 489 xfs_trans_cancel(tp, commit_flags);
489 } 490 }
@@ -739,7 +740,8 @@ xfs_free_eofblocks(
739 /* 740 /*
740 * Attach the dquots to the inode up front. 741 * Attach the dquots to the inode up front.
741 */ 742 */
742 if ((error = XFS_QM_DQATTACH(mp, ip, 0))) 743 error = xfs_qm_dqattach(ip, 0);
744 if (error)
743 return error; 745 return error;
744 746
745 /* 747 /*
@@ -1181,7 +1183,8 @@ xfs_inactive(
1181 1183
1182 ASSERT(ip->i_d.di_nlink == 0); 1184 ASSERT(ip->i_d.di_nlink == 0);
1183 1185
1184 if ((error = XFS_QM_DQATTACH(mp, ip, 0))) 1186 error = xfs_qm_dqattach(ip, 0);
1187 if (error)
1185 return VN_INACTIVE_CACHE; 1188 return VN_INACTIVE_CACHE;
1186 1189
1187 tp = xfs_trans_alloc(mp, XFS_TRANS_INACTIVE); 1190 tp = xfs_trans_alloc(mp, XFS_TRANS_INACTIVE);
@@ -1307,7 +1310,7 @@ xfs_inactive(
1307 /* 1310 /*
1308 * Credit the quota account(s). The inode is gone. 1311 * Credit the quota account(s). The inode is gone.
1309 */ 1312 */
1310 XFS_TRANS_MOD_DQUOT_BYINO(mp, tp, ip, XFS_TRANS_DQ_ICOUNT, -1); 1313 xfs_trans_mod_dquot_byino(tp, ip, XFS_TRANS_DQ_ICOUNT, -1);
1311 1314
1312 /* 1315 /*
1313 * Just ignore errors at this point. There is nothing we can 1316 * Just ignore errors at this point. There is nothing we can
@@ -1323,11 +1326,11 @@ xfs_inactive(
1323 xfs_fs_cmn_err(CE_NOTE, mp, "xfs_inactive: " 1326 xfs_fs_cmn_err(CE_NOTE, mp, "xfs_inactive: "
1324 "xfs_trans_commit() returned error %d", error); 1327 "xfs_trans_commit() returned error %d", error);
1325 } 1328 }
1329
1326 /* 1330 /*
1327 * Release the dquots held by inode, if any. 1331 * Release the dquots held by inode, if any.
1328 */ 1332 */
1329 XFS_QM_DQDETACH(mp, ip); 1333 xfs_qm_dqdetach(ip);
1330
1331 xfs_iunlock(ip, XFS_IOLOCK_EXCL | XFS_ILOCK_EXCL); 1334 xfs_iunlock(ip, XFS_IOLOCK_EXCL | XFS_ILOCK_EXCL);
1332 1335
1333 out: 1336 out:
@@ -1427,8 +1430,7 @@ xfs_create(
1427 /* 1430 /*
1428 * Make sure that we have allocated dquot(s) on disk. 1431 * Make sure that we have allocated dquot(s) on disk.
1429 */ 1432 */
1430 error = XFS_QM_DQVOPALLOC(mp, dp, 1433 error = xfs_qm_vop_dqalloc(dp, current_fsuid(), current_fsgid(), prid,
1431 current_fsuid(), current_fsgid(), prid,
1432 XFS_QMOPT_QUOTALL | XFS_QMOPT_INHERIT, &udqp, &gdqp); 1434 XFS_QMOPT_QUOTALL | XFS_QMOPT_INHERIT, &udqp, &gdqp);
1433 if (error) 1435 if (error)
1434 goto std_return; 1436 goto std_return;
@@ -1489,7 +1491,7 @@ xfs_create(
1489 /* 1491 /*
1490 * Reserve disk quota and the inode. 1492 * Reserve disk quota and the inode.
1491 */ 1493 */
1492 error = XFS_TRANS_RESERVE_QUOTA(mp, tp, udqp, gdqp, resblks, 1, 0); 1494 error = xfs_trans_reserve_quota(tp, mp, udqp, gdqp, resblks, 1, 0);
1493 if (error) 1495 if (error)
1494 goto out_trans_cancel; 1496 goto out_trans_cancel;
1495 1497
@@ -1561,7 +1563,7 @@ xfs_create(
1561 * These ids of the inode couldn't have changed since the new 1563 * These ids of the inode couldn't have changed since the new
1562 * inode has been locked ever since it was created. 1564 * inode has been locked ever since it was created.
1563 */ 1565 */
1564 XFS_QM_DQVOPCREATE(mp, tp, ip, udqp, gdqp); 1566 xfs_qm_vop_create_dqattach(tp, ip, udqp, gdqp);
1565 1567
1566 /* 1568 /*
1567 * xfs_trans_commit normally decrements the vnode ref count 1569 * xfs_trans_commit normally decrements the vnode ref count
@@ -1580,8 +1582,8 @@ xfs_create(
1580 goto out_dqrele; 1582 goto out_dqrele;
1581 } 1583 }
1582 1584
1583 XFS_QM_DQRELE(mp, udqp); 1585 xfs_qm_dqrele(udqp);
1584 XFS_QM_DQRELE(mp, gdqp); 1586 xfs_qm_dqrele(gdqp);
1585 1587
1586 *ipp = ip; 1588 *ipp = ip;
1587 1589
@@ -1602,8 +1604,8 @@ xfs_create(
1602 out_trans_cancel: 1604 out_trans_cancel:
1603 xfs_trans_cancel(tp, cancel_flags); 1605 xfs_trans_cancel(tp, cancel_flags);
1604 out_dqrele: 1606 out_dqrele:
1605 XFS_QM_DQRELE(mp, udqp); 1607 xfs_qm_dqrele(udqp);
1606 XFS_QM_DQRELE(mp, gdqp); 1608 xfs_qm_dqrele(gdqp);
1607 1609
1608 if (unlock_dp_on_error) 1610 if (unlock_dp_on_error)
1609 xfs_iunlock(dp, XFS_ILOCK_EXCL); 1611 xfs_iunlock(dp, XFS_ILOCK_EXCL);
@@ -1837,11 +1839,11 @@ xfs_remove(
1837 return error; 1839 return error;
1838 } 1840 }
1839 1841
1840 error = XFS_QM_DQATTACH(mp, dp, 0); 1842 error = xfs_qm_dqattach(dp, 0);
1841 if (error) 1843 if (error)
1842 goto std_return; 1844 goto std_return;
1843 1845
1844 error = XFS_QM_DQATTACH(mp, ip, 0); 1846 error = xfs_qm_dqattach(ip, 0);
1845 if (error) 1847 if (error)
1846 goto std_return; 1848 goto std_return;
1847 1849
@@ -2028,11 +2030,11 @@ xfs_link(
2028 2030
2029 /* Return through std_return after this point. */ 2031 /* Return through std_return after this point. */
2030 2032
2031 error = XFS_QM_DQATTACH(mp, sip, 0); 2033 error = xfs_qm_dqattach(sip, 0);
2032 if (error) 2034 if (error)
2033 goto std_return; 2035 goto std_return;
2034 2036
2035 error = XFS_QM_DQATTACH(mp, tdp, 0); 2037 error = xfs_qm_dqattach(tdp, 0);
2036 if (error) 2038 if (error)
2037 goto std_return; 2039 goto std_return;
2038 2040
@@ -2205,8 +2207,7 @@ xfs_symlink(
2205 /* 2207 /*
2206 * Make sure that we have allocated dquot(s) on disk. 2208 * Make sure that we have allocated dquot(s) on disk.
2207 */ 2209 */
2208 error = XFS_QM_DQVOPALLOC(mp, dp, 2210 error = xfs_qm_vop_dqalloc(dp, current_fsuid(), current_fsgid(), prid,
2209 current_fsuid(), current_fsgid(), prid,
2210 XFS_QMOPT_QUOTALL | XFS_QMOPT_INHERIT, &udqp, &gdqp); 2211 XFS_QMOPT_QUOTALL | XFS_QMOPT_INHERIT, &udqp, &gdqp);
2211 if (error) 2212 if (error)
2212 goto std_return; 2213 goto std_return;
@@ -2248,7 +2249,7 @@ xfs_symlink(
2248 /* 2249 /*
2249 * Reserve disk quota : blocks and inode. 2250 * Reserve disk quota : blocks and inode.
2250 */ 2251 */
2251 error = XFS_TRANS_RESERVE_QUOTA(mp, tp, udqp, gdqp, resblks, 1, 0); 2252 error = xfs_trans_reserve_quota(tp, mp, udqp, gdqp, resblks, 1, 0);
2252 if (error) 2253 if (error)
2253 goto error_return; 2254 goto error_return;
2254 2255
@@ -2288,7 +2289,7 @@ xfs_symlink(
2288 /* 2289 /*
2289 * Also attach the dquot(s) to it, if applicable. 2290 * Also attach the dquot(s) to it, if applicable.
2290 */ 2291 */
2291 XFS_QM_DQVOPCREATE(mp, tp, ip, udqp, gdqp); 2292 xfs_qm_vop_create_dqattach(tp, ip, udqp, gdqp);
2292 2293
2293 if (resblks) 2294 if (resblks)
2294 resblks -= XFS_IALLOC_SPACE_RES(mp); 2295 resblks -= XFS_IALLOC_SPACE_RES(mp);
@@ -2376,8 +2377,8 @@ xfs_symlink(
2376 goto error2; 2377 goto error2;
2377 } 2378 }
2378 error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES); 2379 error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES);
2379 XFS_QM_DQRELE(mp, udqp); 2380 xfs_qm_dqrele(udqp);
2380 XFS_QM_DQRELE(mp, gdqp); 2381 xfs_qm_dqrele(gdqp);
2381 2382
2382 /* Fall through to std_return with error = 0 or errno from 2383 /* Fall through to std_return with error = 0 or errno from
2383 * xfs_trans_commit */ 2384 * xfs_trans_commit */
@@ -2401,8 +2402,8 @@ std_return:
2401 cancel_flags |= XFS_TRANS_ABORT; 2402 cancel_flags |= XFS_TRANS_ABORT;
2402 error_return: 2403 error_return:
2403 xfs_trans_cancel(tp, cancel_flags); 2404 xfs_trans_cancel(tp, cancel_flags);
2404 XFS_QM_DQRELE(mp, udqp); 2405 xfs_qm_dqrele(udqp);
2405 XFS_QM_DQRELE(mp, gdqp); 2406 xfs_qm_dqrele(gdqp);
2406 2407
2407 if (unlock_dp_on_error) 2408 if (unlock_dp_on_error)
2408 xfs_iunlock(dp, XFS_ILOCK_EXCL); 2409 xfs_iunlock(dp, XFS_ILOCK_EXCL);
@@ -2541,7 +2542,8 @@ xfs_alloc_file_space(
2541 if (XFS_FORCED_SHUTDOWN(mp)) 2542 if (XFS_FORCED_SHUTDOWN(mp))
2542 return XFS_ERROR(EIO); 2543 return XFS_ERROR(EIO);
2543 2544
2544 if ((error = XFS_QM_DQATTACH(mp, ip, 0))) 2545 error = xfs_qm_dqattach(ip, 0);
2546 if (error)
2545 return error; 2547 return error;
2546 2548
2547 if (len <= 0) 2549 if (len <= 0)
@@ -2628,8 +2630,8 @@ retry:
2628 break; 2630 break;
2629 } 2631 }
2630 xfs_ilock(ip, XFS_ILOCK_EXCL); 2632 xfs_ilock(ip, XFS_ILOCK_EXCL);
2631 error = XFS_TRANS_RESERVE_QUOTA_NBLKS(mp, tp, ip, 2633 error = xfs_trans_reserve_quota_nblks(tp, ip, qblocks,
2632 qblocks, 0, quota_flag); 2634 0, quota_flag);
2633 if (error) 2635 if (error)
2634 goto error1; 2636 goto error1;
2635 2637
@@ -2688,7 +2690,7 @@ dmapi_enospc_check:
2688 2690
2689error0: /* Cancel bmap, unlock inode, unreserve quota blocks, cancel trans */ 2691error0: /* Cancel bmap, unlock inode, unreserve quota blocks, cancel trans */
2690 xfs_bmap_cancel(&free_list); 2692 xfs_bmap_cancel(&free_list);
2691 XFS_TRANS_UNRESERVE_QUOTA_NBLKS(mp, tp, ip, qblocks, 0, quota_flag); 2693 xfs_trans_unreserve_quota_nblks(tp, ip, qblocks, 0, quota_flag);
2692 2694
2693error1: /* Just cancel transaction */ 2695error1: /* Just cancel transaction */
2694 xfs_trans_cancel(tp, XFS_TRANS_RELEASE_LOG_RES | XFS_TRANS_ABORT); 2696 xfs_trans_cancel(tp, XFS_TRANS_RELEASE_LOG_RES | XFS_TRANS_ABORT);
@@ -2827,7 +2829,8 @@ xfs_free_file_space(
2827 2829
2828 xfs_itrace_entry(ip); 2830 xfs_itrace_entry(ip);
2829 2831
2830 if ((error = XFS_QM_DQATTACH(mp, ip, 0))) 2832 error = xfs_qm_dqattach(ip, 0);
2833 if (error)
2831 return error; 2834 return error;
2832 2835
2833 error = 0; 2836 error = 0;
@@ -2953,9 +2956,9 @@ xfs_free_file_space(
2953 break; 2956 break;
2954 } 2957 }
2955 xfs_ilock(ip, XFS_ILOCK_EXCL); 2958 xfs_ilock(ip, XFS_ILOCK_EXCL);
2956 error = XFS_TRANS_RESERVE_QUOTA(mp, tp, 2959 error = xfs_trans_reserve_quota(tp, mp,
2957 ip->i_udquot, ip->i_gdquot, resblks, 0, 2960 ip->i_udquot, ip->i_gdquot,
2958 XFS_QMOPT_RES_REGBLKS); 2961 resblks, 0, XFS_QMOPT_RES_REGBLKS);
2959 if (error) 2962 if (error)
2960 goto error1; 2963 goto error1;
2961 2964