Skip to content

Commit d82661d

Browse files
committed
[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>
1 parent 860b25d commit d82661d

6 files changed

Lines changed: 23 additions & 29 deletions

File tree

‎fs/gfs2/bmap.c‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -903,14 +903,10 @@ static int do_grow(struct gfs2_inode *ip, u64 size)
903903
if (!al)
904904
return -ENOMEM;
905905

906-
error = gfs2_quota_lock(ip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE);
906+
error = gfs2_quota_lock_check(ip);
907907
if (error)
908908
goto out;
909909

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-
914910
al->al_requested = sdp->sd_max_height + RES_DATA;
915911

916912
error = gfs2_inplace_reserve(ip);

‎fs/gfs2/eattr.c‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -686,14 +686,10 @@ static int ea_alloc_skeleton(struct gfs2_inode *ip, struct gfs2_ea_request *er,
686686
if (!al)
687687
return -ENOMEM;
688688

689-
error = gfs2_quota_lock(ip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE);
689+
error = gfs2_quota_lock_check(ip);
690690
if (error)
691691
goto out;
692692

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-
697693
al->al_requested = blks;
698694

699695
error = gfs2_inplace_reserve(ip);

‎fs/gfs2/ops_address.c‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -653,14 +653,10 @@ static int gfs2_write_begin(struct file *file, struct address_space *mapping,
653653
goto out_unlock;
654654
}
655655

656-
error = gfs2_quota_lock(ip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE);
656+
error = gfs2_quota_lock_check(ip);
657657
if (error)
658658
goto out_alloc_put;
659659

660-
error = gfs2_quota_check(ip, ip->i_inode.i_uid, ip->i_inode.i_gid);
661-
if (error)
662-
goto out_qunlock;
663-
664660
al->al_requested = data_blocks + ind_blocks;
665661
error = gfs2_inplace_reserve(ip);
666662
if (error)

‎fs/gfs2/ops_file.c‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -369,12 +369,9 @@ static int gfs2_page_mkwrite(struct vm_area_struct *vma, struct page *page)
369369
if (al == NULL)
370370
goto out_unlock;
371371

372-
ret = gfs2_quota_lock(ip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE);
372+
ret = gfs2_quota_lock_check(ip);
373373
if (ret)
374374
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;
378375
al->al_requested = data_blocks + ind_blocks;
379376
ret = gfs2_inplace_reserve(ip);
380377
if (ret)

‎fs/gfs2/ops_inode.c‎

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -205,14 +205,10 @@ static int gfs2_link(struct dentry *old_dentry, struct inode *dir,
205205
goto out_gunlock;
206206
}
207207

208-
error = gfs2_quota_lock(dip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE);
208+
error = gfs2_quota_lock_check(dip);
209209
if (error)
210210
goto out_alloc;
211211

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-
216212
al->al_requested = sdp->sd_max_dirres;
217213

218214
error = gfs2_inplace_reserve(dip);
@@ -725,14 +721,10 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry,
725721
goto out_gunlock;
726722
}
727723

728-
error = gfs2_quota_lock(ndip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE);
724+
error = gfs2_quota_lock_check(ndip);
729725
if (error)
730726
goto out_alloc;
731727

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-
736728
al->al_requested = sdp->sd_max_dirres;
737729

738730
error = gfs2_inplace_reserve(ndip);

‎fs/gfs2/quota.h‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,21 @@ int gfs2_quota_init(struct gfs2_sbd *sdp);
3232
void gfs2_quota_scan(struct gfs2_sbd *sdp);
3333
void gfs2_quota_cleanup(struct gfs2_sbd *sdp);
3434

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+
3552
#endif /* __QUOTA_DOT_H__ */

0 commit comments

Comments
 (0)