diff options
author | Christoph Hellwig <hch@lst.de> | 2009-06-08 09:33:32 -0400 |
---|---|---|
committer | Christoph Hellwig <hch@brick.lst.de> | 2009-06-08 09:33:32 -0400 |
commit | 7d095257e321214e4cf359abd131ba1f09c60cba (patch) | |
tree | 3f71e2650651616f8ba168b64a82ab48aedef14c /fs/xfs/quota | |
parent | 0c5e1ce89f1eacc366ec421c0f5f681159479c28 (diff) |
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>
Diffstat (limited to 'fs/xfs/quota')
-rw-r--r-- | fs/xfs/quota/xfs_dquot.c | 4 | ||||
-rw-r--r-- | fs/xfs/quota/xfs_dquot.h | 1 | ||||
-rw-r--r-- | fs/xfs/quota/xfs_qm.c | 139 | ||||
-rw-r--r-- | fs/xfs/quota/xfs_qm.h | 21 | ||||
-rw-r--r-- | fs/xfs/quota/xfs_qm_bhv.c | 76 | ||||
-rw-r--r-- | fs/xfs/quota/xfs_trans_dquot.c | 65 |
6 files changed, 104 insertions, 202 deletions
diff --git a/fs/xfs/quota/xfs_dquot.c b/fs/xfs/quota/xfs_dquot.c index e4babcc63423..4d6d051ee56e 100644 --- a/fs/xfs/quota/xfs_dquot.c +++ b/fs/xfs/quota/xfs_dquot.c | |||
@@ -1194,7 +1194,9 @@ void | |||
1194 | xfs_qm_dqrele( | 1194 | xfs_qm_dqrele( |
1195 | xfs_dquot_t *dqp) | 1195 | xfs_dquot_t *dqp) |
1196 | { | 1196 | { |
1197 | ASSERT(dqp); | 1197 | if (!dqp) |
1198 | return; | ||
1199 | |||
1198 | xfs_dqtrace_entry(dqp, "DQRELE"); | 1200 | xfs_dqtrace_entry(dqp, "DQRELE"); |
1199 | 1201 | ||
1200 | xfs_dqlock(dqp); | 1202 | xfs_dqlock(dqp); |
diff --git a/fs/xfs/quota/xfs_dquot.h b/fs/xfs/quota/xfs_dquot.h index de0f402ddb4c..6533ead9b889 100644 --- a/fs/xfs/quota/xfs_dquot.h +++ b/fs/xfs/quota/xfs_dquot.h | |||
@@ -181,7 +181,6 @@ extern void xfs_qm_adjust_dqlimits(xfs_mount_t *, | |||
181 | extern int xfs_qm_dqget(xfs_mount_t *, xfs_inode_t *, | 181 | extern int xfs_qm_dqget(xfs_mount_t *, xfs_inode_t *, |
182 | xfs_dqid_t, uint, uint, xfs_dquot_t **); | 182 | xfs_dqid_t, uint, uint, xfs_dquot_t **); |
183 | extern void xfs_qm_dqput(xfs_dquot_t *); | 183 | extern void xfs_qm_dqput(xfs_dquot_t *); |
184 | extern void xfs_qm_dqrele(xfs_dquot_t *); | ||
185 | extern void xfs_dqlock(xfs_dquot_t *); | 184 | extern void xfs_dqlock(xfs_dquot_t *); |
186 | extern void xfs_dqlock2(xfs_dquot_t *, xfs_dquot_t *); | 185 | extern void xfs_dqlock2(xfs_dquot_t *, xfs_dquot_t *); |
187 | extern void xfs_dqunlock(xfs_dquot_t *); | 186 | extern void xfs_dqunlock(xfs_dquot_t *); |
diff --git a/fs/xfs/quota/xfs_qm.c b/fs/xfs/quota/xfs_qm.c index 5b6695049e00..aa5d8212661c 100644 --- a/fs/xfs/quota/xfs_qm.c +++ b/fs/xfs/quota/xfs_qm.c | |||
@@ -287,11 +287,13 @@ xfs_qm_rele_quotafs_ref( | |||
287 | * Just destroy the quotainfo structure. | 287 | * Just destroy the quotainfo structure. |
288 | */ | 288 | */ |
289 | void | 289 | void |
290 | xfs_qm_unmount_quotadestroy( | 290 | xfs_qm_unmount( |
291 | xfs_mount_t *mp) | 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 | xfs_qm_destroy_quotainfo(mp); | 295 | xfs_qm_destroy_quotainfo(mp); |
296 | } | ||
295 | } | 297 | } |
296 | 298 | ||
297 | 299 | ||
@@ -385,8 +387,13 @@ xfs_qm_mount_quotas( | |||
385 | if (error) { | 387 | if (error) { |
386 | xfs_fs_cmn_err(CE_WARN, mp, | 388 | xfs_fs_cmn_err(CE_WARN, mp, |
387 | "Failed to initialize disk quotas."); | 389 | "Failed to initialize disk quotas."); |
390 | return; | ||
388 | } | 391 | } |
389 | return; | 392 | |
393 | #ifdef QUOTADEBUG | ||
394 | if (XFS_IS_QUOTA_ON(mp)) | ||
395 | xfs_qm_internalqcheck(mp); | ||
396 | #endif | ||
390 | } | 397 | } |
391 | 398 | ||
392 | /* | 399 | /* |
@@ -774,12 +781,11 @@ xfs_qm_dqattach_grouphint( | |||
774 | * Given a locked inode, attach dquot(s) to it, taking U/G/P-QUOTAON | 781 | * Given a locked inode, attach dquot(s) to it, taking U/G/P-QUOTAON |
775 | * into account. | 782 | * into account. |
776 | * If XFS_QMOPT_DQALLOC, the dquot(s) will be allocated if needed. | 783 | * If XFS_QMOPT_DQALLOC, the dquot(s) will be allocated if needed. |
777 | * If XFS_QMOPT_ILOCKED, then inode sent is already locked EXCL. | ||
778 | * Inode may get unlocked and relocked in here, and the caller must deal with | 784 | * Inode may get unlocked and relocked in here, and the caller must deal with |
779 | * the consequences. | 785 | * the consequences. |
780 | */ | 786 | */ |
781 | int | 787 | int |
782 | xfs_qm_dqattach( | 788 | xfs_qm_dqattach_locked( |
783 | xfs_inode_t *ip, | 789 | xfs_inode_t *ip, |
784 | uint flags) | 790 | uint flags) |
785 | { | 791 | { |
@@ -787,17 +793,14 @@ xfs_qm_dqattach( | |||
787 | uint nquotas = 0; | 793 | uint nquotas = 0; |
788 | int error = 0; | 794 | int error = 0; |
789 | 795 | ||
790 | if ((! XFS_IS_QUOTA_ON(mp)) || | 796 | if (!XFS_IS_QUOTA_RUNNING(mp) || |
791 | (! XFS_NOT_DQATTACHED(mp, ip)) || | 797 | !XFS_IS_QUOTA_ON(mp) || |
792 | (ip->i_ino == mp->m_sb.sb_uquotino) || | 798 | !XFS_NOT_DQATTACHED(mp, ip) || |
793 | (ip->i_ino == mp->m_sb.sb_gquotino)) | 799 | ip->i_ino == mp->m_sb.sb_uquotino || |
800 | ip->i_ino == mp->m_sb.sb_gquotino) | ||
794 | return 0; | 801 | return 0; |
795 | 802 | ||
796 | ASSERT((flags & XFS_QMOPT_ILOCKED) == 0 || | 803 | ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); |
797 | xfs_isilocked(ip, XFS_ILOCK_EXCL)); | ||
798 | |||
799 | if (! (flags & XFS_QMOPT_ILOCKED)) | ||
800 | xfs_ilock(ip, XFS_ILOCK_EXCL); | ||
801 | 804 | ||
802 | if (XFS_IS_UQUOTA_ON(mp)) { | 805 | if (XFS_IS_UQUOTA_ON(mp)) { |
803 | error = xfs_qm_dqattach_one(ip, ip->i_d.di_uid, XFS_DQ_USER, | 806 | error = xfs_qm_dqattach_one(ip, ip->i_d.di_uid, XFS_DQ_USER, |
@@ -849,8 +852,7 @@ xfs_qm_dqattach( | |||
849 | xfs_qm_dqattach_grouphint(ip->i_udquot, ip->i_gdquot); | 852 | xfs_qm_dqattach_grouphint(ip->i_udquot, ip->i_gdquot); |
850 | } | 853 | } |
851 | 854 | ||
852 | done: | 855 | done: |
853 | |||
854 | #ifdef QUOTADEBUG | 856 | #ifdef QUOTADEBUG |
855 | if (! error) { | 857 | if (! error) { |
856 | if (XFS_IS_UQUOTA_ON(mp)) | 858 | if (XFS_IS_UQUOTA_ON(mp)) |
@@ -858,15 +860,22 @@ xfs_qm_dqattach( | |||
858 | if (XFS_IS_OQUOTA_ON(mp)) | 860 | if (XFS_IS_OQUOTA_ON(mp)) |
859 | ASSERT(ip->i_gdquot); | 861 | ASSERT(ip->i_gdquot); |
860 | } | 862 | } |
863 | ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); | ||
861 | #endif | 864 | #endif |
865 | return error; | ||
866 | } | ||
862 | 867 | ||
863 | if (! (flags & XFS_QMOPT_ILOCKED)) | 868 | int |
864 | xfs_iunlock(ip, XFS_ILOCK_EXCL); | 869 | xfs_qm_dqattach( |
870 | struct xfs_inode *ip, | ||
871 | uint flags) | ||
872 | { | ||
873 | int error; | ||
874 | |||
875 | xfs_ilock(ip, XFS_ILOCK_EXCL); | ||
876 | error = xfs_qm_dqattach_locked(ip, flags); | ||
877 | xfs_iunlock(ip, XFS_ILOCK_EXCL); | ||
865 | 878 | ||
866 | #ifdef QUOTADEBUG | ||
867 | else | ||
868 | ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); | ||
869 | #endif | ||
870 | return error; | 879 | return error; |
871 | } | 880 | } |
872 | 881 | ||
@@ -912,7 +921,7 @@ xfs_qm_sync( | |||
912 | boolean_t nowait; | 921 | boolean_t nowait; |
913 | int error; | 922 | int error; |
914 | 923 | ||
915 | if (! XFS_IS_QUOTA_ON(mp)) | 924 | if (!XFS_IS_QUOTA_RUNNING(mp) || !XFS_IS_QUOTA_ON(mp)) |
916 | return 0; | 925 | return 0; |
917 | 926 | ||
918 | restarts = 0; | 927 | restarts = 0; |
@@ -2319,20 +2328,20 @@ xfs_qm_write_sb_changes( | |||
2319 | */ | 2328 | */ |
2320 | int | 2329 | int |
2321 | xfs_qm_vop_dqalloc( | 2330 | xfs_qm_vop_dqalloc( |
2322 | xfs_mount_t *mp, | 2331 | struct xfs_inode *ip, |
2323 | xfs_inode_t *ip, | 2332 | uid_t uid, |
2324 | uid_t uid, | 2333 | gid_t gid, |
2325 | gid_t gid, | 2334 | prid_t prid, |
2326 | prid_t prid, | 2335 | uint flags, |
2327 | uint flags, | 2336 | struct xfs_dquot **O_udqpp, |
2328 | xfs_dquot_t **O_udqpp, | 2337 | struct xfs_dquot **O_gdqpp) |
2329 | xfs_dquot_t **O_gdqpp) | ||
2330 | { | 2338 | { |
2331 | int error; | 2339 | struct xfs_mount *mp = ip->i_mount; |
2332 | xfs_dquot_t *uq, *gq; | 2340 | struct xfs_dquot *uq, *gq; |
2333 | uint lockflags; | 2341 | int error; |
2342 | uint lockflags; | ||
2334 | 2343 | ||
2335 | if (!XFS_IS_QUOTA_ON(mp)) | 2344 | if (!XFS_IS_QUOTA_RUNNING(mp) || !XFS_IS_QUOTA_ON(mp)) |
2336 | return 0; | 2345 | return 0; |
2337 | 2346 | ||
2338 | lockflags = XFS_ILOCK_EXCL; | 2347 | lockflags = XFS_ILOCK_EXCL; |
@@ -2346,8 +2355,8 @@ xfs_qm_vop_dqalloc( | |||
2346 | * if necessary. The dquot(s) will not be locked. | 2355 | * if necessary. The dquot(s) will not be locked. |
2347 | */ | 2356 | */ |
2348 | if (XFS_NOT_DQATTACHED(mp, ip)) { | 2357 | if (XFS_NOT_DQATTACHED(mp, ip)) { |
2349 | if ((error = xfs_qm_dqattach(ip, XFS_QMOPT_DQALLOC | | 2358 | error = xfs_qm_dqattach_locked(ip, XFS_QMOPT_DQALLOC); |
2350 | XFS_QMOPT_ILOCKED))) { | 2359 | if (error) { |
2351 | xfs_iunlock(ip, lockflags); | 2360 | xfs_iunlock(ip, lockflags); |
2352 | return error; | 2361 | return error; |
2353 | } | 2362 | } |
@@ -2469,6 +2478,7 @@ xfs_qm_vop_chown( | |||
2469 | uint bfield = XFS_IS_REALTIME_INODE(ip) ? | 2478 | uint bfield = XFS_IS_REALTIME_INODE(ip) ? |
2470 | XFS_TRANS_DQ_RTBCOUNT : XFS_TRANS_DQ_BCOUNT; | 2479 | XFS_TRANS_DQ_RTBCOUNT : XFS_TRANS_DQ_BCOUNT; |
2471 | 2480 | ||
2481 | |||
2472 | ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); | 2482 | ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); |
2473 | ASSERT(XFS_IS_QUOTA_RUNNING(ip->i_mount)); | 2483 | ASSERT(XFS_IS_QUOTA_RUNNING(ip->i_mount)); |
2474 | 2484 | ||
@@ -2508,13 +2518,13 @@ xfs_qm_vop_chown_reserve( | |||
2508 | xfs_dquot_t *gdqp, | 2518 | xfs_dquot_t *gdqp, |
2509 | uint flags) | 2519 | uint flags) |
2510 | { | 2520 | { |
2511 | int error; | 2521 | xfs_mount_t *mp = ip->i_mount; |
2512 | xfs_mount_t *mp; | ||
2513 | uint delblks, blkflags, prjflags = 0; | 2522 | uint delblks, blkflags, prjflags = 0; |
2514 | xfs_dquot_t *unresudq, *unresgdq, *delblksudq, *delblksgdq; | 2523 | xfs_dquot_t *unresudq, *unresgdq, *delblksudq, *delblksgdq; |
2524 | int error; | ||
2525 | |||
2515 | 2526 | ||
2516 | ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL|XFS_ILOCK_SHARED)); | 2527 | ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL|XFS_ILOCK_SHARED)); |
2517 | mp = ip->i_mount; | ||
2518 | ASSERT(XFS_IS_QUOTA_RUNNING(mp)); | 2528 | ASSERT(XFS_IS_QUOTA_RUNNING(mp)); |
2519 | 2529 | ||
2520 | delblks = ip->i_delayed_blks; | 2530 | delblks = ip->i_delayed_blks; |
@@ -2582,28 +2592,23 @@ xfs_qm_vop_chown_reserve( | |||
2582 | 2592 | ||
2583 | int | 2593 | int |
2584 | xfs_qm_vop_rename_dqattach( | 2594 | xfs_qm_vop_rename_dqattach( |
2585 | xfs_inode_t **i_tab) | 2595 | struct xfs_inode **i_tab) |
2586 | { | 2596 | { |
2587 | xfs_inode_t *ip; | 2597 | struct xfs_mount *mp = i_tab[0]->i_mount; |
2588 | int i; | 2598 | int i; |
2589 | int error; | ||
2590 | |||
2591 | ip = i_tab[0]; | ||
2592 | 2599 | ||
2593 | if (! XFS_IS_QUOTA_ON(ip->i_mount)) | 2600 | if (!XFS_IS_QUOTA_RUNNING(mp) || !XFS_IS_QUOTA_ON(mp)) |
2594 | return 0; | 2601 | return 0; |
2595 | 2602 | ||
2596 | if (XFS_NOT_DQATTACHED(ip->i_mount, ip)) { | 2603 | for (i = 0; (i < 4 && i_tab[i]); i++) { |
2597 | error = xfs_qm_dqattach(ip, 0); | 2604 | struct xfs_inode *ip = i_tab[i]; |
2598 | if (error) | 2605 | int error; |
2599 | return error; | 2606 | |
2600 | } | ||
2601 | for (i = 1; (i < 4 && i_tab[i]); i++) { | ||
2602 | /* | 2607 | /* |
2603 | * Watch out for duplicate entries in the table. | 2608 | * Watch out for duplicate entries in the table. |
2604 | */ | 2609 | */ |
2605 | if ((ip = i_tab[i]) != i_tab[i-1]) { | 2610 | if (i == 0 || ip != i_tab[i-1]) { |
2606 | if (XFS_NOT_DQATTACHED(ip->i_mount, ip)) { | 2611 | if (XFS_NOT_DQATTACHED(mp, ip)) { |
2607 | error = xfs_qm_dqattach(ip, 0); | 2612 | error = xfs_qm_dqattach(ip, 0); |
2608 | if (error) | 2613 | if (error) |
2609 | return error; | 2614 | return error; |
@@ -2614,17 +2619,19 @@ xfs_qm_vop_rename_dqattach( | |||
2614 | } | 2619 | } |
2615 | 2620 | ||
2616 | void | 2621 | void |
2617 | xfs_qm_vop_dqattach_and_dqmod_newinode( | 2622 | xfs_qm_vop_create_dqattach( |
2618 | xfs_trans_t *tp, | 2623 | struct xfs_trans *tp, |
2619 | xfs_inode_t *ip, | 2624 | struct xfs_inode *ip, |
2620 | xfs_dquot_t *udqp, | 2625 | struct xfs_dquot *udqp, |
2621 | xfs_dquot_t *gdqp) | 2626 | struct xfs_dquot *gdqp) |
2622 | { | 2627 | { |
2623 | if (!XFS_IS_QUOTA_ON(tp->t_mountp)) | 2628 | struct xfs_mount *mp = tp->t_mountp; |
2629 | |||
2630 | if (!XFS_IS_QUOTA_RUNNING(mp) || !XFS_IS_QUOTA_ON(mp)) | ||
2624 | return; | 2631 | return; |
2625 | 2632 | ||
2626 | ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); | 2633 | ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); |
2627 | ASSERT(XFS_IS_QUOTA_RUNNING(tp->t_mountp)); | 2634 | ASSERT(XFS_IS_QUOTA_RUNNING(mp)); |
2628 | 2635 | ||
2629 | if (udqp) { | 2636 | if (udqp) { |
2630 | xfs_dqlock(udqp); | 2637 | xfs_dqlock(udqp); |
@@ -2632,7 +2639,7 @@ xfs_qm_vop_dqattach_and_dqmod_newinode( | |||
2632 | xfs_dqunlock(udqp); | 2639 | xfs_dqunlock(udqp); |
2633 | ASSERT(ip->i_udquot == NULL); | 2640 | ASSERT(ip->i_udquot == NULL); |
2634 | ip->i_udquot = udqp; | 2641 | ip->i_udquot = udqp; |
2635 | ASSERT(XFS_IS_UQUOTA_ON(tp->t_mountp)); | 2642 | ASSERT(XFS_IS_UQUOTA_ON(mp)); |
2636 | ASSERT(ip->i_d.di_uid == be32_to_cpu(udqp->q_core.d_id)); | 2643 | ASSERT(ip->i_d.di_uid == be32_to_cpu(udqp->q_core.d_id)); |
2637 | xfs_trans_mod_dquot(tp, udqp, XFS_TRANS_DQ_ICOUNT, 1); | 2644 | xfs_trans_mod_dquot(tp, udqp, XFS_TRANS_DQ_ICOUNT, 1); |
2638 | } | 2645 | } |
@@ -2642,8 +2649,8 @@ xfs_qm_vop_dqattach_and_dqmod_newinode( | |||
2642 | xfs_dqunlock(gdqp); | 2649 | xfs_dqunlock(gdqp); |
2643 | ASSERT(ip->i_gdquot == NULL); | 2650 | ASSERT(ip->i_gdquot == NULL); |
2644 | ip->i_gdquot = gdqp; | 2651 | ip->i_gdquot = gdqp; |
2645 | ASSERT(XFS_IS_OQUOTA_ON(tp->t_mountp)); | 2652 | ASSERT(XFS_IS_OQUOTA_ON(mp)); |
2646 | ASSERT((XFS_IS_GQUOTA_ON(tp->t_mountp) ? | 2653 | ASSERT((XFS_IS_GQUOTA_ON(mp) ? |
2647 | ip->i_d.di_gid : ip->i_d.di_projid) == | 2654 | ip->i_d.di_gid : ip->i_d.di_projid) == |
2648 | be32_to_cpu(gdqp->q_core.d_id)); | 2655 | be32_to_cpu(gdqp->q_core.d_id)); |
2649 | xfs_trans_mod_dquot(tp, gdqp, XFS_TRANS_DQ_ICOUNT, 1); | 2656 | xfs_trans_mod_dquot(tp, gdqp, XFS_TRANS_DQ_ICOUNT, 1); |
diff --git a/fs/xfs/quota/xfs_qm.h b/fs/xfs/quota/xfs_qm.h index a371954cae1b..495564b8af38 100644 --- a/fs/xfs/quota/xfs_qm.h +++ b/fs/xfs/quota/xfs_qm.h | |||
@@ -127,8 +127,6 @@ typedef struct xfs_quotainfo { | |||
127 | } xfs_quotainfo_t; | 127 | } xfs_quotainfo_t; |
128 | 128 | ||
129 | 129 | ||
130 | extern xfs_dqtrxops_t xfs_trans_dquot_ops; | ||
131 | |||
132 | extern void xfs_trans_mod_dquot(xfs_trans_t *, xfs_dquot_t *, uint, long); | 130 | extern void xfs_trans_mod_dquot(xfs_trans_t *, xfs_dquot_t *, uint, long); |
133 | extern int xfs_trans_reserve_quota_bydquots(xfs_trans_t *, xfs_mount_t *, | 131 | extern int xfs_trans_reserve_quota_bydquots(xfs_trans_t *, xfs_mount_t *, |
134 | xfs_dquot_t *, xfs_dquot_t *, long, long, uint); | 132 | xfs_dquot_t *, xfs_dquot_t *, long, long, uint); |
@@ -159,17 +157,11 @@ typedef struct xfs_dquot_acct { | |||
159 | #define XFS_QM_RTBWARNLIMIT 5 | 157 | #define XFS_QM_RTBWARNLIMIT 5 |
160 | 158 | ||
161 | extern void xfs_qm_destroy_quotainfo(xfs_mount_t *); | 159 | extern void xfs_qm_destroy_quotainfo(xfs_mount_t *); |
162 | extern void xfs_qm_mount_quotas(xfs_mount_t *); | ||
163 | extern int xfs_qm_quotacheck(xfs_mount_t *); | 160 | extern int xfs_qm_quotacheck(xfs_mount_t *); |
164 | extern void xfs_qm_unmount_quotadestroy(xfs_mount_t *); | ||
165 | extern void xfs_qm_unmount_quotas(xfs_mount_t *); | ||
166 | extern int xfs_qm_write_sb_changes(xfs_mount_t *, __int64_t); | 161 | extern int xfs_qm_write_sb_changes(xfs_mount_t *, __int64_t); |
167 | extern int xfs_qm_sync(xfs_mount_t *, int); | ||
168 | 162 | ||
169 | /* dquot stuff */ | 163 | /* dquot stuff */ |
170 | extern boolean_t xfs_qm_dqalloc_incore(xfs_dquot_t **); | 164 | extern boolean_t xfs_qm_dqalloc_incore(xfs_dquot_t **); |
171 | extern int xfs_qm_dqattach(xfs_inode_t *, uint); | ||
172 | extern void xfs_qm_dqdetach(xfs_inode_t *); | ||
173 | extern int xfs_qm_dqpurge_all(xfs_mount_t *, uint); | 165 | extern int xfs_qm_dqpurge_all(xfs_mount_t *, uint); |
174 | extern void xfs_qm_dqrele_all_inodes(xfs_mount_t *, uint); | 166 | extern void xfs_qm_dqrele_all_inodes(xfs_mount_t *, uint); |
175 | 167 | ||
@@ -183,19 +175,6 @@ extern int xfs_qm_scall_getqstat(xfs_mount_t *, fs_quota_stat_t *); | |||
183 | extern int xfs_qm_scall_quotaon(xfs_mount_t *, uint); | 175 | extern int xfs_qm_scall_quotaon(xfs_mount_t *, uint); |
184 | extern int xfs_qm_scall_quotaoff(xfs_mount_t *, uint); | 176 | extern int xfs_qm_scall_quotaoff(xfs_mount_t *, uint); |
185 | 177 | ||
186 | /* vop stuff */ | ||
187 | extern int xfs_qm_vop_dqalloc(xfs_mount_t *, xfs_inode_t *, | ||
188 | uid_t, gid_t, prid_t, uint, | ||
189 | xfs_dquot_t **, xfs_dquot_t **); | ||
190 | extern void xfs_qm_vop_dqattach_and_dqmod_newinode( | ||
191 | xfs_trans_t *, xfs_inode_t *, | ||
192 | xfs_dquot_t *, xfs_dquot_t *); | ||
193 | extern int xfs_qm_vop_rename_dqattach(xfs_inode_t **); | ||
194 | extern xfs_dquot_t * xfs_qm_vop_chown(xfs_trans_t *, xfs_inode_t *, | ||
195 | xfs_dquot_t **, xfs_dquot_t *); | ||
196 | extern int xfs_qm_vop_chown_reserve(xfs_trans_t *, xfs_inode_t *, | ||
197 | xfs_dquot_t *, xfs_dquot_t *, uint); | ||
198 | |||
199 | /* list stuff */ | 178 | /* list stuff */ |
200 | extern void xfs_qm_freelist_append(xfs_frlist_t *, xfs_dquot_t *); | 179 | extern void xfs_qm_freelist_append(xfs_frlist_t *, xfs_dquot_t *); |
201 | extern void xfs_qm_freelist_unlink(xfs_dquot_t *); | 180 | extern void xfs_qm_freelist_unlink(xfs_dquot_t *); |
diff --git a/fs/xfs/quota/xfs_qm_bhv.c b/fs/xfs/quota/xfs_qm_bhv.c index 63037c689a4b..56a5965f3c8b 100644 --- a/fs/xfs/quota/xfs_qm_bhv.c +++ b/fs/xfs/quota/xfs_qm_bhv.c | |||
@@ -84,7 +84,7 @@ xfs_fill_statvfs_from_dquot( | |||
84 | * return a statvfs of the project, not the entire filesystem. | 84 | * return a statvfs of the project, not the entire filesystem. |
85 | * This makes such trees appear as if they are filesystems in themselves. | 85 | * This makes such trees appear as if they are filesystems in themselves. |
86 | */ | 86 | */ |
87 | STATIC void | 87 | void |
88 | xfs_qm_statvfs( | 88 | xfs_qm_statvfs( |
89 | xfs_inode_t *ip, | 89 | xfs_inode_t *ip, |
90 | struct kstatfs *statp) | 90 | struct kstatfs *statp) |
@@ -92,20 +92,13 @@ xfs_qm_statvfs( | |||
92 | xfs_mount_t *mp = ip->i_mount; | 92 | xfs_mount_t *mp = ip->i_mount; |
93 | xfs_dquot_t *dqp; | 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 | if (!xfs_qm_dqget(mp, NULL, ip->i_d.di_projid, XFS_DQ_PROJ, 0, &dqp)) { | 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; | 96 | xfs_fill_statvfs_from_dquot(statp, &dqp->q_core); |
102 | |||
103 | xfs_fill_statvfs_from_dquot(statp, dp); | ||
104 | xfs_qm_dqput(dqp); | 97 | xfs_qm_dqput(dqp); |
105 | } | 98 | } |
106 | } | 99 | } |
107 | 100 | ||
108 | STATIC int | 101 | int |
109 | xfs_qm_newmount( | 102 | xfs_qm_newmount( |
110 | xfs_mount_t *mp, | 103 | xfs_mount_t *mp, |
111 | uint *needquotamount, | 104 | uint *needquotamount, |
@@ -114,9 +107,6 @@ xfs_qm_newmount( | |||
114 | uint quotaondisk; | 107 | uint quotaondisk; |
115 | uint uquotaondisk = 0, gquotaondisk = 0, pquotaondisk = 0; | 108 | uint uquotaondisk = 0, gquotaondisk = 0, pquotaondisk = 0; |
116 | 109 | ||
117 | *quotaflags = 0; | ||
118 | *needquotamount = B_FALSE; | ||
119 | |||
120 | quotaondisk = xfs_sb_version_hasquota(&mp->m_sb) && | 110 | quotaondisk = xfs_sb_version_hasquota(&mp->m_sb) && |
121 | (mp->m_sb.sb_qflags & XFS_ALL_QUOTA_ACCT); | 111 | (mp->m_sb.sb_qflags & XFS_ALL_QUOTA_ACCT); |
122 | 112 | ||
@@ -179,66 +169,6 @@ xfs_qm_newmount( | |||
179 | return 0; | 169 | return 0; |
180 | } | 170 | } |
181 | 171 | ||
182 | STATIC int | ||
183 | xfs_qm_endmount( | ||
184 | xfs_mount_t *mp, | ||
185 | uint needquotamount, | ||
186 | uint quotaflags) | ||
187 | { | ||
188 | if (needquotamount) { | ||
189 | ASSERT(mp->m_qflags == 0); | ||
190 | mp->m_qflags = quotaflags; | ||
191 | xfs_qm_mount_quotas(mp); | ||
192 | } | ||
193 | |||
194 | #if defined(DEBUG) && defined(XFS_LOUD_RECOVERY) | ||
195 | if (! (XFS_IS_QUOTA_ON(mp))) | ||
196 | xfs_fs_cmn_err(CE_NOTE, mp, "Disk quotas not turned on"); | ||
197 | else | ||
198 | xfs_fs_cmn_err(CE_NOTE, mp, "Disk quotas turned on"); | ||
199 | #endif | ||
200 | |||
201 | #ifdef QUOTADEBUG | ||
202 | if (XFS_IS_QUOTA_ON(mp) && xfs_qm_internalqcheck(mp)) | ||
203 | cmn_err(CE_WARN, "XFS: mount internalqcheck failed"); | ||
204 | #endif | ||
205 | |||
206 | return 0; | ||
207 | } | ||
208 | |||
209 | STATIC void | ||
210 | xfs_qm_dqrele_null( | ||
211 | xfs_dquot_t *dq) | ||
212 | { | ||
213 | /* | ||
214 | * Called from XFS, where we always check first for a NULL dquot. | ||
215 | */ | ||
216 | if (!dq) | ||
217 | return; | ||
218 | xfs_qm_dqrele(dq); | ||
219 | } | ||
220 | |||
221 | |||
222 | struct xfs_qmops xfs_qmcore_xfs = { | ||
223 | .xfs_qminit = xfs_qm_newmount, | ||
224 | .xfs_qmdone = xfs_qm_unmount_quotadestroy, | ||
225 | .xfs_qmmount = xfs_qm_endmount, | ||
226 | .xfs_qmunmount = xfs_qm_unmount_quotas, | ||
227 | .xfs_dqrele = xfs_qm_dqrele_null, | ||
228 | .xfs_dqattach = xfs_qm_dqattach, | ||
229 | .xfs_dqdetach = xfs_qm_dqdetach, | ||
230 | .xfs_dqpurgeall = xfs_qm_dqpurge_all, | ||
231 | .xfs_dqvopalloc = xfs_qm_vop_dqalloc, | ||
232 | .xfs_dqvopcreate = xfs_qm_vop_dqattach_and_dqmod_newinode, | ||
233 | .xfs_dqvoprename = xfs_qm_vop_rename_dqattach, | ||
234 | .xfs_dqvopchown = xfs_qm_vop_chown, | ||
235 | .xfs_dqvopchownresv = xfs_qm_vop_chown_reserve, | ||
236 | .xfs_dqstatvfs = xfs_qm_statvfs, | ||
237 | .xfs_dqsync = xfs_qm_sync, | ||
238 | .xfs_dqtrxops = &xfs_trans_dquot_ops, | ||
239 | }; | ||
240 | EXPORT_SYMBOL(xfs_qmcore_xfs); | ||
241 | |||
242 | void __init | 172 | void __init |
243 | xfs_qm_init(void) | 173 | xfs_qm_init(void) |
244 | { | 174 | { |
diff --git a/fs/xfs/quota/xfs_trans_dquot.c b/fs/xfs/quota/xfs_trans_dquot.c index 447173bcf96d..eafa7ab34085 100644 --- a/fs/xfs/quota/xfs_trans_dquot.c +++ b/fs/xfs/quota/xfs_trans_dquot.c | |||
@@ -111,7 +111,7 @@ xfs_trans_log_dquot( | |||
111 | * Carry forward whatever is left of the quota blk reservation to | 111 | * Carry forward whatever is left of the quota blk reservation to |
112 | * the spanky new transaction | 112 | * the spanky new transaction |
113 | */ | 113 | */ |
114 | STATIC void | 114 | void |
115 | xfs_trans_dup_dqinfo( | 115 | xfs_trans_dup_dqinfo( |
116 | xfs_trans_t *otp, | 116 | xfs_trans_t *otp, |
117 | xfs_trans_t *ntp) | 117 | xfs_trans_t *ntp) |
@@ -167,19 +167,17 @@ xfs_trans_dup_dqinfo( | |||
167 | /* | 167 | /* |
168 | * Wrap around mod_dquot to account for both user and group quotas. | 168 | * Wrap around mod_dquot to account for both user and group quotas. |
169 | */ | 169 | */ |
170 | STATIC void | 170 | void |
171 | xfs_trans_mod_dquot_byino( | 171 | xfs_trans_mod_dquot_byino( |
172 | xfs_trans_t *tp, | 172 | xfs_trans_t *tp, |
173 | xfs_inode_t *ip, | 173 | xfs_inode_t *ip, |
174 | uint field, | 174 | uint field, |
175 | long delta) | 175 | long delta) |
176 | { | 176 | { |
177 | xfs_mount_t *mp; | 177 | xfs_mount_t *mp = tp->t_mountp; |
178 | |||
179 | ASSERT(tp); | ||
180 | mp = tp->t_mountp; | ||
181 | 178 | ||
182 | if (!XFS_IS_QUOTA_ON(mp) || | 179 | if (!XFS_IS_QUOTA_RUNNING(mp) || |
180 | !XFS_IS_QUOTA_ON(mp) || | ||
183 | ip->i_ino == mp->m_sb.sb_uquotino || | 181 | ip->i_ino == mp->m_sb.sb_uquotino || |
184 | ip->i_ino == mp->m_sb.sb_gquotino) | 182 | ip->i_ino == mp->m_sb.sb_gquotino) |
185 | return; | 183 | return; |
@@ -229,6 +227,7 @@ xfs_trans_mod_dquot( | |||
229 | xfs_dqtrx_t *qtrx; | 227 | xfs_dqtrx_t *qtrx; |
230 | 228 | ||
231 | ASSERT(tp); | 229 | ASSERT(tp); |
230 | ASSERT(XFS_IS_QUOTA_RUNNING(tp->t_mountp)); | ||
232 | qtrx = NULL; | 231 | qtrx = NULL; |
233 | 232 | ||
234 | if (tp->t_dqinfo == NULL) | 233 | if (tp->t_dqinfo == NULL) |
@@ -346,7 +345,7 @@ xfs_trans_dqlockedjoin( | |||
346 | * Unreserve just the reservations done by this transaction. | 345 | * Unreserve just the reservations done by this transaction. |
347 | * dquot is still left locked at exit. | 346 | * dquot is still left locked at exit. |
348 | */ | 347 | */ |
349 | STATIC void | 348 | void |
350 | xfs_trans_apply_dquot_deltas( | 349 | xfs_trans_apply_dquot_deltas( |
351 | xfs_trans_t *tp) | 350 | xfs_trans_t *tp) |
352 | { | 351 | { |
@@ -357,7 +356,7 @@ xfs_trans_apply_dquot_deltas( | |||
357 | long totalbdelta; | 356 | long totalbdelta; |
358 | long totalrtbdelta; | 357 | long totalrtbdelta; |
359 | 358 | ||
360 | if (! (tp->t_flags & XFS_TRANS_DQ_DIRTY)) | 359 | if (!(tp->t_flags & XFS_TRANS_DQ_DIRTY)) |
361 | return; | 360 | return; |
362 | 361 | ||
363 | ASSERT(tp->t_dqinfo); | 362 | ASSERT(tp->t_dqinfo); |
@@ -531,7 +530,7 @@ xfs_trans_apply_dquot_deltas( | |||
531 | * we simply throw those away, since that's the expected behavior | 530 | * we simply throw those away, since that's the expected behavior |
532 | * when a transaction is curtailed without a commit. | 531 | * when a transaction is curtailed without a commit. |
533 | */ | 532 | */ |
534 | STATIC void | 533 | void |
535 | xfs_trans_unreserve_and_mod_dquots( | 534 | xfs_trans_unreserve_and_mod_dquots( |
536 | xfs_trans_t *tp) | 535 | xfs_trans_t *tp) |
537 | { | 536 | { |
@@ -768,7 +767,7 @@ xfs_trans_reserve_quota_bydquots( | |||
768 | { | 767 | { |
769 | int resvd = 0, error; | 768 | int resvd = 0, error; |
770 | 769 | ||
771 | if (!XFS_IS_QUOTA_ON(mp)) | 770 | if (!XFS_IS_QUOTA_RUNNING(mp) || !XFS_IS_QUOTA_ON(mp)) |
772 | return 0; | 771 | return 0; |
773 | 772 | ||
774 | if (tp && tp->t_dqinfo == NULL) | 773 | if (tp && tp->t_dqinfo == NULL) |
@@ -811,18 +810,17 @@ xfs_trans_reserve_quota_bydquots( | |||
811 | * This doesn't change the actual usage, just the reservation. | 810 | * This doesn't change the actual usage, just the reservation. |
812 | * The inode sent in is locked. | 811 | * The inode sent in is locked. |
813 | */ | 812 | */ |
814 | STATIC int | 813 | int |
815 | xfs_trans_reserve_quota_nblks( | 814 | xfs_trans_reserve_quota_nblks( |
816 | xfs_trans_t *tp, | 815 | struct xfs_trans *tp, |
817 | xfs_mount_t *mp, | 816 | struct xfs_inode *ip, |
818 | xfs_inode_t *ip, | 817 | long nblks, |
819 | long nblks, | 818 | long ninos, |
820 | long ninos, | 819 | uint flags) |
821 | uint flags) | ||
822 | { | 820 | { |
823 | int error; | 821 | struct xfs_mount *mp = ip->i_mount; |
824 | 822 | ||
825 | if (!XFS_IS_QUOTA_ON(mp)) | 823 | if (!XFS_IS_QUOTA_RUNNING(mp) || !XFS_IS_QUOTA_ON(mp)) |
826 | return 0; | 824 | return 0; |
827 | if (XFS_IS_PQUOTA_ON(mp)) | 825 | if (XFS_IS_PQUOTA_ON(mp)) |
828 | flags |= XFS_QMOPT_ENOSPC; | 826 | flags |= XFS_QMOPT_ENOSPC; |
@@ -831,7 +829,6 @@ xfs_trans_reserve_quota_nblks( | |||
831 | ASSERT(ip->i_ino != mp->m_sb.sb_gquotino); | 829 | ASSERT(ip->i_ino != mp->m_sb.sb_gquotino); |
832 | 830 | ||
833 | ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); | 831 | ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); |
834 | ASSERT(XFS_IS_QUOTA_RUNNING(ip->i_mount)); | ||
835 | ASSERT((flags & ~(XFS_QMOPT_FORCE_RES | XFS_QMOPT_ENOSPC)) == | 832 | ASSERT((flags & ~(XFS_QMOPT_FORCE_RES | XFS_QMOPT_ENOSPC)) == |
836 | XFS_TRANS_DQ_RES_RTBLKS || | 833 | XFS_TRANS_DQ_RES_RTBLKS || |
837 | (flags & ~(XFS_QMOPT_FORCE_RES | XFS_QMOPT_ENOSPC)) == | 834 | (flags & ~(XFS_QMOPT_FORCE_RES | XFS_QMOPT_ENOSPC)) == |
@@ -840,11 +837,9 @@ xfs_trans_reserve_quota_nblks( | |||
840 | /* | 837 | /* |
841 | * Reserve nblks against these dquots, with trans as the mediator. | 838 | * Reserve nblks against these dquots, with trans as the mediator. |
842 | */ | 839 | */ |
843 | error = xfs_trans_reserve_quota_bydquots(tp, mp, | 840 | return xfs_trans_reserve_quota_bydquots(tp, mp, |
844 | ip->i_udquot, ip->i_gdquot, | 841 | ip->i_udquot, ip->i_gdquot, |
845 | nblks, ninos, | 842 | nblks, ninos, flags); |
846 | flags); | ||
847 | return error; | ||
848 | } | 843 | } |
849 | 844 | ||
850 | /* | 845 | /* |
@@ -895,25 +890,15 @@ STATIC void | |||
895 | xfs_trans_alloc_dqinfo( | 890 | xfs_trans_alloc_dqinfo( |
896 | xfs_trans_t *tp) | 891 | xfs_trans_t *tp) |
897 | { | 892 | { |
898 | (tp)->t_dqinfo = kmem_zone_zalloc(xfs_Gqm->qm_dqtrxzone, KM_SLEEP); | 893 | tp->t_dqinfo = kmem_zone_zalloc(xfs_Gqm->qm_dqtrxzone, KM_SLEEP); |
899 | } | 894 | } |
900 | 895 | ||
901 | STATIC void | 896 | void |
902 | xfs_trans_free_dqinfo( | 897 | xfs_trans_free_dqinfo( |
903 | xfs_trans_t *tp) | 898 | xfs_trans_t *tp) |
904 | { | 899 | { |
905 | if (!tp->t_dqinfo) | 900 | if (!tp->t_dqinfo) |
906 | return; | 901 | return; |
907 | kmem_zone_free(xfs_Gqm->qm_dqtrxzone, (tp)->t_dqinfo); | 902 | kmem_zone_free(xfs_Gqm->qm_dqtrxzone, tp->t_dqinfo); |
908 | (tp)->t_dqinfo = NULL; | 903 | tp->t_dqinfo = NULL; |
909 | } | 904 | } |
910 | |||
911 | xfs_dqtrxops_t xfs_trans_dquot_ops = { | ||
912 | .qo_dup_dqinfo = xfs_trans_dup_dqinfo, | ||
913 | .qo_free_dqinfo = xfs_trans_free_dqinfo, | ||
914 | .qo_mod_dquot_byino = xfs_trans_mod_dquot_byino, | ||
915 | .qo_apply_dquot_deltas = xfs_trans_apply_dquot_deltas, | ||
916 | .qo_reserve_quota_nblks = xfs_trans_reserve_quota_nblks, | ||
917 | .qo_reserve_quota_bydquots = xfs_trans_reserve_quota_bydquots, | ||
918 | .qo_unreserve_and_mod_dquots = xfs_trans_unreserve_and_mod_dquots, | ||
919 | }; | ||