aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Whitehouse <swhiteho@redhat.com>2008-03-10 11:34:50 -0400
committerSteven Whitehouse <swhiteho@redhat.com>2008-03-31 05:41:36 -0400
commitd82661d96993ac4efc1d54259ea85ffcd9b8bec6 (patch)
tree0a42b5a3ff34839673e0007fca4335f18078803a
parent860b25d4a913a00331d333f8e207a088c7a1b84a (diff)
[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>
-rw-r--r--fs/gfs2/bmap.c6
-rw-r--r--fs/gfs2/eattr.c6
-rw-r--r--fs/gfs2/ops_address.c6
-rw-r--r--fs/gfs2/ops_file.c5
-rw-r--r--fs/gfs2/ops_inode.c12
-rw-r--r--fs/gfs2/quota.h17
6 files changed, 23 insertions, 29 deletions
diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c
index f7093aa69aae..c19184f2e70e 100644
--- a/fs/gfs2/bmap.c
+++ b/fs/gfs2/bmap.c
@@ -903,14 +903,10 @@ static int do_grow(struct gfs2_inode *ip, u64 size)
903 if (!al) 903 if (!al)
904 return -ENOMEM; 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 if (error) 907 if (error)
908 goto out; 908 goto out;
909 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
914 al->al_requested = sdp->sd_max_height + RES_DATA; 910 al->al_requested = sdp->sd_max_height + RES_DATA;
915 911
916 error = gfs2_inplace_reserve(ip); 912 error = gfs2_inplace_reserve(ip);
diff --git a/fs/gfs2/eattr.c b/fs/gfs2/eattr.c
index 288d5e6ad93a..81755925a755 100644
--- a/fs/gfs2/eattr.c
+++ b/fs/gfs2/eattr.c
@@ -686,14 +686,10 @@ static int ea_alloc_skeleton(struct gfs2_inode *ip, struct gfs2_ea_request *er,
686 if (!al) 686 if (!al)
687 return -ENOMEM; 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 if (error) 690 if (error)
691 goto out; 691 goto out;
692 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
697 al->al_requested = blks; 693 al->al_requested = blks;
698 694
699 error = gfs2_inplace_reserve(ip); 695 error = gfs2_inplace_reserve(ip);
diff --git a/fs/gfs2/ops_address.c b/fs/gfs2/ops_address.c
index e72fd47d71eb..90a04a6e3789 100644
--- a/fs/gfs2/ops_address.c
+++ b/fs/gfs2/ops_address.c
@@ -653,14 +653,10 @@ static int gfs2_write_begin(struct file *file, struct address_space *mapping,
653 goto out_unlock; 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 if (error) 657 if (error)
658 goto out_alloc_put; 658 goto out_alloc_put;
659 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
664 al->al_requested = data_blocks + ind_blocks; 660 al->al_requested = data_blocks + ind_blocks;
665 error = gfs2_inplace_reserve(ip); 661 error = gfs2_inplace_reserve(ip);
666 if (error) 662 if (error)
diff --git a/fs/gfs2/ops_file.c b/fs/gfs2/ops_file.c
index 2b25a5f7a1c7..e1b7d525a066 100644
--- a/fs/gfs2/ops_file.c
+++ b/fs/gfs2/ops_file.c
@@ -369,12 +369,9 @@ static int gfs2_page_mkwrite(struct vm_area_struct *vma, struct page *page)
369 if (al == NULL) 369 if (al == NULL)
370 goto out_unlock; 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 if (ret) 373 if (ret)
374 goto out_alloc_put; 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 al->al_requested = data_blocks + ind_blocks; 375 al->al_requested = data_blocks + ind_blocks;
379 ret = gfs2_inplace_reserve(ip); 376 ret = gfs2_inplace_reserve(ip);
380 if (ret) 377 if (ret)
diff --git a/fs/gfs2/ops_inode.c b/fs/gfs2/ops_inode.c
index 34fe571e15ee..2686ad4c0029 100644
--- a/fs/gfs2/ops_inode.c
+++ b/fs/gfs2/ops_inode.c
@@ -205,14 +205,10 @@ static int gfs2_link(struct dentry *old_dentry, struct inode *dir,
205 goto out_gunlock; 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 if (error) 209 if (error)
210 goto out_alloc; 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 al->al_requested = sdp->sd_max_dirres; 212 al->al_requested = sdp->sd_max_dirres;
217 213
218 error = gfs2_inplace_reserve(dip); 214 error = gfs2_inplace_reserve(dip);
@@ -725,14 +721,10 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry,
725 goto out_gunlock; 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 if (error) 725 if (error)
730 goto out_alloc; 726 goto out_alloc;
731 727
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
736 al->al_requested = sdp->sd_max_dirres; 728 al->al_requested = sdp->sd_max_dirres;
737 729
738 error = gfs2_inplace_reserve(ndip); 730 error = gfs2_inplace_reserve(ndip);
diff --git a/fs/gfs2/quota.h b/fs/gfs2/quota.h
index a8be1417051f..3b7f4b0e5dfe 100644
--- a/fs/gfs2/quota.h
+++ b/fs/gfs2/quota.h
@@ -32,4 +32,21 @@ int gfs2_quota_init(struct gfs2_sbd *sdp);
32void gfs2_quota_scan(struct gfs2_sbd *sdp); 32void gfs2_quota_scan(struct gfs2_sbd *sdp);
33void gfs2_quota_cleanup(struct gfs2_sbd *sdp); 33void gfs2_quota_cleanup(struct gfs2_sbd *sdp);
34 34
35static 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#endif /* __QUOTA_DOT_H__ */ 52#endif /* __QUOTA_DOT_H__ */