]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
[GFS2] Streamline quota lock/check for no-quota case
authorSteven Whitehouse <swhiteho@redhat.com>
Mon, 10 Mar 2008 15:34:50 +0000 (15:34 +0000)
committerSteven Whitehouse <swhiteho@redhat.com>
Mon, 31 Mar 2008 09:41:36 +0000 (10:41 +0100)
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>
fs/gfs2/bmap.c
fs/gfs2/eattr.c
fs/gfs2/ops_address.c
fs/gfs2/ops_file.c
fs/gfs2/ops_inode.c
fs/gfs2/quota.h

index f7093aa69aae93c46f5cf13abf6e5343dfeb82ff..c19184f2e70e53f268c757dd77d6a481b6f8604d 100644 (file)
@@ -903,14 +903,10 @@ static int do_grow(struct gfs2_inode *ip, u64 size)
        if (!al)
                return -ENOMEM;
 
-       error = gfs2_quota_lock(ip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE);
+       error = gfs2_quota_lock_check(ip);
        if (error)
                goto out;
 
-       error = gfs2_quota_check(ip, ip->i_inode.i_uid, ip->i_inode.i_gid);
-       if (error)
-               goto out_gunlock_q;
-
        al->al_requested = sdp->sd_max_height + RES_DATA;
 
        error = gfs2_inplace_reserve(ip);
index 288d5e6ad93ac1b3637c6c40920dd93ea723ba46..81755925a755b6b284d95a72b7d7557331067c88 100644 (file)
@@ -686,14 +686,10 @@ static int ea_alloc_skeleton(struct gfs2_inode *ip, struct gfs2_ea_request *er,
        if (!al)
                return -ENOMEM;
 
-       error = gfs2_quota_lock(ip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE);
+       error = gfs2_quota_lock_check(ip);
        if (error)
                goto out;
 
-       error = gfs2_quota_check(ip, ip->i_inode.i_uid, ip->i_inode.i_gid);
-       if (error)
-               goto out_gunlock_q;
-
        al->al_requested = blks;
 
        error = gfs2_inplace_reserve(ip);
index e72fd47d71eb3ff84ea57f68b6bcae0e27b62148..90a04a6e3789179ce7737ca5da9227b41167c334 100644 (file)
@@ -653,14 +653,10 @@ static int gfs2_write_begin(struct file *file, struct address_space *mapping,
                        goto out_unlock;
                }
 
-               error = gfs2_quota_lock(ip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE);
+               error = gfs2_quota_lock_check(ip);
                if (error)
                        goto out_alloc_put;
 
-               error = gfs2_quota_check(ip, ip->i_inode.i_uid, ip->i_inode.i_gid);
-               if (error)
-                       goto out_qunlock;
-
                al->al_requested = data_blocks + ind_blocks;
                error = gfs2_inplace_reserve(ip);
                if (error)
index 2b25a5f7a1c7efe0fbd6b95412a6fe1d21cd5cd9..e1b7d525a06613f83abb239478cd0d8b8e09bb18 100644 (file)
@@ -369,12 +369,9 @@ static int gfs2_page_mkwrite(struct vm_area_struct *vma, struct page *page)
        if (al == NULL)
                goto out_unlock;
 
-       ret = gfs2_quota_lock(ip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE);
+       ret = gfs2_quota_lock_check(ip);
        if (ret)
                goto out_alloc_put;
-       ret = gfs2_quota_check(ip, ip->i_inode.i_uid, ip->i_inode.i_gid);
-       if (ret)
-               goto out_quota_unlock;
        al->al_requested = data_blocks + ind_blocks;
        ret = gfs2_inplace_reserve(ip);
        if (ret)
index 34fe571e15ee2cf482a503b8ffe9fad2c0090642..2686ad4c0029acd2ce1cdfdf46e3d29985a77143 100644 (file)
@@ -205,14 +205,10 @@ static int gfs2_link(struct dentry *old_dentry, struct inode *dir,
                        goto out_gunlock;
                }
 
-               error = gfs2_quota_lock(dip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE);
+               error = gfs2_quota_lock_check(dip);
                if (error)
                        goto out_alloc;
 
-               error = gfs2_quota_check(dip, dip->i_inode.i_uid, dip->i_inode.i_gid);
-               if (error)
-                       goto out_gunlock_q;
-
                al->al_requested = sdp->sd_max_dirres;
 
                error = gfs2_inplace_reserve(dip);
@@ -725,14 +721,10 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry,
                        goto out_gunlock;
                }
 
-               error = gfs2_quota_lock(ndip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE);
+               error = gfs2_quota_lock_check(ndip);
                if (error)
                        goto out_alloc;
 
-               error = gfs2_quota_check(ndip, ndip->i_inode.i_uid, ndip->i_inode.i_gid);
-               if (error)
-                       goto out_gunlock_q;
-
                al->al_requested = sdp->sd_max_dirres;
 
                error = gfs2_inplace_reserve(ndip);
index a8be1417051f9bf07823c3b885a94b3f0e4e9aa4..3b7f4b0e5dfe0fee9e155f01f2fc3fa224ddabfc 100644 (file)
@@ -32,4 +32,21 @@ int gfs2_quota_init(struct gfs2_sbd *sdp);
 void gfs2_quota_scan(struct gfs2_sbd *sdp);
 void gfs2_quota_cleanup(struct gfs2_sbd *sdp);
 
+static inline int gfs2_quota_lock_check(struct gfs2_inode *ip)
+{
+       struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
+       int ret;
+       if (sdp->sd_args.ar_quota == GFS2_QUOTA_OFF)
+               return 0;
+       ret = gfs2_quota_lock(ip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE);
+       if (ret)
+               return ret;
+       if (sdp->sd_args.ar_quota != GFS2_QUOTA_ON)
+               return 0;
+       ret = gfs2_quota_check(ip, ip->i_inode.i_uid, ip->i_inode.i_gid);
+       if (ret)
+               gfs2_quota_unlock(ip);
+       return ret;
+}
+
 #endif /* __QUOTA_DOT_H__ */