aboutsummaryrefslogtreecommitdiffstats
path: root/fs/gfs2/rgrp.c
diff options
context:
space:
mode:
authorBob Peterson <rpeterso@redhat.com>2015-07-16 09:28:04 -0400
committerBob Peterson <rpeterso@redhat.com>2015-12-14 13:16:38 -0500
commita097dc7e24cba7980bc5e2df461a4ef228e97e59 (patch)
treebfe9075d7d759fe136d540cea595dfbc4c81f361 /fs/gfs2/rgrp.c
parentb54e9a0b92d44843f6719ae22b0f6daf5b9b23b4 (diff)
GFS2: Make rgrp reservations part of the gfs2_inode structure
Before this patch, multi-block reservation structures were allocated from a special slab. This patch folds the structure into the gfs2_inode structure. The disadvantage is that the gfs2_inode needs more memory, even when a file is opened read-only. The advantages are: (a) we don't need the special slab and the extra time it takes to allocate and deallocate from it. (b) we no longer need to worry that the structure exists for things like quota management. (c) This also allows us to remove the calls to get_write_access and put_write_access since we know the structure will exist. Signed-off-by: Bob Peterson <rpeterso@redhat.com>
Diffstat (limited to 'fs/gfs2/rgrp.c')
-rw-r--r--fs/gfs2/rgrp.c52
1 files changed, 14 insertions, 38 deletions
diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c
index cb30748e7b19..b879925ce134 100644
--- a/fs/gfs2/rgrp.c
+++ b/fs/gfs2/rgrp.c
@@ -602,28 +602,7 @@ void gfs2_free_clones(struct gfs2_rgrpd *rgd)
602 */ 602 */
603int gfs2_rsqa_alloc(struct gfs2_inode *ip) 603int gfs2_rsqa_alloc(struct gfs2_inode *ip)
604{ 604{
605 int error = 0; 605 return gfs2_qa_alloc(ip);
606
607 down_write(&ip->i_rw_mutex);
608 if (ip->i_res)
609 goto out;
610
611 ip->i_res = kmem_cache_zalloc(gfs2_rsrv_cachep, GFP_NOFS);
612 if (!ip->i_res) {
613 error = -ENOMEM;
614 goto out;
615 }
616
617 RB_CLEAR_NODE(&ip->i_res->rs_node);
618 error = gfs2_qa_alloc(ip);
619 if (error) {
620 kmem_cache_free(gfs2_rsrv_cachep, ip->i_res);
621 ip->i_res = NULL;
622 }
623
624out:
625 up_write(&ip->i_rw_mutex);
626 return error;
627} 606}
628 607
629static void dump_rs(struct seq_file *seq, const struct gfs2_blkreserv *rs) 608static void dump_rs(struct seq_file *seq, const struct gfs2_blkreserv *rs)
@@ -693,15 +672,12 @@ void gfs2_rs_deltree(struct gfs2_blkreserv *rs)
693void gfs2_rsqa_delete(struct gfs2_inode *ip, atomic_t *wcount) 672void gfs2_rsqa_delete(struct gfs2_inode *ip, atomic_t *wcount)
694{ 673{
695 down_write(&ip->i_rw_mutex); 674 down_write(&ip->i_rw_mutex);
696 if (ip->i_res && ((wcount == NULL) || (atomic_read(wcount) <= 1))) { 675 if ((wcount == NULL) || (atomic_read(wcount) <= 1)) {
697 gfs2_rs_deltree(ip->i_res); 676 gfs2_rs_deltree(&ip->i_res);
698 BUG_ON(ip->i_res->rs_free); 677 BUG_ON(ip->i_res.rs_free);
699 kmem_cache_free(gfs2_rsrv_cachep, ip->i_res);
700 ip->i_res = NULL;
701
702 gfs2_qa_delete(ip);
703 } 678 }
704 up_write(&ip->i_rw_mutex); 679 up_write(&ip->i_rw_mutex);
680 gfs2_qa_delete(ip, wcount);
705} 681}
706 682
707/** 683/**
@@ -1465,7 +1441,7 @@ static void rs_insert(struct gfs2_inode *ip)
1465{ 1441{
1466 struct rb_node **newn, *parent = NULL; 1442 struct rb_node **newn, *parent = NULL;
1467 int rc; 1443 int rc;
1468 struct gfs2_blkreserv *rs = ip->i_res; 1444 struct gfs2_blkreserv *rs = &ip->i_res;
1469 struct gfs2_rgrpd *rgd = rs->rs_rbm.rgd; 1445 struct gfs2_rgrpd *rgd = rs->rs_rbm.rgd;
1470 u64 fsblock = gfs2_rbm_to_block(&rs->rs_rbm); 1446 u64 fsblock = gfs2_rbm_to_block(&rs->rs_rbm);
1471 1447
@@ -1512,7 +1488,7 @@ static void rg_mblk_search(struct gfs2_rgrpd *rgd, struct gfs2_inode *ip,
1512{ 1488{
1513 struct gfs2_rbm rbm = { .rgd = rgd, }; 1489 struct gfs2_rbm rbm = { .rgd = rgd, };
1514 u64 goal; 1490 u64 goal;
1515 struct gfs2_blkreserv *rs = ip->i_res; 1491 struct gfs2_blkreserv *rs = &ip->i_res;
1516 u32 extlen; 1492 u32 extlen;
1517 u32 free_blocks = rgd->rd_free_clone - rgd->rd_reserved; 1493 u32 free_blocks = rgd->rd_free_clone - rgd->rd_reserved;
1518 int ret; 1494 int ret;
@@ -1583,7 +1559,7 @@ static u64 gfs2_next_unreserved_block(struct gfs2_rgrpd *rgd, u64 block,
1583 } 1559 }
1584 1560
1585 if (n) { 1561 if (n) {
1586 while ((rs_cmp(block, length, rs) == 0) && (ip->i_res != rs)) { 1562 while ((rs_cmp(block, length, rs) == 0) && (&ip->i_res != rs)) {
1587 block = gfs2_rbm_to_block(&rs->rs_rbm) + rs->rs_free; 1563 block = gfs2_rbm_to_block(&rs->rs_rbm) + rs->rs_free;
1588 n = n->rb_right; 1564 n = n->rb_right;
1589 if (n == NULL) 1565 if (n == NULL)
@@ -1993,7 +1969,7 @@ int gfs2_inplace_reserve(struct gfs2_inode *ip, struct gfs2_alloc_parms *ap)
1993{ 1969{
1994 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); 1970 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
1995 struct gfs2_rgrpd *begin = NULL; 1971 struct gfs2_rgrpd *begin = NULL;
1996 struct gfs2_blkreserv *rs = ip->i_res; 1972 struct gfs2_blkreserv *rs = &ip->i_res;
1997 int error = 0, rg_locked, flags = 0; 1973 int error = 0, rg_locked, flags = 0;
1998 u64 last_unlinked = NO_BLOCK; 1974 u64 last_unlinked = NO_BLOCK;
1999 int loops = 0; 1975 int loops = 0;
@@ -2122,7 +2098,7 @@ next_rgrp:
2122 2098
2123void gfs2_inplace_release(struct gfs2_inode *ip) 2099void gfs2_inplace_release(struct gfs2_inode *ip)
2124{ 2100{
2125 struct gfs2_blkreserv *rs = ip->i_res; 2101 struct gfs2_blkreserv *rs = &ip->i_res;
2126 2102
2127 if (rs->rs_rgd_gh.gh_gl) 2103 if (rs->rs_rgd_gh.gh_gl)
2128 gfs2_glock_dq_uninit(&rs->rs_rgd_gh); 2104 gfs2_glock_dq_uninit(&rs->rs_rgd_gh);
@@ -2276,7 +2252,7 @@ static void gfs2_rgrp_error(struct gfs2_rgrpd *rgd)
2276static void gfs2_adjust_reservation(struct gfs2_inode *ip, 2252static void gfs2_adjust_reservation(struct gfs2_inode *ip,
2277 const struct gfs2_rbm *rbm, unsigned len) 2253 const struct gfs2_rbm *rbm, unsigned len)
2278{ 2254{
2279 struct gfs2_blkreserv *rs = ip->i_res; 2255 struct gfs2_blkreserv *rs = &ip->i_res;
2280 struct gfs2_rgrpd *rgd = rbm->rgd; 2256 struct gfs2_rgrpd *rgd = rbm->rgd;
2281 unsigned rlen; 2257 unsigned rlen;
2282 u64 block; 2258 u64 block;
@@ -2319,8 +2295,8 @@ static void gfs2_set_alloc_start(struct gfs2_rbm *rbm,
2319{ 2295{
2320 u64 goal; 2296 u64 goal;
2321 2297
2322 if (gfs2_rs_active(ip->i_res)) { 2298 if (gfs2_rs_active(&ip->i_res)) {
2323 *rbm = ip->i_res->rs_rbm; 2299 *rbm = ip->i_res.rs_rbm;
2324 return; 2300 return;
2325 } 2301 }
2326 2302
@@ -2374,7 +2350,7 @@ int gfs2_alloc_blocks(struct gfs2_inode *ip, u64 *bn, unsigned int *nblocks,
2374 gfs2_alloc_extent(&rbm, dinode, nblocks); 2350 gfs2_alloc_extent(&rbm, dinode, nblocks);
2375 block = gfs2_rbm_to_block(&rbm); 2351 block = gfs2_rbm_to_block(&rbm);
2376 rbm.rgd->rd_last_alloc = block - rbm.rgd->rd_data0; 2352 rbm.rgd->rd_last_alloc = block - rbm.rgd->rd_data0;
2377 if (gfs2_rs_active(ip->i_res)) 2353 if (gfs2_rs_active(&ip->i_res))
2378 gfs2_adjust_reservation(ip, &rbm, *nblocks); 2354 gfs2_adjust_reservation(ip, &rbm, *nblocks);
2379 ndata = *nblocks; 2355 ndata = *nblocks;
2380 if (dinode) 2356 if (dinode)