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/xfs_qm.c | |
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/xfs_qm.c')
-rw-r--r-- | fs/xfs/quota/xfs_qm.c | 139 |
1 files changed, 73 insertions, 66 deletions
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); |