aboutsummaryrefslogtreecommitdiffstats
path: root/fs/gfs2/quota.c
diff options
context:
space:
mode:
authorBob Peterson <rpeterso@redhat.com>2012-06-06 06:17:59 -0400
committerSteven Whitehouse <swhiteho@redhat.com>2012-06-06 06:17:59 -0400
commit0a305e496059a113f93bdd3ad27a5aaa917fe34d (patch)
treeb0b6ce3997fef4c4e28f598a98e2e08c939414a6 /fs/gfs2/quota.c
parenteea5b5510fc5545d15b69da8e485a7424ae388cf (diff)
GFS2: Extend the life of the reservations
This patch lengthens the lifespan of the reservations structure for inodes. Before, they were allocated and deallocated for every write operation. With this patch, they are allocated when the first write occurs, and deallocated when the last process closes the file. It's more efficient to do it this way because it saves GFS2 a lot of unnecessary allocates and frees. It also gives us more flexibility for the future: (1) we can now fold the qadata structure back into the structure and save those alloc/frees, (2) we can use this for multi-block reservations. Signed-off-by: Bob Peterson <rpeterso@redhat.com> Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Diffstat (limited to 'fs/gfs2/quota.c')
-rw-r--r--fs/gfs2/quota.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/fs/gfs2/quota.c b/fs/gfs2/quota.c
index b97178e7d397..197cc2dade7f 100644
--- a/fs/gfs2/quota.c
+++ b/fs/gfs2/quota.c
@@ -764,6 +764,10 @@ static int do_sync(unsigned int num_qd, struct gfs2_quota_data **qda)
764 unsigned int nalloc = 0, blocks; 764 unsigned int nalloc = 0, blocks;
765 int error; 765 int error;
766 766
767 error = gfs2_rs_alloc(ip);
768 if (error)
769 return error;
770
767 gfs2_write_calc_reserv(ip, sizeof(struct gfs2_quota), 771 gfs2_write_calc_reserv(ip, sizeof(struct gfs2_quota),
768 &data_blocks, &ind_blocks); 772 &data_blocks, &ind_blocks);
769 773
@@ -1549,10 +1553,14 @@ static int gfs2_set_dqblk(struct super_block *sb, int type, qid_t id,
1549 if (error) 1553 if (error)
1550 return error; 1554 return error;
1551 1555
1556 error = gfs2_rs_alloc(ip);
1557 if (error)
1558 goto out_put;
1559
1552 mutex_lock(&ip->i_inode.i_mutex); 1560 mutex_lock(&ip->i_inode.i_mutex);
1553 error = gfs2_glock_nq_init(qd->qd_gl, LM_ST_EXCLUSIVE, 0, &q_gh); 1561 error = gfs2_glock_nq_init(qd->qd_gl, LM_ST_EXCLUSIVE, 0, &q_gh);
1554 if (error) 1562 if (error)
1555 goto out_put; 1563 goto out_unlockput;
1556 error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &i_gh); 1564 error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &i_gh);
1557 if (error) 1565 if (error)
1558 goto out_q; 1566 goto out_q;
@@ -1609,8 +1617,9 @@ out_i:
1609 gfs2_glock_dq_uninit(&i_gh); 1617 gfs2_glock_dq_uninit(&i_gh);
1610out_q: 1618out_q:
1611 gfs2_glock_dq_uninit(&q_gh); 1619 gfs2_glock_dq_uninit(&q_gh);
1612out_put: 1620out_unlockput:
1613 mutex_unlock(&ip->i_inode.i_mutex); 1621 mutex_unlock(&ip->i_inode.i_mutex);
1622out_put:
1614 qd_put(qd); 1623 qd_put(qd);
1615 return error; 1624 return error;
1616} 1625}