GFS2: decouple quota allocations from block allocations
This patch separates the code pertaining to allocations into two parts: quota-related information and block reservations. This patch also moves all the block reservation structure allocations to function gfs2_inplace_reserve to simplify the code, and moves the frees to function gfs2_inplace_release. Signed-off-by: Bob Peterson <rpeterso@redhat.com> Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
This commit is contained in:

committed by
Steven Whitehouse

vanhempi
b3e47ca0c2
commit
564e12b115
@@ -321,11 +321,11 @@ static int ea_remove_unstuffed(struct gfs2_inode *ip, struct buffer_head *bh,
|
||||
struct gfs2_ea_header *ea,
|
||||
struct gfs2_ea_header *prev, int leave)
|
||||
{
|
||||
struct gfs2_alloc *al;
|
||||
struct gfs2_qadata *qa;
|
||||
int error;
|
||||
|
||||
al = gfs2_alloc_get(ip);
|
||||
if (!al)
|
||||
qa = gfs2_qadata_get(ip);
|
||||
if (!qa)
|
||||
return -ENOMEM;
|
||||
|
||||
error = gfs2_quota_hold(ip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE);
|
||||
@@ -336,7 +336,7 @@ static int ea_remove_unstuffed(struct gfs2_inode *ip, struct buffer_head *bh,
|
||||
|
||||
gfs2_quota_unhold(ip);
|
||||
out_alloc:
|
||||
gfs2_alloc_put(ip);
|
||||
gfs2_qadata_put(ip);
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -709,21 +709,19 @@ static int ea_alloc_skeleton(struct gfs2_inode *ip, struct gfs2_ea_request *er,
|
||||
unsigned int blks,
|
||||
ea_skeleton_call_t skeleton_call, void *private)
|
||||
{
|
||||
struct gfs2_alloc *al;
|
||||
struct gfs2_qadata *qa;
|
||||
struct buffer_head *dibh;
|
||||
int error;
|
||||
|
||||
al = gfs2_alloc_get(ip);
|
||||
if (!al)
|
||||
qa = gfs2_qadata_get(ip);
|
||||
if (!qa)
|
||||
return -ENOMEM;
|
||||
|
||||
error = gfs2_quota_lock_check(ip);
|
||||
if (error)
|
||||
goto out;
|
||||
|
||||
al->al_requested = blks;
|
||||
|
||||
error = gfs2_inplace_reserve(ip);
|
||||
error = gfs2_inplace_reserve(ip, blks);
|
||||
if (error)
|
||||
goto out_gunlock_q;
|
||||
|
||||
@@ -752,7 +750,7 @@ out_ipres:
|
||||
out_gunlock_q:
|
||||
gfs2_quota_unlock(ip);
|
||||
out:
|
||||
gfs2_alloc_put(ip);
|
||||
gfs2_qadata_put(ip);
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -1436,9 +1434,9 @@ out:
|
||||
static int ea_dealloc_block(struct gfs2_inode *ip)
|
||||
{
|
||||
struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
|
||||
struct gfs2_alloc *al = ip->i_alloc;
|
||||
struct gfs2_rgrpd *rgd;
|
||||
struct buffer_head *dibh;
|
||||
struct gfs2_holder gh;
|
||||
int error;
|
||||
|
||||
rgd = gfs2_blk2rgrpd(sdp, ip->i_eattr);
|
||||
@@ -1447,8 +1445,7 @@ static int ea_dealloc_block(struct gfs2_inode *ip)
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
error = gfs2_glock_nq_init(rgd->rd_gl, LM_ST_EXCLUSIVE, 0,
|
||||
&al->al_rgd_gh);
|
||||
error = gfs2_glock_nq_init(rgd->rd_gl, LM_ST_EXCLUSIVE, 0, &gh);
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
@@ -1472,7 +1469,7 @@ static int ea_dealloc_block(struct gfs2_inode *ip)
|
||||
gfs2_trans_end(sdp);
|
||||
|
||||
out_gunlock:
|
||||
gfs2_glock_dq_uninit(&al->al_rgd_gh);
|
||||
gfs2_glock_dq_uninit(&gh);
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -1485,11 +1482,11 @@ out_gunlock:
|
||||
|
||||
int gfs2_ea_dealloc(struct gfs2_inode *ip)
|
||||
{
|
||||
struct gfs2_alloc *al;
|
||||
struct gfs2_qadata *qa;
|
||||
int error;
|
||||
|
||||
al = gfs2_alloc_get(ip);
|
||||
if (!al)
|
||||
qa = gfs2_qadata_get(ip);
|
||||
if (!qa)
|
||||
return -ENOMEM;
|
||||
|
||||
error = gfs2_quota_hold(ip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE);
|
||||
@@ -1511,7 +1508,7 @@ int gfs2_ea_dealloc(struct gfs2_inode *ip)
|
||||
out_quota:
|
||||
gfs2_quota_unhold(ip);
|
||||
out_alloc:
|
||||
gfs2_alloc_put(ip);
|
||||
gfs2_qadata_put(ip);
|
||||
return error;
|
||||
}
|
||||
|
||||
|
Viittaa uudesa ongelmassa
Block a user