xfs: kill xfs_qmops

Kill the quota ops function vector and replace it with direct calls or
stubs in the CONFIG_XFS_QUOTA=n case.

Make sure we check XFS_IS_QUOTA_RUNNING in the right spots. We can remove
the number of those checks because the XFS_TRANS_DQ_DIRTY flag can't be set
otherwise.

This brings us back closer to the way this code worked in IRIX and earlier
Linux versions, but we keep a lot of the more useful factoring of common
code.

Eventually we should also kill xfs_qm_bhv.c, but that's left for a later
patch.

Reduces the size of the source code by about 250 lines and the size of
XFS module by about 1.5 kilobytes with quotas enabled:

text data bss dec hex filename
615957 2960 3848 622765 980ad fs/xfs/xfs.o
617231 3152 3848 624231 98667 fs/xfs/xfs.o.old

Fallout:

- xfs_qm_dqattach is split into xfs_qm_dqattach_locked which expects
the inode locked and xfs_qm_dqattach which does the locking around it,
thus removing XFS_QMOPT_ILOCKED.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Eric Sandeen <sandeen@sandeen.net>

authored by

Christoph Hellwig and committed by
Christoph Hellwig
7d095257 0c5e1ce8

+377 -625
+1 -2
fs/xfs/Makefile
··· 88 88 xfs_utils.o \ 89 89 xfs_vnodeops.o \ 90 90 xfs_rw.o \ 91 - xfs_dmops.o \ 92 - xfs_qmops.o 91 + xfs_dmops.o 93 92 94 93 xfs-$(CONFIG_XFS_TRACE) += xfs_btree_trace.o \ 95 94 xfs_dir2_trace.o
+13 -11
fs/xfs/linux-2.6/xfs_ioctl.c
··· 908 908 struct xfs_mount *mp = ip->i_mount; 909 909 struct xfs_trans *tp; 910 910 unsigned int lock_flags = 0; 911 - struct xfs_dquot *udqp = NULL, *gdqp = NULL; 911 + struct xfs_dquot *udqp = NULL; 912 + struct xfs_dquot *gdqp = NULL; 912 913 struct xfs_dquot *olddquot = NULL; 913 914 int code; 914 915 ··· 929 928 * because the i_*dquot fields will get updated anyway. 930 929 */ 931 930 if (XFS_IS_QUOTA_ON(mp) && (mask & FSX_PROJID)) { 932 - code = XFS_QM_DQVOPALLOC(mp, ip, ip->i_d.di_uid, 931 + code = xfs_qm_vop_dqalloc(ip, ip->i_d.di_uid, 933 932 ip->i_d.di_gid, fa->fsx_projid, 934 933 XFS_QMOPT_PQUOTA, &udqp, &gdqp); 935 934 if (code) ··· 964 963 * Do a quota reservation only if projid is actually going to change. 965 964 */ 966 965 if (mask & FSX_PROJID) { 967 - if (XFS_IS_PQUOTA_ON(mp) && 966 + if (XFS_IS_QUOTA_RUNNING(mp) && 967 + XFS_IS_PQUOTA_ON(mp) && 968 968 ip->i_d.di_projid != fa->fsx_projid) { 969 969 ASSERT(tp); 970 - code = XFS_QM_DQVOPCHOWNRESV(mp, tp, ip, udqp, gdqp, 970 + code = xfs_qm_vop_chown_reserve(tp, ip, udqp, gdqp, 971 971 capable(CAP_FOWNER) ? 972 972 XFS_QMOPT_FORCE_RES : 0); 973 973 if (code) /* out of quota */ ··· 1070 1068 * in the transaction. 1071 1069 */ 1072 1070 if (ip->i_d.di_projid != fa->fsx_projid) { 1073 - if (XFS_IS_PQUOTA_ON(mp)) { 1074 - olddquot = XFS_QM_DQVOPCHOWN(mp, tp, ip, 1071 + if (XFS_IS_QUOTA_RUNNING(mp) && XFS_IS_PQUOTA_ON(mp)) { 1072 + olddquot = xfs_qm_vop_chown(tp, ip, 1075 1073 &ip->i_gdquot, gdqp); 1076 1074 } 1077 1075 ip->i_d.di_projid = fa->fsx_projid; ··· 1117 1115 /* 1118 1116 * Release any dquot(s) the inode had kept before chown. 1119 1117 */ 1120 - XFS_QM_DQRELE(mp, olddquot); 1121 - XFS_QM_DQRELE(mp, udqp); 1122 - XFS_QM_DQRELE(mp, gdqp); 1118 + xfs_qm_dqrele(olddquot); 1119 + xfs_qm_dqrele(udqp); 1120 + xfs_qm_dqrele(gdqp); 1123 1121 1124 1122 if (code) 1125 1123 return code; ··· 1133 1131 return 0; 1134 1132 1135 1133 error_return: 1136 - XFS_QM_DQRELE(mp, udqp); 1137 - XFS_QM_DQRELE(mp, gdqp); 1134 + xfs_qm_dqrele(udqp); 1135 + xfs_qm_dqrele(gdqp); 1138 1136 xfs_trans_cancel(tp, 0); 1139 1137 if (lock_flags) 1140 1138 xfs_iunlock(ip, lock_flags);
+14 -8
fs/xfs/linux-2.6/xfs_super.c
··· 405 405 return EINVAL; 406 406 } 407 407 408 + #ifndef CONFIG_XFS_QUOTA 409 + if (XFS_IS_QUOTA_RUNNING(mp)) { 410 + cmn_err(CE_WARN, 411 + "XFS: quota support not available in this kernel."); 412 + return EINVAL; 413 + } 414 + #endif 415 + 408 416 if ((mp->m_qflags & (XFS_GQUOTA_ACCT | XFS_GQUOTA_ACTIVE)) && 409 417 (mp->m_qflags & (XFS_PQUOTA_ACCT | XFS_PQUOTA_ACTIVE))) { 410 418 cmn_err(CE_WARN, ··· 1106 1098 xfs_freesb(mp); 1107 1099 xfs_icsb_destroy_counters(mp); 1108 1100 xfs_close_devices(mp); 1109 - xfs_qmops_put(mp); 1110 1101 xfs_dmops_put(mp); 1111 1102 xfs_free_fsname(mp); 1112 1103 kfree(mp); ··· 1175 1168 { 1176 1169 struct xfs_mount *mp = XFS_M(dentry->d_sb); 1177 1170 xfs_sb_t *sbp = &mp->m_sb; 1171 + struct xfs_inode *ip = XFS_I(dentry->d_inode); 1178 1172 __uint64_t fakeinos, id; 1179 1173 xfs_extlen_t lsize; 1180 1174 ··· 1204 1196 statp->f_ffree = statp->f_files - (sbp->sb_icount - sbp->sb_ifree); 1205 1197 spin_unlock(&mp->m_sb_lock); 1206 1198 1207 - XFS_QM_DQSTATVFS(XFS_I(dentry->d_inode), statp); 1199 + if ((ip->i_d.di_flags & XFS_DIFLAG_PROJINHERIT) || 1200 + ((mp->m_qflags & (XFS_PQUOTA_ACCT|XFS_OQUOTA_ENFD))) == 1201 + (XFS_PQUOTA_ACCT|XFS_OQUOTA_ENFD)) 1202 + xfs_qm_statvfs(ip, statp); 1208 1203 return 0; 1209 1204 } 1210 1205 ··· 1415 1404 error = xfs_dmops_get(mp); 1416 1405 if (error) 1417 1406 goto out_free_fsname; 1418 - error = xfs_qmops_get(mp); 1419 - if (error) 1420 - goto out_put_dmops; 1421 1407 1422 1408 if (silent) 1423 1409 flags |= XFS_MFSI_QUIET; 1424 1410 1425 1411 error = xfs_open_devices(mp); 1426 1412 if (error) 1427 - goto out_put_qmops; 1413 + goto out_put_dmops; 1428 1414 1429 1415 if (xfs_icsb_init_counters(mp)) 1430 1416 mp->m_flags |= XFS_MOUNT_NO_PERCPU_SB; ··· 1490 1482 out_destroy_counters: 1491 1483 xfs_icsb_destroy_counters(mp); 1492 1484 xfs_close_devices(mp); 1493 - out_put_qmops: 1494 - xfs_qmops_put(mp); 1495 1485 out_put_dmops: 1496 1486 xfs_dmops_put(mp); 1497 1487 out_free_fsname:
+4 -3
fs/xfs/linux-2.6/xfs_sync.c
··· 43 43 #include "xfs_buf_item.h" 44 44 #include "xfs_inode_item.h" 45 45 #include "xfs_rw.h" 46 + #include "xfs_quota.h" 46 47 47 48 #include <linux/kthread.h> 48 49 #include <linux/freezer.h> ··· 318 317 319 318 /* push non-blocking */ 320 319 xfs_sync_inodes(mp, SYNC_DELWRI|SYNC_BDFLUSH); 321 - XFS_QM_DQSYNC(mp, SYNC_BDFLUSH); 320 + xfs_qm_sync(mp, SYNC_BDFLUSH); 322 321 xfs_filestream_flush(mp); 323 322 324 323 /* push and block */ 325 324 xfs_sync_inodes(mp, SYNC_DELWRI|SYNC_WAIT|SYNC_IOWAIT); 326 - XFS_QM_DQSYNC(mp, SYNC_WAIT); 325 + xfs_qm_sync(mp, SYNC_WAIT); 327 326 328 327 /* write superblock and hoover up shutdown errors */ 329 328 error = xfs_sync_fsdata(mp, 0); ··· 468 467 xfs_log_force(mp, (xfs_lsn_t)0, XFS_LOG_FORCE); 469 468 xfs_reclaim_inodes(mp, 0, XFS_IFLUSH_DELWRI_ELSE_ASYNC); 470 469 /* dgc: errors ignored here */ 471 - error = XFS_QM_DQSYNC(mp, SYNC_BDFLUSH); 470 + error = xfs_qm_sync(mp, SYNC_BDFLUSH); 472 471 error = xfs_sync_fsdata(mp, SYNC_BDFLUSH); 473 472 if (xfs_log_need_covered(mp)) 474 473 error = xfs_commit_dummy_trans(mp, XFS_LOG_FORCE);
+3 -1
fs/xfs/quota/xfs_dquot.c
··· 1194 1194 xfs_qm_dqrele( 1195 1195 xfs_dquot_t *dqp) 1196 1196 { 1197 - ASSERT(dqp); 1197 + if (!dqp) 1198 + return; 1199 + 1198 1200 xfs_dqtrace_entry(dqp, "DQRELE"); 1199 1201 1200 1202 xfs_dqlock(dqp);
-1
fs/xfs/quota/xfs_dquot.h
··· 181 181 extern int xfs_qm_dqget(xfs_mount_t *, xfs_inode_t *, 182 182 xfs_dqid_t, uint, uint, xfs_dquot_t **); 183 183 extern void xfs_qm_dqput(xfs_dquot_t *); 184 - extern void xfs_qm_dqrele(xfs_dquot_t *); 185 184 extern void xfs_dqlock(xfs_dquot_t *); 186 185 extern void xfs_dqlock2(xfs_dquot_t *, xfs_dquot_t *); 187 186 extern void xfs_dqunlock(xfs_dquot_t *);
+73 -66
fs/xfs/quota/xfs_qm.c
··· 287 287 * Just destroy the quotainfo structure. 288 288 */ 289 289 void 290 - xfs_qm_unmount_quotadestroy( 291 - xfs_mount_t *mp) 290 + xfs_qm_unmount( 291 + struct xfs_mount *mp) 292 292 { 293 - if (mp->m_quotainfo) 293 + if (mp->m_quotainfo) { 294 + xfs_qm_dqpurge_all(mp, XFS_QMOPT_QUOTALL | XFS_QMOPT_UMOUNTING); 294 295 xfs_qm_destroy_quotainfo(mp); 296 + } 295 297 } 296 298 297 299 ··· 387 385 if (error) { 388 386 xfs_fs_cmn_err(CE_WARN, mp, 389 387 "Failed to initialize disk quotas."); 388 + return; 390 389 } 391 - return; 390 + 391 + #ifdef QUOTADEBUG 392 + if (XFS_IS_QUOTA_ON(mp)) 393 + xfs_qm_internalqcheck(mp); 394 + #endif 392 395 } 393 396 394 397 /* ··· 781 774 * Given a locked inode, attach dquot(s) to it, taking U/G/P-QUOTAON 782 775 * into account. 783 776 * If XFS_QMOPT_DQALLOC, the dquot(s) will be allocated if needed. 784 - * If XFS_QMOPT_ILOCKED, then inode sent is already locked EXCL. 785 777 * Inode may get unlocked and relocked in here, and the caller must deal with 786 778 * the consequences. 787 779 */ 788 780 int 789 - xfs_qm_dqattach( 781 + xfs_qm_dqattach_locked( 790 782 xfs_inode_t *ip, 791 783 uint flags) 792 784 { ··· 793 787 uint nquotas = 0; 794 788 int error = 0; 795 789 796 - if ((! XFS_IS_QUOTA_ON(mp)) || 797 - (! XFS_NOT_DQATTACHED(mp, ip)) || 798 - (ip->i_ino == mp->m_sb.sb_uquotino) || 799 - (ip->i_ino == mp->m_sb.sb_gquotino)) 790 + if (!XFS_IS_QUOTA_RUNNING(mp) || 791 + !XFS_IS_QUOTA_ON(mp) || 792 + !XFS_NOT_DQATTACHED(mp, ip) || 793 + ip->i_ino == mp->m_sb.sb_uquotino || 794 + ip->i_ino == mp->m_sb.sb_gquotino) 800 795 return 0; 801 796 802 - ASSERT((flags & XFS_QMOPT_ILOCKED) == 0 || 803 - xfs_isilocked(ip, XFS_ILOCK_EXCL)); 804 - 805 - if (! (flags & XFS_QMOPT_ILOCKED)) 806 - xfs_ilock(ip, XFS_ILOCK_EXCL); 797 + ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); 807 798 808 799 if (XFS_IS_UQUOTA_ON(mp)) { 809 800 error = xfs_qm_dqattach_one(ip, ip->i_d.di_uid, XFS_DQ_USER, ··· 852 849 xfs_qm_dqattach_grouphint(ip->i_udquot, ip->i_gdquot); 853 850 } 854 851 855 - done: 856 - 852 + done: 857 853 #ifdef QUOTADEBUG 858 854 if (! error) { 859 855 if (XFS_IS_UQUOTA_ON(mp)) ··· 860 858 if (XFS_IS_OQUOTA_ON(mp)) 861 859 ASSERT(ip->i_gdquot); 862 860 } 861 + ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); 863 862 #endif 863 + return error; 864 + } 864 865 865 - if (! (flags & XFS_QMOPT_ILOCKED)) 866 - xfs_iunlock(ip, XFS_ILOCK_EXCL); 866 + int 867 + xfs_qm_dqattach( 868 + struct xfs_inode *ip, 869 + uint flags) 870 + { 871 + int error; 867 872 868 - #ifdef QUOTADEBUG 869 - else 870 - ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); 871 - #endif 873 + xfs_ilock(ip, XFS_ILOCK_EXCL); 874 + error = xfs_qm_dqattach_locked(ip, flags); 875 + xfs_iunlock(ip, XFS_ILOCK_EXCL); 876 + 872 877 return error; 873 878 } 874 879 ··· 921 912 boolean_t nowait; 922 913 int error; 923 914 924 - if (! XFS_IS_QUOTA_ON(mp)) 915 + if (!XFS_IS_QUOTA_RUNNING(mp) || !XFS_IS_QUOTA_ON(mp)) 925 916 return 0; 926 917 927 918 restarts = 0; ··· 2328 2319 */ 2329 2320 int 2330 2321 xfs_qm_vop_dqalloc( 2331 - xfs_mount_t *mp, 2332 - xfs_inode_t *ip, 2333 - uid_t uid, 2334 - gid_t gid, 2335 - prid_t prid, 2336 - uint flags, 2337 - xfs_dquot_t **O_udqpp, 2338 - xfs_dquot_t **O_gdqpp) 2322 + struct xfs_inode *ip, 2323 + uid_t uid, 2324 + gid_t gid, 2325 + prid_t prid, 2326 + uint flags, 2327 + struct xfs_dquot **O_udqpp, 2328 + struct xfs_dquot **O_gdqpp) 2339 2329 { 2340 - int error; 2341 - xfs_dquot_t *uq, *gq; 2342 - uint lockflags; 2330 + struct xfs_mount *mp = ip->i_mount; 2331 + struct xfs_dquot *uq, *gq; 2332 + int error; 2333 + uint lockflags; 2343 2334 2344 - if (!XFS_IS_QUOTA_ON(mp)) 2335 + if (!XFS_IS_QUOTA_RUNNING(mp) || !XFS_IS_QUOTA_ON(mp)) 2345 2336 return 0; 2346 2337 2347 2338 lockflags = XFS_ILOCK_EXCL; ··· 2355 2346 * if necessary. The dquot(s) will not be locked. 2356 2347 */ 2357 2348 if (XFS_NOT_DQATTACHED(mp, ip)) { 2358 - if ((error = xfs_qm_dqattach(ip, XFS_QMOPT_DQALLOC | 2359 - XFS_QMOPT_ILOCKED))) { 2349 + error = xfs_qm_dqattach_locked(ip, XFS_QMOPT_DQALLOC); 2350 + if (error) { 2360 2351 xfs_iunlock(ip, lockflags); 2361 2352 return error; 2362 2353 } ··· 2478 2469 uint bfield = XFS_IS_REALTIME_INODE(ip) ? 2479 2470 XFS_TRANS_DQ_RTBCOUNT : XFS_TRANS_DQ_BCOUNT; 2480 2471 2472 + 2481 2473 ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); 2482 2474 ASSERT(XFS_IS_QUOTA_RUNNING(ip->i_mount)); 2483 2475 ··· 2518 2508 xfs_dquot_t *gdqp, 2519 2509 uint flags) 2520 2510 { 2521 - int error; 2522 - xfs_mount_t *mp; 2511 + xfs_mount_t *mp = ip->i_mount; 2523 2512 uint delblks, blkflags, prjflags = 0; 2524 2513 xfs_dquot_t *unresudq, *unresgdq, *delblksudq, *delblksgdq; 2514 + int error; 2515 + 2525 2516 2526 2517 ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL|XFS_ILOCK_SHARED)); 2527 - mp = ip->i_mount; 2528 2518 ASSERT(XFS_IS_QUOTA_RUNNING(mp)); 2529 2519 2530 2520 delblks = ip->i_delayed_blks; ··· 2592 2582 2593 2583 int 2594 2584 xfs_qm_vop_rename_dqattach( 2595 - xfs_inode_t **i_tab) 2585 + struct xfs_inode **i_tab) 2596 2586 { 2597 - xfs_inode_t *ip; 2598 - int i; 2599 - int error; 2587 + struct xfs_mount *mp = i_tab[0]->i_mount; 2588 + int i; 2600 2589 2601 - ip = i_tab[0]; 2602 - 2603 - if (! XFS_IS_QUOTA_ON(ip->i_mount)) 2590 + if (!XFS_IS_QUOTA_RUNNING(mp) || !XFS_IS_QUOTA_ON(mp)) 2604 2591 return 0; 2605 2592 2606 - if (XFS_NOT_DQATTACHED(ip->i_mount, ip)) { 2607 - error = xfs_qm_dqattach(ip, 0); 2608 - if (error) 2609 - return error; 2610 - } 2611 - for (i = 1; (i < 4 && i_tab[i]); i++) { 2593 + for (i = 0; (i < 4 && i_tab[i]); i++) { 2594 + struct xfs_inode *ip = i_tab[i]; 2595 + int error; 2596 + 2612 2597 /* 2613 2598 * Watch out for duplicate entries in the table. 2614 2599 */ 2615 - if ((ip = i_tab[i]) != i_tab[i-1]) { 2616 - if (XFS_NOT_DQATTACHED(ip->i_mount, ip)) { 2600 + if (i == 0 || ip != i_tab[i-1]) { 2601 + if (XFS_NOT_DQATTACHED(mp, ip)) { 2617 2602 error = xfs_qm_dqattach(ip, 0); 2618 2603 if (error) 2619 2604 return error; ··· 2619 2614 } 2620 2615 2621 2616 void 2622 - xfs_qm_vop_dqattach_and_dqmod_newinode( 2623 - xfs_trans_t *tp, 2624 - xfs_inode_t *ip, 2625 - xfs_dquot_t *udqp, 2626 - xfs_dquot_t *gdqp) 2617 + xfs_qm_vop_create_dqattach( 2618 + struct xfs_trans *tp, 2619 + struct xfs_inode *ip, 2620 + struct xfs_dquot *udqp, 2621 + struct xfs_dquot *gdqp) 2627 2622 { 2628 - if (!XFS_IS_QUOTA_ON(tp->t_mountp)) 2623 + struct xfs_mount *mp = tp->t_mountp; 2624 + 2625 + if (!XFS_IS_QUOTA_RUNNING(mp) || !XFS_IS_QUOTA_ON(mp)) 2629 2626 return; 2630 2627 2631 2628 ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); 2632 - ASSERT(XFS_IS_QUOTA_RUNNING(tp->t_mountp)); 2629 + ASSERT(XFS_IS_QUOTA_RUNNING(mp)); 2633 2630 2634 2631 if (udqp) { 2635 2632 xfs_dqlock(udqp); ··· 2639 2632 xfs_dqunlock(udqp); 2640 2633 ASSERT(ip->i_udquot == NULL); 2641 2634 ip->i_udquot = udqp; 2642 - ASSERT(XFS_IS_UQUOTA_ON(tp->t_mountp)); 2635 + ASSERT(XFS_IS_UQUOTA_ON(mp)); 2643 2636 ASSERT(ip->i_d.di_uid == be32_to_cpu(udqp->q_core.d_id)); 2644 2637 xfs_trans_mod_dquot(tp, udqp, XFS_TRANS_DQ_ICOUNT, 1); 2645 2638 } ··· 2649 2642 xfs_dqunlock(gdqp); 2650 2643 ASSERT(ip->i_gdquot == NULL); 2651 2644 ip->i_gdquot = gdqp; 2652 - ASSERT(XFS_IS_OQUOTA_ON(tp->t_mountp)); 2653 - ASSERT((XFS_IS_GQUOTA_ON(tp->t_mountp) ? 2645 + ASSERT(XFS_IS_OQUOTA_ON(mp)); 2646 + ASSERT((XFS_IS_GQUOTA_ON(mp) ? 2654 2647 ip->i_d.di_gid : ip->i_d.di_projid) == 2655 2648 be32_to_cpu(gdqp->q_core.d_id)); 2656 2649 xfs_trans_mod_dquot(tp, gdqp, XFS_TRANS_DQ_ICOUNT, 1);
-21
fs/xfs/quota/xfs_qm.h
··· 127 127 } xfs_quotainfo_t; 128 128 129 129 130 - extern xfs_dqtrxops_t xfs_trans_dquot_ops; 131 - 132 130 extern void xfs_trans_mod_dquot(xfs_trans_t *, xfs_dquot_t *, uint, long); 133 131 extern int xfs_trans_reserve_quota_bydquots(xfs_trans_t *, xfs_mount_t *, 134 132 xfs_dquot_t *, xfs_dquot_t *, long, long, uint); ··· 157 159 #define XFS_QM_RTBWARNLIMIT 5 158 160 159 161 extern void xfs_qm_destroy_quotainfo(xfs_mount_t *); 160 - extern void xfs_qm_mount_quotas(xfs_mount_t *); 161 162 extern int xfs_qm_quotacheck(xfs_mount_t *); 162 - extern void xfs_qm_unmount_quotadestroy(xfs_mount_t *); 163 - extern void xfs_qm_unmount_quotas(xfs_mount_t *); 164 163 extern int xfs_qm_write_sb_changes(xfs_mount_t *, __int64_t); 165 - extern int xfs_qm_sync(xfs_mount_t *, int); 166 164 167 165 /* dquot stuff */ 168 166 extern boolean_t xfs_qm_dqalloc_incore(xfs_dquot_t **); 169 - extern int xfs_qm_dqattach(xfs_inode_t *, uint); 170 - extern void xfs_qm_dqdetach(xfs_inode_t *); 171 167 extern int xfs_qm_dqpurge_all(xfs_mount_t *, uint); 172 168 extern void xfs_qm_dqrele_all_inodes(xfs_mount_t *, uint); 173 169 ··· 174 182 extern int xfs_qm_scall_getqstat(xfs_mount_t *, fs_quota_stat_t *); 175 183 extern int xfs_qm_scall_quotaon(xfs_mount_t *, uint); 176 184 extern int xfs_qm_scall_quotaoff(xfs_mount_t *, uint); 177 - 178 - /* vop stuff */ 179 - extern int xfs_qm_vop_dqalloc(xfs_mount_t *, xfs_inode_t *, 180 - uid_t, gid_t, prid_t, uint, 181 - xfs_dquot_t **, xfs_dquot_t **); 182 - extern void xfs_qm_vop_dqattach_and_dqmod_newinode( 183 - xfs_trans_t *, xfs_inode_t *, 184 - xfs_dquot_t *, xfs_dquot_t *); 185 - extern int xfs_qm_vop_rename_dqattach(xfs_inode_t **); 186 - extern xfs_dquot_t * xfs_qm_vop_chown(xfs_trans_t *, xfs_inode_t *, 187 - xfs_dquot_t **, xfs_dquot_t *); 188 - extern int xfs_qm_vop_chown_reserve(xfs_trans_t *, xfs_inode_t *, 189 - xfs_dquot_t *, xfs_dquot_t *, uint); 190 185 191 186 /* list stuff */ 192 187 extern void xfs_qm_freelist_append(xfs_frlist_t *, xfs_dquot_t *);
+3 -73
fs/xfs/quota/xfs_qm_bhv.c
··· 84 84 * return a statvfs of the project, not the entire filesystem. 85 85 * This makes such trees appear as if they are filesystems in themselves. 86 86 */ 87 - STATIC void 87 + void 88 88 xfs_qm_statvfs( 89 89 xfs_inode_t *ip, 90 90 struct kstatfs *statp) ··· 92 92 xfs_mount_t *mp = ip->i_mount; 93 93 xfs_dquot_t *dqp; 94 94 95 - if (!(ip->i_d.di_flags & XFS_DIFLAG_PROJINHERIT) || 96 - !((mp->m_qflags & (XFS_PQUOTA_ACCT|XFS_OQUOTA_ENFD))) == 97 - (XFS_PQUOTA_ACCT|XFS_OQUOTA_ENFD)) 98 - return; 99 - 100 95 if (!xfs_qm_dqget(mp, NULL, ip->i_d.di_projid, XFS_DQ_PROJ, 0, &dqp)) { 101 - xfs_disk_dquot_t *dp = &dqp->q_core; 102 - 103 - xfs_fill_statvfs_from_dquot(statp, dp); 96 + xfs_fill_statvfs_from_dquot(statp, &dqp->q_core); 104 97 xfs_qm_dqput(dqp); 105 98 } 106 99 } 107 100 108 - STATIC int 101 + int 109 102 xfs_qm_newmount( 110 103 xfs_mount_t *mp, 111 104 uint *needquotamount, ··· 106 113 { 107 114 uint quotaondisk; 108 115 uint uquotaondisk = 0, gquotaondisk = 0, pquotaondisk = 0; 109 - 110 - *quotaflags = 0; 111 - *needquotamount = B_FALSE; 112 116 113 117 quotaondisk = xfs_sb_version_hasquota(&mp->m_sb) && 114 118 (mp->m_sb.sb_qflags & XFS_ALL_QUOTA_ACCT); ··· 168 178 169 179 return 0; 170 180 } 171 - 172 - STATIC int 173 - xfs_qm_endmount( 174 - xfs_mount_t *mp, 175 - uint needquotamount, 176 - uint quotaflags) 177 - { 178 - if (needquotamount) { 179 - ASSERT(mp->m_qflags == 0); 180 - mp->m_qflags = quotaflags; 181 - xfs_qm_mount_quotas(mp); 182 - } 183 - 184 - #if defined(DEBUG) && defined(XFS_LOUD_RECOVERY) 185 - if (! (XFS_IS_QUOTA_ON(mp))) 186 - xfs_fs_cmn_err(CE_NOTE, mp, "Disk quotas not turned on"); 187 - else 188 - xfs_fs_cmn_err(CE_NOTE, mp, "Disk quotas turned on"); 189 - #endif 190 - 191 - #ifdef QUOTADEBUG 192 - if (XFS_IS_QUOTA_ON(mp) && xfs_qm_internalqcheck(mp)) 193 - cmn_err(CE_WARN, "XFS: mount internalqcheck failed"); 194 - #endif 195 - 196 - return 0; 197 - } 198 - 199 - STATIC void 200 - xfs_qm_dqrele_null( 201 - xfs_dquot_t *dq) 202 - { 203 - /* 204 - * Called from XFS, where we always check first for a NULL dquot. 205 - */ 206 - if (!dq) 207 - return; 208 - xfs_qm_dqrele(dq); 209 - } 210 - 211 - 212 - struct xfs_qmops xfs_qmcore_xfs = { 213 - .xfs_qminit = xfs_qm_newmount, 214 - .xfs_qmdone = xfs_qm_unmount_quotadestroy, 215 - .xfs_qmmount = xfs_qm_endmount, 216 - .xfs_qmunmount = xfs_qm_unmount_quotas, 217 - .xfs_dqrele = xfs_qm_dqrele_null, 218 - .xfs_dqattach = xfs_qm_dqattach, 219 - .xfs_dqdetach = xfs_qm_dqdetach, 220 - .xfs_dqpurgeall = xfs_qm_dqpurge_all, 221 - .xfs_dqvopalloc = xfs_qm_vop_dqalloc, 222 - .xfs_dqvopcreate = xfs_qm_vop_dqattach_and_dqmod_newinode, 223 - .xfs_dqvoprename = xfs_qm_vop_rename_dqattach, 224 - .xfs_dqvopchown = xfs_qm_vop_chown, 225 - .xfs_dqvopchownresv = xfs_qm_vop_chown_reserve, 226 - .xfs_dqstatvfs = xfs_qm_statvfs, 227 - .xfs_dqsync = xfs_qm_sync, 228 - .xfs_dqtrxops = &xfs_trans_dquot_ops, 229 - }; 230 - EXPORT_SYMBOL(xfs_qmcore_xfs); 231 181 232 182 void __init 233 183 xfs_qm_init(void)
+25 -40
fs/xfs/quota/xfs_trans_dquot.c
··· 111 111 * Carry forward whatever is left of the quota blk reservation to 112 112 * the spanky new transaction 113 113 */ 114 - STATIC void 114 + void 115 115 xfs_trans_dup_dqinfo( 116 116 xfs_trans_t *otp, 117 117 xfs_trans_t *ntp) ··· 167 167 /* 168 168 * Wrap around mod_dquot to account for both user and group quotas. 169 169 */ 170 - STATIC void 170 + void 171 171 xfs_trans_mod_dquot_byino( 172 172 xfs_trans_t *tp, 173 173 xfs_inode_t *ip, 174 174 uint field, 175 175 long delta) 176 176 { 177 - xfs_mount_t *mp; 177 + xfs_mount_t *mp = tp->t_mountp; 178 178 179 - ASSERT(tp); 180 - mp = tp->t_mountp; 181 - 182 - if (!XFS_IS_QUOTA_ON(mp) || 179 + if (!XFS_IS_QUOTA_RUNNING(mp) || 180 + !XFS_IS_QUOTA_ON(mp) || 183 181 ip->i_ino == mp->m_sb.sb_uquotino || 184 182 ip->i_ino == mp->m_sb.sb_gquotino) 185 183 return; ··· 227 229 xfs_dqtrx_t *qtrx; 228 230 229 231 ASSERT(tp); 232 + ASSERT(XFS_IS_QUOTA_RUNNING(tp->t_mountp)); 230 233 qtrx = NULL; 231 234 232 235 if (tp->t_dqinfo == NULL) ··· 345 346 * Unreserve just the reservations done by this transaction. 346 347 * dquot is still left locked at exit. 347 348 */ 348 - STATIC void 349 + void 349 350 xfs_trans_apply_dquot_deltas( 350 351 xfs_trans_t *tp) 351 352 { ··· 356 357 long totalbdelta; 357 358 long totalrtbdelta; 358 359 359 - if (! (tp->t_flags & XFS_TRANS_DQ_DIRTY)) 360 + if (!(tp->t_flags & XFS_TRANS_DQ_DIRTY)) 360 361 return; 361 362 362 363 ASSERT(tp->t_dqinfo); ··· 530 531 * we simply throw those away, since that's the expected behavior 531 532 * when a transaction is curtailed without a commit. 532 533 */ 533 - STATIC void 534 + void 534 535 xfs_trans_unreserve_and_mod_dquots( 535 536 xfs_trans_t *tp) 536 537 { ··· 767 768 { 768 769 int resvd = 0, error; 769 770 770 - if (!XFS_IS_QUOTA_ON(mp)) 771 + if (!XFS_IS_QUOTA_RUNNING(mp) || !XFS_IS_QUOTA_ON(mp)) 771 772 return 0; 772 773 773 774 if (tp && tp->t_dqinfo == NULL) ··· 810 811 * This doesn't change the actual usage, just the reservation. 811 812 * The inode sent in is locked. 812 813 */ 813 - STATIC int 814 + int 814 815 xfs_trans_reserve_quota_nblks( 815 - xfs_trans_t *tp, 816 - xfs_mount_t *mp, 817 - xfs_inode_t *ip, 818 - long nblks, 819 - long ninos, 820 - uint flags) 816 + struct xfs_trans *tp, 817 + struct xfs_inode *ip, 818 + long nblks, 819 + long ninos, 820 + uint flags) 821 821 { 822 - int error; 822 + struct xfs_mount *mp = ip->i_mount; 823 823 824 - if (!XFS_IS_QUOTA_ON(mp)) 824 + if (!XFS_IS_QUOTA_RUNNING(mp) || !XFS_IS_QUOTA_ON(mp)) 825 825 return 0; 826 826 if (XFS_IS_PQUOTA_ON(mp)) 827 827 flags |= XFS_QMOPT_ENOSPC; ··· 829 831 ASSERT(ip->i_ino != mp->m_sb.sb_gquotino); 830 832 831 833 ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); 832 - ASSERT(XFS_IS_QUOTA_RUNNING(ip->i_mount)); 833 834 ASSERT((flags & ~(XFS_QMOPT_FORCE_RES | XFS_QMOPT_ENOSPC)) == 834 835 XFS_TRANS_DQ_RES_RTBLKS || 835 836 (flags & ~(XFS_QMOPT_FORCE_RES | XFS_QMOPT_ENOSPC)) == ··· 837 840 /* 838 841 * Reserve nblks against these dquots, with trans as the mediator. 839 842 */ 840 - error = xfs_trans_reserve_quota_bydquots(tp, mp, 841 - ip->i_udquot, ip->i_gdquot, 842 - nblks, ninos, 843 - flags); 844 - return error; 843 + return xfs_trans_reserve_quota_bydquots(tp, mp, 844 + ip->i_udquot, ip->i_gdquot, 845 + nblks, ninos, flags); 845 846 } 846 847 847 848 /* ··· 890 895 xfs_trans_alloc_dqinfo( 891 896 xfs_trans_t *tp) 892 897 { 893 - (tp)->t_dqinfo = kmem_zone_zalloc(xfs_Gqm->qm_dqtrxzone, KM_SLEEP); 898 + tp->t_dqinfo = kmem_zone_zalloc(xfs_Gqm->qm_dqtrxzone, KM_SLEEP); 894 899 } 895 900 896 - STATIC void 901 + void 897 902 xfs_trans_free_dqinfo( 898 903 xfs_trans_t *tp) 899 904 { 900 905 if (!tp->t_dqinfo) 901 906 return; 902 - kmem_zone_free(xfs_Gqm->qm_dqtrxzone, (tp)->t_dqinfo); 903 - (tp)->t_dqinfo = NULL; 907 + kmem_zone_free(xfs_Gqm->qm_dqtrxzone, tp->t_dqinfo); 908 + tp->t_dqinfo = NULL; 904 909 } 905 - 906 - xfs_dqtrxops_t xfs_trans_dquot_ops = { 907 - .qo_dup_dqinfo = xfs_trans_dup_dqinfo, 908 - .qo_free_dqinfo = xfs_trans_free_dqinfo, 909 - .qo_mod_dquot_byino = xfs_trans_mod_dquot_byino, 910 - .qo_apply_dquot_deltas = xfs_trans_apply_dquot_deltas, 911 - .qo_reserve_quota_nblks = xfs_trans_reserve_quota_nblks, 912 - .qo_reserve_quota_bydquots = xfs_trans_reserve_quota_bydquots, 913 - .qo_unreserve_and_mod_dquots = xfs_trans_unreserve_and_mod_dquots, 914 - };
+7 -5
fs/xfs/xfs_attr.c
··· 249 249 /* 250 250 * Attach the dquots to the inode. 251 251 */ 252 - if ((error = XFS_QM_DQATTACH(mp, dp, 0))) 253 - return (error); 252 + error = xfs_qm_dqattach(dp, 0); 253 + if (error) 254 + return error; 254 255 255 256 /* 256 257 * If the inode doesn't have an attribute fork, add one. ··· 312 311 } 313 312 xfs_ilock(dp, XFS_ILOCK_EXCL); 314 313 315 - error = XFS_TRANS_RESERVE_QUOTA_NBLKS(mp, args.trans, dp, args.total, 0, 314 + error = xfs_trans_reserve_quota_nblks(args.trans, dp, args.total, 0, 316 315 rsvd ? XFS_QMOPT_RES_REGBLKS | XFS_QMOPT_FORCE_RES : 317 316 XFS_QMOPT_RES_REGBLKS); 318 317 if (error) { ··· 502 501 /* 503 502 * Attach the dquots to the inode. 504 503 */ 505 - if ((error = XFS_QM_DQATTACH(mp, dp, 0))) 506 - return (error); 504 + error = xfs_qm_dqattach(dp, 0); 505 + if (error) 506 + return error; 507 507 508 508 /* 509 509 * Start our first transaction of the day.
+17 -16
fs/xfs/xfs_bmap.c
··· 2691 2691 * Adjust the disk quota also. This was reserved 2692 2692 * earlier. 2693 2693 */ 2694 - XFS_TRANS_MOD_DQUOT_BYINO(mp, ap->tp, ap->ip, 2694 + xfs_trans_mod_dquot_byino(ap->tp, ap->ip, 2695 2695 ap->wasdel ? XFS_TRANS_DQ_DELRTBCOUNT : 2696 2696 XFS_TRANS_DQ_RTBCOUNT, (long) ralen); 2697 2697 } else { ··· 2995 2995 * Adjust the disk quota also. This was reserved 2996 2996 * earlier. 2997 2997 */ 2998 - XFS_TRANS_MOD_DQUOT_BYINO(mp, ap->tp, ap->ip, 2998 + xfs_trans_mod_dquot_byino(ap->tp, ap->ip, 2999 2999 ap->wasdel ? XFS_TRANS_DQ_DELBCOUNT : 3000 3000 XFS_TRANS_DQ_BCOUNT, 3001 3001 (long) args.len); ··· 3066 3066 return error; 3067 3067 xfs_bmap_add_free(cbno, 1, cur->bc_private.b.flist, mp); 3068 3068 ip->i_d.di_nblocks--; 3069 - XFS_TRANS_MOD_DQUOT_BYINO(mp, tp, ip, XFS_TRANS_DQ_BCOUNT, -1L); 3069 + xfs_trans_mod_dquot_byino(tp, ip, XFS_TRANS_DQ_BCOUNT, -1L); 3070 3070 xfs_trans_binval(tp, cbp); 3071 3071 if (cur->bc_bufs[0] == cbp) 3072 3072 cur->bc_bufs[0] = NULL; ··· 3386 3386 * Adjust quota data. 3387 3387 */ 3388 3388 if (qfield) 3389 - XFS_TRANS_MOD_DQUOT_BYINO(mp, tp, ip, qfield, (long)-nblks); 3389 + xfs_trans_mod_dquot_byino(tp, ip, qfield, (long)-nblks); 3390 3390 3391 3391 /* 3392 3392 * Account for change in delayed indirect blocks. ··· 3523 3523 *firstblock = cur->bc_private.b.firstblock = args.fsbno; 3524 3524 cur->bc_private.b.allocated++; 3525 3525 ip->i_d.di_nblocks++; 3526 - XFS_TRANS_MOD_DQUOT_BYINO(mp, tp, ip, XFS_TRANS_DQ_BCOUNT, 1L); 3526 + xfs_trans_mod_dquot_byino(tp, ip, XFS_TRANS_DQ_BCOUNT, 1L); 3527 3527 abp = xfs_btree_get_bufl(mp, tp, args.fsbno, 0); 3528 3528 /* 3529 3529 * Fill in the child block. ··· 3690 3690 XFS_BMAP_TRACE_POST_UPDATE("new", ip, 0, whichfork); 3691 3691 XFS_IFORK_NEXT_SET(ip, whichfork, 1); 3692 3692 ip->i_d.di_nblocks = 1; 3693 - XFS_TRANS_MOD_DQUOT_BYINO(args.mp, tp, ip, 3693 + xfs_trans_mod_dquot_byino(tp, ip, 3694 3694 XFS_TRANS_DQ_BCOUNT, 1L); 3695 3695 flags |= xfs_ilog_fext(whichfork); 3696 3696 } else { ··· 4048 4048 XFS_TRANS_PERM_LOG_RES, XFS_ADDAFORK_LOG_COUNT))) 4049 4049 goto error0; 4050 4050 xfs_ilock(ip, XFS_ILOCK_EXCL); 4051 - error = XFS_TRANS_RESERVE_QUOTA_NBLKS(mp, tp, ip, blks, 0, rsvd ? 4051 + error = xfs_trans_reserve_quota_nblks(tp, ip, blks, 0, rsvd ? 4052 4052 XFS_QMOPT_RES_REGBLKS | XFS_QMOPT_FORCE_RES : 4053 4053 XFS_QMOPT_RES_REGBLKS); 4054 4054 if (error) { ··· 4983 4983 * adjusted later. We return if we haven't 4984 4984 * allocated blocks already inside this loop. 4985 4985 */ 4986 - if ((error = XFS_TRANS_RESERVE_QUOTA_NBLKS( 4987 - mp, NULL, ip, (long)alen, 0, 4986 + error = xfs_trans_reserve_quota_nblks( 4987 + NULL, ip, (long)alen, 0, 4988 4988 rt ? XFS_QMOPT_RES_RTBLKS : 4989 - XFS_QMOPT_RES_REGBLKS))) { 4989 + XFS_QMOPT_RES_REGBLKS); 4990 + if (error) { 4990 4991 if (n == 0) { 4991 4992 *nmap = 0; 4992 4993 ASSERT(cur == NULL); ··· 5036 5035 if (XFS_IS_QUOTA_ON(mp)) 5037 5036 /* unreserve the blocks now */ 5038 5037 (void) 5039 - XFS_TRANS_UNRESERVE_QUOTA_NBLKS( 5040 - mp, NULL, ip, 5038 + xfs_trans_unreserve_quota_nblks( 5039 + NULL, ip, 5041 5040 (long)alen, 0, rt ? 5042 5041 XFS_QMOPT_RES_RTBLKS : 5043 5042 XFS_QMOPT_RES_REGBLKS); ··· 5692 5691 do_div(rtexts, mp->m_sb.sb_rextsize); 5693 5692 xfs_mod_incore_sb(mp, XFS_SBS_FREXTENTS, 5694 5693 (int64_t)rtexts, rsvd); 5695 - (void)XFS_TRANS_RESERVE_QUOTA_NBLKS(mp, 5696 - NULL, ip, -((long)del.br_blockcount), 0, 5694 + (void)xfs_trans_reserve_quota_nblks(NULL, 5695 + ip, -((long)del.br_blockcount), 0, 5697 5696 XFS_QMOPT_RES_RTBLKS); 5698 5697 } else { 5699 5698 xfs_mod_incore_sb(mp, XFS_SBS_FDBLOCKS, 5700 5699 (int64_t)del.br_blockcount, rsvd); 5701 - (void)XFS_TRANS_RESERVE_QUOTA_NBLKS(mp, 5702 - NULL, ip, -((long)del.br_blockcount), 0, 5700 + (void)xfs_trans_reserve_quota_nblks(NULL, 5701 + ip, -((long)del.br_blockcount), 0, 5703 5702 XFS_QMOPT_RES_REGBLKS); 5704 5703 } 5705 5704 ip->i_delayed_blks -= del.br_blockcount;
+2 -2
fs/xfs/xfs_bmap_btree.c
··· 590 590 cur->bc_private.b.allocated++; 591 591 cur->bc_private.b.ip->i_d.di_nblocks++; 592 592 xfs_trans_log_inode(args.tp, cur->bc_private.b.ip, XFS_ILOG_CORE); 593 - XFS_TRANS_MOD_DQUOT_BYINO(args.mp, args.tp, cur->bc_private.b.ip, 593 + xfs_trans_mod_dquot_byino(args.tp, cur->bc_private.b.ip, 594 594 XFS_TRANS_DQ_BCOUNT, 1L); 595 595 596 596 new->l = cpu_to_be64(args.fsbno); ··· 618 618 ip->i_d.di_nblocks--; 619 619 620 620 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); 621 - XFS_TRANS_MOD_DQUOT_BYINO(mp, tp, ip, XFS_TRANS_DQ_BCOUNT, -1L); 621 + xfs_trans_mod_dquot_byino(tp, ip, XFS_TRANS_DQ_BCOUNT, -1L); 622 622 xfs_trans_binval(tp, bp); 623 623 return 0; 624 624 }
+1 -4
fs/xfs/xfs_iget.c
··· 500 500 * ilock one but will still hold the iolock. 501 501 */ 502 502 xfs_ilock(ip, XFS_ILOCK_EXCL | XFS_IOLOCK_EXCL); 503 - /* 504 - * Release dquots (and their references) if any. 505 - */ 506 - XFS_QM_DQDETACH(ip->i_mount, ip); 503 + xfs_qm_dqdetach(ip); 507 504 xfs_iunlock(ip, XFS_ILOCK_EXCL | XFS_IOLOCK_EXCL); 508 505 509 506 switch (ip->i_d.di_mode & S_IFMT) {
+6 -6
fs/xfs/xfs_iomap.c
··· 385 385 * Make sure that the dquots are there. This doesn't hold 386 386 * the ilock across a disk read. 387 387 */ 388 - error = XFS_QM_DQATTACH(ip->i_mount, ip, XFS_QMOPT_ILOCKED); 388 + error = xfs_qm_dqattach_locked(ip, 0); 389 389 if (error) 390 390 return XFS_ERROR(error); 391 391 ··· 444 444 if (error) 445 445 goto error_out; 446 446 447 - error = XFS_TRANS_RESERVE_QUOTA_NBLKS(mp, tp, ip, 448 - qblocks, 0, quota_flag); 447 + error = xfs_trans_reserve_quota_nblks(tp, ip, qblocks, 0, quota_flag); 449 448 if (error) 450 449 goto error1; 451 450 ··· 494 495 495 496 error0: /* Cancel bmap, unlock inode, unreserve quota blocks, cancel trans */ 496 497 xfs_bmap_cancel(&free_list); 497 - XFS_TRANS_UNRESERVE_QUOTA_NBLKS(mp, tp, ip, qblocks, 0, quota_flag); 498 + xfs_trans_unreserve_quota_nblks(tp, ip, qblocks, 0, quota_flag); 498 499 499 500 error1: /* Just cancel transaction */ 500 501 xfs_trans_cancel(tp, XFS_TRANS_RELEASE_LOG_RES | XFS_TRANS_ABORT); ··· 581 582 * Make sure that the dquots are there. This doesn't hold 582 583 * the ilock across a disk read. 583 584 */ 584 - error = XFS_QM_DQATTACH(mp, ip, XFS_QMOPT_ILOCKED); 585 + error = xfs_qm_dqattach_locked(ip, 0); 585 586 if (error) 586 587 return XFS_ERROR(error); 587 588 ··· 683 684 /* 684 685 * Make sure that the dquots are there. 685 686 */ 686 - if ((error = XFS_QM_DQATTACH(mp, ip, 0))) 687 + error = xfs_qm_dqattach(ip, 0); 688 + if (error) 687 689 return XFS_ERROR(error); 688 690 689 691 offset_fsb = XFS_B_TO_FSBT(mp, offset);
+86 -17
fs/xfs/xfs_mount.c
··· 960 960 } 961 961 962 962 /* 963 + * Clear the quotaflags in memory and in the superblock. 964 + */ 965 + int 966 + xfs_mount_reset_sbqflags( 967 + struct xfs_mount *mp) 968 + { 969 + int error; 970 + struct xfs_trans *tp; 971 + 972 + mp->m_qflags = 0; 973 + 974 + /* 975 + * It is OK to look at sb_qflags here in mount path, 976 + * without m_sb_lock. 977 + */ 978 + if (mp->m_sb.sb_qflags == 0) 979 + return 0; 980 + spin_lock(&mp->m_sb_lock); 981 + mp->m_sb.sb_qflags = 0; 982 + spin_unlock(&mp->m_sb_lock); 983 + 984 + /* 985 + * If the fs is readonly, let the incore superblock run 986 + * with quotas off but don't flush the update out to disk 987 + */ 988 + if (mp->m_flags & XFS_MOUNT_RDONLY) 989 + return 0; 990 + 991 + #ifdef QUOTADEBUG 992 + xfs_fs_cmn_err(CE_NOTE, mp, "Writing superblock quota changes"); 993 + #endif 994 + 995 + tp = xfs_trans_alloc(mp, XFS_TRANS_QM_SBCHANGE); 996 + error = xfs_trans_reserve(tp, 0, mp->m_sb.sb_sectsize + 128, 0, 0, 997 + XFS_DEFAULT_LOG_COUNT); 998 + if (error) { 999 + xfs_trans_cancel(tp, 0); 1000 + xfs_fs_cmn_err(CE_ALERT, mp, 1001 + "xfs_mount_reset_sbqflags: Superblock update failed!"); 1002 + return error; 1003 + } 1004 + 1005 + xfs_mod_sb(tp, XFS_SB_QFLAGS); 1006 + return xfs_trans_commit(tp, 0); 1007 + } 1008 + 1009 + /* 963 1010 * This function does the following on an initial mount of a file system: 964 1011 * - reads the superblock from disk and init the mount struct 965 1012 * - if we're a 32-bit kernel, do a size check on the superblock ··· 1023 976 xfs_sb_t *sbp = &(mp->m_sb); 1024 977 xfs_inode_t *rip; 1025 978 __uint64_t resblks; 1026 - uint quotamount, quotaflags; 979 + uint quotamount = 0; 980 + uint quotaflags = 0; 1027 981 int error = 0; 1028 982 1029 983 xfs_mount_common(mp, sbp); ··· 1258 1210 /* 1259 1211 * Initialise the XFS quota management subsystem for this mount 1260 1212 */ 1261 - error = XFS_QM_INIT(mp, &quotamount, &quotaflags); 1262 - if (error) 1263 - goto out_rtunmount; 1213 + if (XFS_IS_QUOTA_RUNNING(mp)) { 1214 + error = xfs_qm_newmount(mp, &quotamount, &quotaflags); 1215 + if (error) 1216 + goto out_rtunmount; 1217 + } else { 1218 + ASSERT(!XFS_IS_QUOTA_ON(mp)); 1219 + 1220 + /* 1221 + * If a file system had quotas running earlier, but decided to 1222 + * mount without -o uquota/pquota/gquota options, revoke the 1223 + * quotachecked license. 1224 + */ 1225 + if (mp->m_sb.sb_qflags & XFS_ALL_QUOTA_ACCT) { 1226 + cmn_err(CE_NOTE, 1227 + "XFS: resetting qflags for filesystem %s", 1228 + mp->m_fsname); 1229 + 1230 + error = xfs_mount_reset_sbqflags(mp); 1231 + if (error) 1232 + return error; 1233 + } 1234 + } 1264 1235 1265 1236 /* 1266 1237 * Finish recovering the file system. This part needed to be ··· 1295 1228 /* 1296 1229 * Complete the quota initialisation, post-log-replay component. 1297 1230 */ 1298 - error = XFS_QM_MOUNT(mp, quotamount, quotaflags); 1299 - if (error) 1300 - goto out_rtunmount; 1231 + if (quotamount) { 1232 + ASSERT(mp->m_qflags == 0); 1233 + mp->m_qflags = quotaflags; 1234 + 1235 + xfs_qm_mount_quotas(mp); 1236 + } 1237 + 1238 + #if defined(DEBUG) && defined(XFS_LOUD_RECOVERY) 1239 + if (XFS_IS_QUOTA_ON(mp)) 1240 + xfs_fs_cmn_err(CE_NOTE, mp, "Disk quotas turned on"); 1241 + else 1242 + xfs_fs_cmn_err(CE_NOTE, mp, "Disk quotas not turned on"); 1243 + #endif 1301 1244 1302 1245 /* 1303 1246 * Now we are mounted, reserve a small amount of unused space for ··· 1356 1279 __uint64_t resblks; 1357 1280 int error; 1358 1281 1359 - /* 1360 - * Release dquot that rootinode, rbmino and rsumino might be holding, 1361 - * and release the quota inodes. 1362 - */ 1363 - XFS_QM_UNMOUNT(mp); 1364 - 1282 + xfs_qm_unmount_quotas(mp); 1365 1283 xfs_rtunmount_inodes(mp); 1366 1284 IRELE(mp->m_rootip); 1367 1285 ··· 1373 1301 xfs_log_force(mp, (xfs_lsn_t)0, XFS_LOG_FORCE | XFS_LOG_SYNC); 1374 1302 xfs_reclaim_inodes(mp, 0, XFS_IFLUSH_ASYNC); 1375 1303 1376 - XFS_QM_DQPURGEALL(mp, XFS_QMOPT_QUOTALL | XFS_QMOPT_UMOUNTING); 1377 - 1378 - if (mp->m_quotainfo) 1379 - XFS_QM_DONE(mp); 1304 + xfs_qm_unmount(mp); 1380 1305 1381 1306 /* 1382 1307 * Flush out the log synchronously so that we know for sure
+2 -82
fs/xfs/xfs_mount.h
··· 64 64 struct xfs_mru_cache; 65 65 struct xfs_nameops; 66 66 struct xfs_ail; 67 + struct xfs_quotainfo; 68 + 67 69 68 70 /* 69 71 * Prototypes and functions for the Data Migration subsystem. ··· 108 106 #define XFS_SEND_UNMOUNT(mp, ip,right,mode,rval,fl) \ 109 107 (*(mp)->m_dm_ops->xfs_send_unmount)(mp,ip,right,mode,rval,fl) 110 108 111 - 112 - /* 113 - * Prototypes and functions for the Quota Management subsystem. 114 - */ 115 - 116 - struct xfs_dquot; 117 - struct xfs_dqtrxops; 118 - struct xfs_quotainfo; 119 - 120 - typedef int (*xfs_qminit_t)(struct xfs_mount *, uint *, uint *); 121 - typedef int (*xfs_qmmount_t)(struct xfs_mount *, uint, uint); 122 - typedef void (*xfs_qmunmount_t)(struct xfs_mount *); 123 - typedef void (*xfs_qmdone_t)(struct xfs_mount *); 124 - typedef void (*xfs_dqrele_t)(struct xfs_dquot *); 125 - typedef int (*xfs_dqattach_t)(struct xfs_inode *, uint); 126 - typedef void (*xfs_dqdetach_t)(struct xfs_inode *); 127 - typedef int (*xfs_dqpurgeall_t)(struct xfs_mount *, uint); 128 - typedef int (*xfs_dqvopalloc_t)(struct xfs_mount *, 129 - struct xfs_inode *, uid_t, gid_t, prid_t, uint, 130 - struct xfs_dquot **, struct xfs_dquot **); 131 - typedef void (*xfs_dqvopcreate_t)(struct xfs_trans *, struct xfs_inode *, 132 - struct xfs_dquot *, struct xfs_dquot *); 133 - typedef int (*xfs_dqvoprename_t)(struct xfs_inode **); 134 - typedef struct xfs_dquot * (*xfs_dqvopchown_t)( 135 - struct xfs_trans *, struct xfs_inode *, 136 - struct xfs_dquot **, struct xfs_dquot *); 137 - typedef int (*xfs_dqvopchownresv_t)(struct xfs_trans *, struct xfs_inode *, 138 - struct xfs_dquot *, struct xfs_dquot *, uint); 139 - typedef void (*xfs_dqstatvfs_t)(struct xfs_inode *, struct kstatfs *); 140 - typedef int (*xfs_dqsync_t)(struct xfs_mount *, int flags); 141 - 142 - typedef struct xfs_qmops { 143 - xfs_qminit_t xfs_qminit; 144 - xfs_qmdone_t xfs_qmdone; 145 - xfs_qmmount_t xfs_qmmount; 146 - xfs_qmunmount_t xfs_qmunmount; 147 - xfs_dqrele_t xfs_dqrele; 148 - xfs_dqattach_t xfs_dqattach; 149 - xfs_dqdetach_t xfs_dqdetach; 150 - xfs_dqpurgeall_t xfs_dqpurgeall; 151 - xfs_dqvopalloc_t xfs_dqvopalloc; 152 - xfs_dqvopcreate_t xfs_dqvopcreate; 153 - xfs_dqvoprename_t xfs_dqvoprename; 154 - xfs_dqvopchown_t xfs_dqvopchown; 155 - xfs_dqvopchownresv_t xfs_dqvopchownresv; 156 - xfs_dqstatvfs_t xfs_dqstatvfs; 157 - xfs_dqsync_t xfs_dqsync; 158 - struct xfs_dqtrxops *xfs_dqtrxops; 159 - } xfs_qmops_t; 160 - 161 - #define XFS_QM_INIT(mp, mnt, fl) \ 162 - (*(mp)->m_qm_ops->xfs_qminit)(mp, mnt, fl) 163 - #define XFS_QM_MOUNT(mp, mnt, fl) \ 164 - (*(mp)->m_qm_ops->xfs_qmmount)(mp, mnt, fl) 165 - #define XFS_QM_UNMOUNT(mp) \ 166 - (*(mp)->m_qm_ops->xfs_qmunmount)(mp) 167 - #define XFS_QM_DONE(mp) \ 168 - (*(mp)->m_qm_ops->xfs_qmdone)(mp) 169 - #define XFS_QM_DQRELE(mp, dq) \ 170 - (*(mp)->m_qm_ops->xfs_dqrele)(dq) 171 - #define XFS_QM_DQATTACH(mp, ip, fl) \ 172 - (*(mp)->m_qm_ops->xfs_dqattach)(ip, fl) 173 - #define XFS_QM_DQDETACH(mp, ip) \ 174 - (*(mp)->m_qm_ops->xfs_dqdetach)(ip) 175 - #define XFS_QM_DQPURGEALL(mp, fl) \ 176 - (*(mp)->m_qm_ops->xfs_dqpurgeall)(mp, fl) 177 - #define XFS_QM_DQVOPALLOC(mp, ip, uid, gid, prid, fl, dq1, dq2) \ 178 - (*(mp)->m_qm_ops->xfs_dqvopalloc)(mp, ip, uid, gid, prid, fl, dq1, dq2) 179 - #define XFS_QM_DQVOPCREATE(mp, tp, ip, dq1, dq2) \ 180 - (*(mp)->m_qm_ops->xfs_dqvopcreate)(tp, ip, dq1, dq2) 181 - #define XFS_QM_DQVOPRENAME(mp, ip) \ 182 - (*(mp)->m_qm_ops->xfs_dqvoprename)(ip) 183 - #define XFS_QM_DQVOPCHOWN(mp, tp, ip, dqp, dq) \ 184 - (*(mp)->m_qm_ops->xfs_dqvopchown)(tp, ip, dqp, dq) 185 - #define XFS_QM_DQVOPCHOWNRESV(mp, tp, ip, dq1, dq2, fl) \ 186 - (*(mp)->m_qm_ops->xfs_dqvopchownresv)(tp, ip, dq1, dq2, fl) 187 - #define XFS_QM_DQSTATVFS(ip, statp) \ 188 - (*(ip)->i_mount->m_qm_ops->xfs_dqstatvfs)(ip, statp) 189 - #define XFS_QM_DQSYNC(mp, flags) \ 190 - (*(mp)->m_qm_ops->xfs_dqsync)(mp, flags) 191 109 192 110 #ifdef HAVE_PERCPU_SB 193 111 ··· 432 510 433 511 extern int xfs_dmops_get(struct xfs_mount *); 434 512 extern void xfs_dmops_put(struct xfs_mount *); 435 - extern int xfs_qmops_get(struct xfs_mount *); 436 - extern void xfs_qmops_put(struct xfs_mount *); 437 513 438 514 extern struct xfs_dmops xfs_dmcore_xfs; 439 515
-152
fs/xfs/xfs_qmops.c
··· 1 - /* 2 - * Copyright (c) 2000-2005 Silicon Graphics, Inc. 3 - * All Rights Reserved. 4 - * 5 - * This program is free software; you can redistribute it and/or 6 - * modify it under the terms of the GNU General Public License as 7 - * published by the Free Software Foundation. 8 - * 9 - * This program is distributed in the hope that it would be useful, 10 - * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 - * GNU General Public License for more details. 13 - * 14 - * You should have received a copy of the GNU General Public License 15 - * along with this program; if not, write the Free Software Foundation, 16 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17 - */ 18 - #include "xfs.h" 19 - #include "xfs_fs.h" 20 - #include "xfs_types.h" 21 - #include "xfs_log.h" 22 - #include "xfs_inum.h" 23 - #include "xfs_trans.h" 24 - #include "xfs_sb.h" 25 - #include "xfs_ag.h" 26 - #include "xfs_dir2.h" 27 - #include "xfs_dmapi.h" 28 - #include "xfs_mount.h" 29 - #include "xfs_quota.h" 30 - #include "xfs_error.h" 31 - 32 - 33 - STATIC struct xfs_dquot * 34 - xfs_dqvopchown_default( 35 - struct xfs_trans *tp, 36 - struct xfs_inode *ip, 37 - struct xfs_dquot **dqp, 38 - struct xfs_dquot *dq) 39 - { 40 - return NULL; 41 - } 42 - 43 - /* 44 - * Clear the quotaflags in memory and in the superblock. 45 - */ 46 - int 47 - xfs_mount_reset_sbqflags(xfs_mount_t *mp) 48 - { 49 - int error; 50 - xfs_trans_t *tp; 51 - 52 - mp->m_qflags = 0; 53 - /* 54 - * It is OK to look at sb_qflags here in mount path, 55 - * without m_sb_lock. 56 - */ 57 - if (mp->m_sb.sb_qflags == 0) 58 - return 0; 59 - spin_lock(&mp->m_sb_lock); 60 - mp->m_sb.sb_qflags = 0; 61 - spin_unlock(&mp->m_sb_lock); 62 - 63 - /* 64 - * if the fs is readonly, let the incore superblock run 65 - * with quotas off but don't flush the update out to disk 66 - */ 67 - if (mp->m_flags & XFS_MOUNT_RDONLY) 68 - return 0; 69 - #ifdef QUOTADEBUG 70 - xfs_fs_cmn_err(CE_NOTE, mp, "Writing superblock quota changes"); 71 - #endif 72 - tp = xfs_trans_alloc(mp, XFS_TRANS_QM_SBCHANGE); 73 - if ((error = xfs_trans_reserve(tp, 0, mp->m_sb.sb_sectsize + 128, 0, 0, 74 - XFS_DEFAULT_LOG_COUNT))) { 75 - xfs_trans_cancel(tp, 0); 76 - xfs_fs_cmn_err(CE_ALERT, mp, 77 - "xfs_mount_reset_sbqflags: Superblock update failed!"); 78 - return error; 79 - } 80 - xfs_mod_sb(tp, XFS_SB_QFLAGS); 81 - error = xfs_trans_commit(tp, 0); 82 - return error; 83 - } 84 - 85 - STATIC int 86 - xfs_noquota_init( 87 - xfs_mount_t *mp, 88 - uint *needquotamount, 89 - uint *quotaflags) 90 - { 91 - int error = 0; 92 - 93 - *quotaflags = 0; 94 - *needquotamount = B_FALSE; 95 - 96 - ASSERT(!XFS_IS_QUOTA_ON(mp)); 97 - 98 - /* 99 - * If a file system had quotas running earlier, but decided to 100 - * mount without -o uquota/pquota/gquota options, revoke the 101 - * quotachecked license. 102 - */ 103 - if (mp->m_sb.sb_qflags & XFS_ALL_QUOTA_ACCT) { 104 - cmn_err(CE_NOTE, 105 - "XFS resetting qflags for filesystem %s", 106 - mp->m_fsname); 107 - 108 - error = xfs_mount_reset_sbqflags(mp); 109 - } 110 - return error; 111 - } 112 - 113 - static struct xfs_qmops xfs_qmcore_stub = { 114 - .xfs_qminit = (xfs_qminit_t) xfs_noquota_init, 115 - .xfs_qmdone = (xfs_qmdone_t) fs_noerr, 116 - .xfs_qmmount = (xfs_qmmount_t) fs_noerr, 117 - .xfs_qmunmount = (xfs_qmunmount_t) fs_noerr, 118 - .xfs_dqrele = (xfs_dqrele_t) fs_noerr, 119 - .xfs_dqattach = (xfs_dqattach_t) fs_noerr, 120 - .xfs_dqdetach = (xfs_dqdetach_t) fs_noerr, 121 - .xfs_dqpurgeall = (xfs_dqpurgeall_t) fs_noerr, 122 - .xfs_dqvopalloc = (xfs_dqvopalloc_t) fs_noerr, 123 - .xfs_dqvopcreate = (xfs_dqvopcreate_t) fs_noerr, 124 - .xfs_dqvoprename = (xfs_dqvoprename_t) fs_noerr, 125 - .xfs_dqvopchown = xfs_dqvopchown_default, 126 - .xfs_dqvopchownresv = (xfs_dqvopchownresv_t) fs_noerr, 127 - .xfs_dqstatvfs = (xfs_dqstatvfs_t) fs_noval, 128 - .xfs_dqsync = (xfs_dqsync_t) fs_noerr, 129 - }; 130 - 131 - int 132 - xfs_qmops_get(struct xfs_mount *mp) 133 - { 134 - if (XFS_IS_QUOTA_RUNNING(mp)) { 135 - #ifdef CONFIG_XFS_QUOTA 136 - mp->m_qm_ops = &xfs_qmcore_xfs; 137 - #else 138 - cmn_err(CE_WARN, 139 - "XFS: qouta support not available in this kernel."); 140 - return EINVAL; 141 - #endif 142 - } else { 143 - mp->m_qm_ops = &xfs_qmcore_stub; 144 - } 145 - 146 - return 0; 147 - } 148 - 149 - void 150 - xfs_qmops_put(struct xfs_mount *mp) 151 - { 152 - }
+59 -57
fs/xfs/xfs_quota.h
··· 197 197 #define XFS_QMOPT_UMOUNTING 0x0000100 /* filesys is being unmounted */ 198 198 #define XFS_QMOPT_DOLOG 0x0000200 /* log buf changes (in quotacheck) */ 199 199 #define XFS_QMOPT_DOWARN 0x0000400 /* increase warning cnt if needed */ 200 - #define XFS_QMOPT_ILOCKED 0x0000800 /* inode is already locked (excl) */ 201 200 #define XFS_QMOPT_DQREPAIR 0x0001000 /* repair dquot if damaged */ 202 201 #define XFS_QMOPT_GQUOTA 0x0002000 /* group dquot requested */ 203 202 #define XFS_QMOPT_ENOSPC 0x0004000 /* enospc instead of edquot (prj) */ ··· 301 302 long qt_delrtb_delta; /* delayed RT blk count changes */ 302 303 } xfs_dqtrx_t; 303 304 304 - /* 305 - * Dquot transaction functions, used if quota is enabled. 306 - */ 307 - typedef void (*qo_dup_dqinfo_t)(struct xfs_trans *, struct xfs_trans *); 308 - typedef void (*qo_mod_dquot_byino_t)(struct xfs_trans *, 309 - struct xfs_inode *, uint, long); 310 - typedef void (*qo_free_dqinfo_t)(struct xfs_trans *); 311 - typedef void (*qo_apply_dquot_deltas_t)(struct xfs_trans *); 312 - typedef void (*qo_unreserve_and_mod_dquots_t)(struct xfs_trans *); 313 - typedef int (*qo_reserve_quota_nblks_t)( 314 - struct xfs_trans *, struct xfs_mount *, 315 - struct xfs_inode *, long, long, uint); 316 - typedef int (*qo_reserve_quota_bydquots_t)( 317 - struct xfs_trans *, struct xfs_mount *, 318 - struct xfs_dquot *, struct xfs_dquot *, 319 - long, long, uint); 320 - typedef struct xfs_dqtrxops { 321 - qo_dup_dqinfo_t qo_dup_dqinfo; 322 - qo_free_dqinfo_t qo_free_dqinfo; 323 - qo_mod_dquot_byino_t qo_mod_dquot_byino; 324 - qo_apply_dquot_deltas_t qo_apply_dquot_deltas; 325 - qo_reserve_quota_nblks_t qo_reserve_quota_nblks; 326 - qo_reserve_quota_bydquots_t qo_reserve_quota_bydquots; 327 - qo_unreserve_and_mod_dquots_t qo_unreserve_and_mod_dquots; 328 - } xfs_dqtrxops_t; 305 + #ifdef CONFIG_XFS_QUOTA 306 + extern void xfs_trans_dup_dqinfo(struct xfs_trans *, struct xfs_trans *); 307 + extern void xfs_trans_free_dqinfo(struct xfs_trans *); 308 + extern void xfs_trans_mod_dquot_byino(struct xfs_trans *, struct xfs_inode *, 309 + uint, long); 310 + extern void xfs_trans_apply_dquot_deltas(struct xfs_trans *); 311 + extern void xfs_trans_unreserve_and_mod_dquots(struct xfs_trans *); 312 + extern int xfs_trans_reserve_quota_nblks(struct xfs_trans *, 313 + struct xfs_inode *, long, long, uint); 314 + extern int xfs_trans_reserve_quota_bydquots(struct xfs_trans *, 315 + struct xfs_mount *, struct xfs_dquot *, 316 + struct xfs_dquot *, long, long, uint); 329 317 330 - #define XFS_DQTRXOP(mp, tp, op, args...) \ 331 - ((mp)->m_qm_ops->xfs_dqtrxops ? \ 332 - ((mp)->m_qm_ops->xfs_dqtrxops->op)(tp, ## args) : 0) 318 + extern int xfs_qm_vop_dqalloc(struct xfs_inode *, uid_t, gid_t, prid_t, uint, 319 + struct xfs_dquot **, struct xfs_dquot **); 320 + extern void xfs_qm_vop_create_dqattach(struct xfs_trans *, struct xfs_inode *, 321 + struct xfs_dquot *, struct xfs_dquot *); 322 + extern int xfs_qm_vop_rename_dqattach(struct xfs_inode **); 323 + extern struct xfs_dquot *xfs_qm_vop_chown(struct xfs_trans *, 324 + struct xfs_inode *, struct xfs_dquot **, struct xfs_dquot *); 325 + extern int xfs_qm_vop_chown_reserve(struct xfs_trans *, struct xfs_inode *, 326 + struct xfs_dquot *, struct xfs_dquot *, uint); 327 + extern int xfs_qm_dqattach(struct xfs_inode *, uint); 328 + extern int xfs_qm_dqattach_locked(struct xfs_inode *, uint); 329 + extern void xfs_qm_dqdetach(struct xfs_inode *); 330 + extern void xfs_qm_dqrele(struct xfs_dquot *); 331 + extern void xfs_qm_statvfs(struct xfs_inode *, struct kstatfs *); 332 + extern int xfs_qm_sync(struct xfs_mount *, int); 333 + extern int xfs_qm_newmount(struct xfs_mount *, uint *, uint *); 334 + extern void xfs_qm_mount_quotas(struct xfs_mount *); 335 + extern void xfs_qm_unmount(struct xfs_mount *); 336 + extern void xfs_qm_unmount_quotas(struct xfs_mount *); 333 337 334 - #define XFS_DQTRXOP_VOID(mp, tp, op, args...) \ 335 - ((mp)->m_qm_ops->xfs_dqtrxops ? \ 336 - ((mp)->m_qm_ops->xfs_dqtrxops->op)(tp, ## args) : (void)0) 338 + #else 339 + #define xfs_trans_dup_dqinfo(tp, tp2) 340 + #define xfs_trans_free_dqinfo(tp) 341 + #define xfs_trans_mod_dquot_byino(tp, ip, fields, delta) 342 + #define xfs_trans_apply_dquot_deltas(tp) 343 + #define xfs_trans_unreserve_and_mod_dquots(tp) 344 + #define xfs_trans_reserve_quota_nblks(tp, ip, nblks, ninos, flags) (0) 345 + #define xfs_trans_reserve_quota_bydquots(tp, mp, u, g, nb, ni, fl) (0) 346 + #define xfs_qm_vop_dqalloc(ip, uid, gid, prid, fl, ou, og) (0) 347 + #define xfs_qm_vop_create_dqattach(tp, ip, u, g) 348 + #define xfs_qm_vop_rename_dqattach(it) (0) 349 + #define xfs_qm_vop_chown(tp, ip, old, new) (NULL) 350 + #define xfs_qm_vop_chown_reserve(tp, ip, u, g, fl) (0) 351 + #define xfs_qm_dqattach(ip, fl) (0) 352 + #define xfs_qm_dqattach_locked(ip, fl) (0) 353 + #define xfs_qm_dqdetach(ip) 354 + #define xfs_qm_dqrele(d) 355 + #define xfs_qm_statvfs(ip, s) 356 + #define xfs_qm_sync(mp, fl) (0) 357 + #define xfs_qm_newmount(mp, a, b) (0) 358 + #define xfs_qm_mount_quotas(mp) 359 + #define xfs_qm_unmount(mp) 360 + #define xfs_qm_unmount_quotas(mp) (0) 361 + #endif /* CONFIG_XFS_QUOTA */ 337 362 338 - #define XFS_TRANS_DUP_DQINFO(mp, otp, ntp) \ 339 - XFS_DQTRXOP_VOID(mp, otp, qo_dup_dqinfo, ntp) 340 - #define XFS_TRANS_FREE_DQINFO(mp, tp) \ 341 - XFS_DQTRXOP_VOID(mp, tp, qo_free_dqinfo) 342 - #define XFS_TRANS_MOD_DQUOT_BYINO(mp, tp, ip, field, delta) \ 343 - XFS_DQTRXOP_VOID(mp, tp, qo_mod_dquot_byino, ip, field, delta) 344 - #define XFS_TRANS_APPLY_DQUOT_DELTAS(mp, tp) \ 345 - XFS_DQTRXOP_VOID(mp, tp, qo_apply_dquot_deltas) 346 - #define XFS_TRANS_RESERVE_QUOTA_NBLKS(mp, tp, ip, nblks, ninos, fl) \ 347 - XFS_DQTRXOP(mp, tp, qo_reserve_quota_nblks, mp, ip, nblks, ninos, fl) 348 - #define XFS_TRANS_RESERVE_QUOTA_BYDQUOTS(mp, tp, ud, gd, nb, ni, fl) \ 349 - XFS_DQTRXOP(mp, tp, qo_reserve_quota_bydquots, mp, ud, gd, nb, ni, fl) 350 - #define XFS_TRANS_UNRESERVE_AND_MOD_DQUOTS(mp, tp) \ 351 - XFS_DQTRXOP_VOID(mp, tp, qo_unreserve_and_mod_dquots) 352 - 353 - #define XFS_TRANS_UNRESERVE_QUOTA_NBLKS(mp, tp, ip, nblks, ninos, flags) \ 354 - XFS_TRANS_RESERVE_QUOTA_NBLKS(mp, tp, ip, -(nblks), -(ninos), flags) 355 - #define XFS_TRANS_RESERVE_QUOTA(mp, tp, ud, gd, nb, ni, f) \ 356 - XFS_TRANS_RESERVE_QUOTA_BYDQUOTS(mp, tp, ud, gd, nb, ni, \ 357 - f | XFS_QMOPT_RES_REGBLKS) 358 - #define XFS_TRANS_UNRESERVE_QUOTA(mp, tp, ud, gd, nb, ni, f) \ 359 - XFS_TRANS_RESERVE_QUOTA_BYDQUOTS(mp, tp, ud, gd, -(nb), -(ni), \ 363 + #define xfs_trans_unreserve_quota_nblks(tp, ip, nblks, ninos, flags) \ 364 + xfs_trans_reserve_quota_nblks(tp, ip, -(nblks), -(ninos), flags) 365 + #define xfs_trans_reserve_quota(tp, mp, ud, gd, nb, ni, f) \ 366 + xfs_trans_reserve_quota_bydquots(tp, mp, ud, gd, nb, ni, \ 360 367 f | XFS_QMOPT_RES_REGBLKS) 361 368 362 369 extern int xfs_qm_dqcheck(xfs_disk_dquot_t *, xfs_dqid_t, uint, uint, char *); 363 370 extern int xfs_mount_reset_sbqflags(struct xfs_mount *); 364 371 365 - extern struct xfs_qmops xfs_qmcore_xfs; 366 - 367 372 #endif /* __KERNEL__ */ 368 - 369 373 #endif /* __XFS_QUOTA_H__ */
+2 -1
fs/xfs/xfs_rename.c
··· 166 166 /* 167 167 * Attach the dquots to the inodes 168 168 */ 169 - if ((error = XFS_QM_DQVOPRENAME(mp, inodes))) { 169 + error = xfs_qm_vop_rename_dqattach(inodes); 170 + if (error) { 170 171 xfs_trans_cancel(tp, cancel_flags); 171 172 goto std_return; 172 173 }
+7 -8
fs/xfs/xfs_trans.c
··· 297 297 tp->t_rtx_res = tp->t_rtx_res_used; 298 298 ntp->t_pflags = tp->t_pflags; 299 299 300 - XFS_TRANS_DUP_DQINFO(tp->t_mountp, tp, ntp); 300 + xfs_trans_dup_dqinfo(tp, ntp); 301 301 302 302 atomic_inc(&tp->t_mountp->m_active_trans); 303 303 return ntp; ··· 831 831 * means is that we have some (non-persistent) quota 832 832 * reservations that need to be unreserved. 833 833 */ 834 - XFS_TRANS_UNRESERVE_AND_MOD_DQUOTS(mp, tp); 834 + xfs_trans_unreserve_and_mod_dquots(tp); 835 835 if (tp->t_ticket) { 836 836 commit_lsn = xfs_log_done(mp, tp->t_ticket, 837 837 NULL, log_flags); ··· 850 850 /* 851 851 * If we need to update the superblock, then do it now. 852 852 */ 853 - if (tp->t_flags & XFS_TRANS_SB_DIRTY) { 853 + if (tp->t_flags & XFS_TRANS_SB_DIRTY) 854 854 xfs_trans_apply_sb_deltas(tp); 855 - } 856 - XFS_TRANS_APPLY_DQUOT_DELTAS(mp, tp); 855 + xfs_trans_apply_dquot_deltas(tp); 857 856 858 857 /* 859 858 * Ask each log item how many log_vector entries it will ··· 1057 1058 } 1058 1059 1059 1060 xfs_trans_unreserve_and_mod_sb(tp); 1060 - XFS_TRANS_UNRESERVE_AND_MOD_DQUOTS(tp->t_mountp, tp); 1061 + xfs_trans_unreserve_and_mod_dquots(tp); 1061 1062 1062 1063 xfs_trans_free_items(tp, flags); 1063 1064 xfs_trans_free_busy(tp); ··· 1182 1183 } 1183 1184 #endif 1184 1185 xfs_trans_unreserve_and_mod_sb(tp); 1185 - XFS_TRANS_UNRESERVE_AND_MOD_DQUOTS(mp, tp); 1186 + xfs_trans_unreserve_and_mod_dquots(tp); 1186 1187 1187 1188 if (tp->t_ticket) { 1188 1189 if (flags & XFS_TRANS_RELEASE_LOG_RES) { ··· 1212 1213 xfs_trans_t *tp) 1213 1214 { 1214 1215 atomic_dec(&tp->t_mountp->m_active_trans); 1215 - XFS_TRANS_FREE_DQINFO(tp->t_mountp, tp); 1216 + xfs_trans_free_dqinfo(tp); 1216 1217 kmem_zone_free(xfs_trans_zone, tp); 1217 1218 } 1218 1219
+1 -1
fs/xfs/xfs_utils.c
··· 166 166 xfs_buf_relse(ialloc_context); 167 167 if (dqinfo) { 168 168 tp->t_dqinfo = dqinfo; 169 - XFS_TRANS_FREE_DQINFO(tp->t_mountp, tp); 169 + xfs_trans_free_dqinfo(tp); 170 170 } 171 171 *tpp = ntp; 172 172 *ipp = NULL;
+51 -48
fs/xfs/xfs_vnodeops.c
··· 118 118 */ 119 119 ASSERT(udqp == NULL); 120 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 122 qflags, &udqp, &gdqp); 123 123 if (code) 124 124 return code; ··· 180 180 * Do a quota reservation only if uid/gid is actually 181 181 * going to change. 182 182 */ 183 - if ((XFS_IS_UQUOTA_ON(mp) && iuid != uid) || 184 - (XFS_IS_GQUOTA_ON(mp) && igid != gid)) { 183 + if (XFS_IS_QUOTA_RUNNING(mp) && 184 + ((XFS_IS_UQUOTA_ON(mp) && iuid != uid) || 185 + (XFS_IS_GQUOTA_ON(mp) && igid != gid))) { 185 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 188 capable(CAP_FOWNER) ? 188 189 XFS_QMOPT_FORCE_RES : 0); 189 190 if (code) /* out of quota */ ··· 218 217 /* 219 218 * Make sure that the dquots are attached to the inode. 220 219 */ 221 - code = XFS_QM_DQATTACH(mp, ip, XFS_QMOPT_ILOCKED); 220 + code = xfs_qm_dqattach_locked(ip, 0); 222 221 if (code) 223 222 goto error_return; 224 223 ··· 352 351 * in the transaction. 353 352 */ 354 353 if (iuid != uid) { 355 - if (XFS_IS_UQUOTA_ON(mp)) { 354 + if (XFS_IS_QUOTA_RUNNING(mp) && XFS_IS_UQUOTA_ON(mp)) { 356 355 ASSERT(mask & ATTR_UID); 357 356 ASSERT(udqp); 358 - olddquot1 = XFS_QM_DQVOPCHOWN(mp, tp, ip, 357 + olddquot1 = xfs_qm_vop_chown(tp, ip, 359 358 &ip->i_udquot, udqp); 360 359 } 361 360 ip->i_d.di_uid = uid; 362 361 inode->i_uid = uid; 363 362 } 364 363 if (igid != gid) { 365 - if (XFS_IS_GQUOTA_ON(mp)) { 364 + if (XFS_IS_QUOTA_RUNNING(mp) && XFS_IS_GQUOTA_ON(mp)) { 366 365 ASSERT(!XFS_IS_PQUOTA_ON(mp)); 367 366 ASSERT(mask & ATTR_GID); 368 367 ASSERT(gdqp); 369 - olddquot2 = XFS_QM_DQVOPCHOWN(mp, tp, ip, 368 + olddquot2 = xfs_qm_vop_chown(tp, ip, 370 369 &ip->i_gdquot, gdqp); 371 370 } 372 371 ip->i_d.di_gid = gid; ··· 462 461 /* 463 462 * Release any dquot(s) the inode had kept before chown. 464 463 */ 465 - XFS_QM_DQRELE(mp, olddquot1); 466 - XFS_QM_DQRELE(mp, olddquot2); 467 - XFS_QM_DQRELE(mp, udqp); 468 - XFS_QM_DQRELE(mp, gdqp); 464 + xfs_qm_dqrele(olddquot1); 465 + xfs_qm_dqrele(olddquot2); 466 + xfs_qm_dqrele(udqp); 467 + xfs_qm_dqrele(gdqp); 469 468 470 469 if (code) { 471 470 return code; ··· 483 482 commit_flags |= XFS_TRANS_ABORT; 484 483 /* FALLTHROUGH */ 485 484 error_return: 486 - XFS_QM_DQRELE(mp, udqp); 487 - XFS_QM_DQRELE(mp, gdqp); 485 + xfs_qm_dqrele(udqp); 486 + xfs_qm_dqrele(gdqp); 488 487 if (tp) { 489 488 xfs_trans_cancel(tp, commit_flags); 490 489 } ··· 740 739 /* 741 740 * Attach the dquots to the inode up front. 742 741 */ 743 - if ((error = XFS_QM_DQATTACH(mp, ip, 0))) 742 + error = xfs_qm_dqattach(ip, 0); 743 + if (error) 744 744 return error; 745 745 746 746 /* ··· 1183 1181 1184 1182 ASSERT(ip->i_d.di_nlink == 0); 1185 1183 1186 - if ((error = XFS_QM_DQATTACH(mp, ip, 0))) 1184 + error = xfs_qm_dqattach(ip, 0); 1185 + if (error) 1187 1186 return VN_INACTIVE_CACHE; 1188 1187 1189 1188 tp = xfs_trans_alloc(mp, XFS_TRANS_INACTIVE); ··· 1310 1307 /* 1311 1308 * Credit the quota account(s). The inode is gone. 1312 1309 */ 1313 - XFS_TRANS_MOD_DQUOT_BYINO(mp, tp, ip, XFS_TRANS_DQ_ICOUNT, -1); 1310 + xfs_trans_mod_dquot_byino(tp, ip, XFS_TRANS_DQ_ICOUNT, -1); 1314 1311 1315 1312 /* 1316 1313 * Just ignore errors at this point. There is nothing we can ··· 1326 1323 xfs_fs_cmn_err(CE_NOTE, mp, "xfs_inactive: " 1327 1324 "xfs_trans_commit() returned error %d", error); 1328 1325 } 1326 + 1329 1327 /* 1330 1328 * Release the dquots held by inode, if any. 1331 1329 */ 1332 - XFS_QM_DQDETACH(mp, ip); 1333 - 1330 + xfs_qm_dqdetach(ip); 1334 1331 xfs_iunlock(ip, XFS_IOLOCK_EXCL | XFS_ILOCK_EXCL); 1335 1332 1336 1333 out: ··· 1430 1427 /* 1431 1428 * Make sure that we have allocated dquot(s) on disk. 1432 1429 */ 1433 - error = XFS_QM_DQVOPALLOC(mp, dp, 1434 - current_fsuid(), current_fsgid(), prid, 1430 + error = xfs_qm_vop_dqalloc(dp, current_fsuid(), current_fsgid(), prid, 1435 1431 XFS_QMOPT_QUOTALL | XFS_QMOPT_INHERIT, &udqp, &gdqp); 1436 1432 if (error) 1437 1433 goto std_return; ··· 1491 1489 /* 1492 1490 * Reserve disk quota and the inode. 1493 1491 */ 1494 - error = XFS_TRANS_RESERVE_QUOTA(mp, tp, udqp, gdqp, resblks, 1, 0); 1492 + error = xfs_trans_reserve_quota(tp, mp, udqp, gdqp, resblks, 1, 0); 1495 1493 if (error) 1496 1494 goto out_trans_cancel; 1497 1495 ··· 1563 1561 * These ids of the inode couldn't have changed since the new 1564 1562 * inode has been locked ever since it was created. 1565 1563 */ 1566 - XFS_QM_DQVOPCREATE(mp, tp, ip, udqp, gdqp); 1564 + xfs_qm_vop_create_dqattach(tp, ip, udqp, gdqp); 1567 1565 1568 1566 /* 1569 1567 * xfs_trans_commit normally decrements the vnode ref count ··· 1582 1580 goto out_dqrele; 1583 1581 } 1584 1582 1585 - XFS_QM_DQRELE(mp, udqp); 1586 - XFS_QM_DQRELE(mp, gdqp); 1583 + xfs_qm_dqrele(udqp); 1584 + xfs_qm_dqrele(gdqp); 1587 1585 1588 1586 *ipp = ip; 1589 1587 ··· 1604 1602 out_trans_cancel: 1605 1603 xfs_trans_cancel(tp, cancel_flags); 1606 1604 out_dqrele: 1607 - XFS_QM_DQRELE(mp, udqp); 1608 - XFS_QM_DQRELE(mp, gdqp); 1605 + xfs_qm_dqrele(udqp); 1606 + xfs_qm_dqrele(gdqp); 1609 1607 1610 1608 if (unlock_dp_on_error) 1611 1609 xfs_iunlock(dp, XFS_ILOCK_EXCL); ··· 1839 1837 return error; 1840 1838 } 1841 1839 1842 - error = XFS_QM_DQATTACH(mp, dp, 0); 1840 + error = xfs_qm_dqattach(dp, 0); 1843 1841 if (error) 1844 1842 goto std_return; 1845 1843 1846 - error = XFS_QM_DQATTACH(mp, ip, 0); 1844 + error = xfs_qm_dqattach(ip, 0); 1847 1845 if (error) 1848 1846 goto std_return; 1849 1847 ··· 2030 2028 2031 2029 /* Return through std_return after this point. */ 2032 2030 2033 - error = XFS_QM_DQATTACH(mp, sip, 0); 2031 + error = xfs_qm_dqattach(sip, 0); 2034 2032 if (error) 2035 2033 goto std_return; 2036 2034 2037 - error = XFS_QM_DQATTACH(mp, tdp, 0); 2035 + error = xfs_qm_dqattach(tdp, 0); 2038 2036 if (error) 2039 2037 goto std_return; 2040 2038 ··· 2207 2205 /* 2208 2206 * Make sure that we have allocated dquot(s) on disk. 2209 2207 */ 2210 - error = XFS_QM_DQVOPALLOC(mp, dp, 2211 - current_fsuid(), current_fsgid(), prid, 2208 + error = xfs_qm_vop_dqalloc(dp, current_fsuid(), current_fsgid(), prid, 2212 2209 XFS_QMOPT_QUOTALL | XFS_QMOPT_INHERIT, &udqp, &gdqp); 2213 2210 if (error) 2214 2211 goto std_return; ··· 2249 2248 /* 2250 2249 * Reserve disk quota : blocks and inode. 2251 2250 */ 2252 - error = XFS_TRANS_RESERVE_QUOTA(mp, tp, udqp, gdqp, resblks, 1, 0); 2251 + error = xfs_trans_reserve_quota(tp, mp, udqp, gdqp, resblks, 1, 0); 2253 2252 if (error) 2254 2253 goto error_return; 2255 2254 ··· 2289 2288 /* 2290 2289 * Also attach the dquot(s) to it, if applicable. 2291 2290 */ 2292 - XFS_QM_DQVOPCREATE(mp, tp, ip, udqp, gdqp); 2291 + xfs_qm_vop_create_dqattach(tp, ip, udqp, gdqp); 2293 2292 2294 2293 if (resblks) 2295 2294 resblks -= XFS_IALLOC_SPACE_RES(mp); ··· 2377 2376 goto error2; 2378 2377 } 2379 2378 error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES); 2380 - XFS_QM_DQRELE(mp, udqp); 2381 - XFS_QM_DQRELE(mp, gdqp); 2379 + xfs_qm_dqrele(udqp); 2380 + xfs_qm_dqrele(gdqp); 2382 2381 2383 2382 /* Fall through to std_return with error = 0 or errno from 2384 2383 * xfs_trans_commit */ ··· 2402 2401 cancel_flags |= XFS_TRANS_ABORT; 2403 2402 error_return: 2404 2403 xfs_trans_cancel(tp, cancel_flags); 2405 - XFS_QM_DQRELE(mp, udqp); 2406 - XFS_QM_DQRELE(mp, gdqp); 2404 + xfs_qm_dqrele(udqp); 2405 + xfs_qm_dqrele(gdqp); 2407 2406 2408 2407 if (unlock_dp_on_error) 2409 2408 xfs_iunlock(dp, XFS_ILOCK_EXCL); ··· 2542 2541 if (XFS_FORCED_SHUTDOWN(mp)) 2543 2542 return XFS_ERROR(EIO); 2544 2543 2545 - if ((error = XFS_QM_DQATTACH(mp, ip, 0))) 2544 + error = xfs_qm_dqattach(ip, 0); 2545 + if (error) 2546 2546 return error; 2547 2547 2548 2548 if (len <= 0) ··· 2630 2628 break; 2631 2629 } 2632 2630 xfs_ilock(ip, XFS_ILOCK_EXCL); 2633 - error = XFS_TRANS_RESERVE_QUOTA_NBLKS(mp, tp, ip, 2634 - qblocks, 0, quota_flag); 2631 + error = xfs_trans_reserve_quota_nblks(tp, ip, qblocks, 2632 + 0, quota_flag); 2635 2633 if (error) 2636 2634 goto error1; 2637 2635 ··· 2690 2688 2691 2689 error0: /* Cancel bmap, unlock inode, unreserve quota blocks, cancel trans */ 2692 2690 xfs_bmap_cancel(&free_list); 2693 - XFS_TRANS_UNRESERVE_QUOTA_NBLKS(mp, tp, ip, qblocks, 0, quota_flag); 2691 + xfs_trans_unreserve_quota_nblks(tp, ip, qblocks, 0, quota_flag); 2694 2692 2695 2693 error1: /* Just cancel transaction */ 2696 2694 xfs_trans_cancel(tp, XFS_TRANS_RELEASE_LOG_RES | XFS_TRANS_ABORT); ··· 2829 2827 2830 2828 xfs_itrace_entry(ip); 2831 2829 2832 - if ((error = XFS_QM_DQATTACH(mp, ip, 0))) 2830 + error = xfs_qm_dqattach(ip, 0); 2831 + if (error) 2833 2832 return error; 2834 2833 2835 2834 error = 0; ··· 2956 2953 break; 2957 2954 } 2958 2955 xfs_ilock(ip, XFS_ILOCK_EXCL); 2959 - error = XFS_TRANS_RESERVE_QUOTA(mp, tp, 2960 - ip->i_udquot, ip->i_gdquot, resblks, 0, 2961 - XFS_QMOPT_RES_REGBLKS); 2956 + error = xfs_trans_reserve_quota(tp, mp, 2957 + ip->i_udquot, ip->i_gdquot, 2958 + resblks, 0, XFS_QMOPT_RES_REGBLKS); 2962 2959 if (error) 2963 2960 goto error1; 2964 2961