Commit d82661d96993ac4efc1d54259ea85ffcd9b8bec6
1 parent
860b25d4a9
Exists in
master
and in
7 other branches
[GFS2] Streamline quota lock/check for no-quota case
This patch streamlines the quota checking in the "no quota" case by making the check inline in the calling function, thus reducing the number of function calls. Eventually we might be able to remove the checks from the gfs2_quota_lock() and gfs2_quota_check() functions, but currently we can't as there are a very few places in the code which need to call these functions directly still. Signed-off-by: Steven Whitehouse <swhiteho@redhat.com> Cc: Abhijith Das <adas@redhat.com>
Showing 6 changed files with 23 additions and 29 deletions Side-by-side Diff
fs/gfs2/bmap.c
... | ... | @@ -903,13 +903,9 @@ |
903 | 903 | if (!al) |
904 | 904 | return -ENOMEM; |
905 | 905 | |
906 | - error = gfs2_quota_lock(ip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE); | |
906 | + error = gfs2_quota_lock_check(ip); | |
907 | 907 | if (error) |
908 | 908 | goto out; |
909 | - | |
910 | - error = gfs2_quota_check(ip, ip->i_inode.i_uid, ip->i_inode.i_gid); | |
911 | - if (error) | |
912 | - goto out_gunlock_q; | |
913 | 909 | |
914 | 910 | al->al_requested = sdp->sd_max_height + RES_DATA; |
915 | 911 |
fs/gfs2/eattr.c
... | ... | @@ -686,13 +686,9 @@ |
686 | 686 | if (!al) |
687 | 687 | return -ENOMEM; |
688 | 688 | |
689 | - error = gfs2_quota_lock(ip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE); | |
689 | + error = gfs2_quota_lock_check(ip); | |
690 | 690 | if (error) |
691 | 691 | goto out; |
692 | - | |
693 | - error = gfs2_quota_check(ip, ip->i_inode.i_uid, ip->i_inode.i_gid); | |
694 | - if (error) | |
695 | - goto out_gunlock_q; | |
696 | 692 | |
697 | 693 | al->al_requested = blks; |
698 | 694 |
fs/gfs2/ops_address.c
... | ... | @@ -653,13 +653,9 @@ |
653 | 653 | goto out_unlock; |
654 | 654 | } |
655 | 655 | |
656 | - error = gfs2_quota_lock(ip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE); | |
656 | + error = gfs2_quota_lock_check(ip); | |
657 | 657 | if (error) |
658 | 658 | goto out_alloc_put; |
659 | - | |
660 | - error = gfs2_quota_check(ip, ip->i_inode.i_uid, ip->i_inode.i_gid); | |
661 | - if (error) | |
662 | - goto out_qunlock; | |
663 | 659 | |
664 | 660 | al->al_requested = data_blocks + ind_blocks; |
665 | 661 | error = gfs2_inplace_reserve(ip); |
fs/gfs2/ops_file.c
... | ... | @@ -369,12 +369,9 @@ |
369 | 369 | if (al == NULL) |
370 | 370 | goto out_unlock; |
371 | 371 | |
372 | - ret = gfs2_quota_lock(ip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE); | |
372 | + ret = gfs2_quota_lock_check(ip); | |
373 | 373 | if (ret) |
374 | 374 | goto out_alloc_put; |
375 | - ret = gfs2_quota_check(ip, ip->i_inode.i_uid, ip->i_inode.i_gid); | |
376 | - if (ret) | |
377 | - goto out_quota_unlock; | |
378 | 375 | al->al_requested = data_blocks + ind_blocks; |
379 | 376 | ret = gfs2_inplace_reserve(ip); |
380 | 377 | if (ret) |
fs/gfs2/ops_inode.c
... | ... | @@ -205,14 +205,10 @@ |
205 | 205 | goto out_gunlock; |
206 | 206 | } |
207 | 207 | |
208 | - error = gfs2_quota_lock(dip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE); | |
208 | + error = gfs2_quota_lock_check(dip); | |
209 | 209 | if (error) |
210 | 210 | goto out_alloc; |
211 | 211 | |
212 | - error = gfs2_quota_check(dip, dip->i_inode.i_uid, dip->i_inode.i_gid); | |
213 | - if (error) | |
214 | - goto out_gunlock_q; | |
215 | - | |
216 | 212 | al->al_requested = sdp->sd_max_dirres; |
217 | 213 | |
218 | 214 | error = gfs2_inplace_reserve(dip); |
219 | 215 | |
... | ... | @@ -725,13 +721,9 @@ |
725 | 721 | goto out_gunlock; |
726 | 722 | } |
727 | 723 | |
728 | - error = gfs2_quota_lock(ndip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE); | |
724 | + error = gfs2_quota_lock_check(ndip); | |
729 | 725 | if (error) |
730 | 726 | goto out_alloc; |
731 | - | |
732 | - error = gfs2_quota_check(ndip, ndip->i_inode.i_uid, ndip->i_inode.i_gid); | |
733 | - if (error) | |
734 | - goto out_gunlock_q; | |
735 | 727 | |
736 | 728 | al->al_requested = sdp->sd_max_dirres; |
737 | 729 |
fs/gfs2/quota.h
... | ... | @@ -32,5 +32,22 @@ |
32 | 32 | void gfs2_quota_scan(struct gfs2_sbd *sdp); |
33 | 33 | void gfs2_quota_cleanup(struct gfs2_sbd *sdp); |
34 | 34 | |
35 | +static inline int gfs2_quota_lock_check(struct gfs2_inode *ip) | |
36 | +{ | |
37 | + struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); | |
38 | + int ret; | |
39 | + if (sdp->sd_args.ar_quota == GFS2_QUOTA_OFF) | |
40 | + return 0; | |
41 | + ret = gfs2_quota_lock(ip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE); | |
42 | + if (ret) | |
43 | + return ret; | |
44 | + if (sdp->sd_args.ar_quota != GFS2_QUOTA_ON) | |
45 | + return 0; | |
46 | + ret = gfs2_quota_check(ip, ip->i_inode.i_uid, ip->i_inode.i_gid); | |
47 | + if (ret) | |
48 | + gfs2_quota_unlock(ip); | |
49 | + return ret; | |
50 | +} | |
51 | + | |
35 | 52 | #endif /* __QUOTA_DOT_H__ */ |