aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Gruenbacher <agruenba@redhat.com>2018-10-04 10:36:02 -0400
committerBob Peterson <rpeterso@redhat.com>2018-10-12 08:33:07 -0400
commit0ddeded4ae768882e5c3a5558f77f27e4e445a6a (patch)
treed32a5bf5e432cf1949cc71cdaf587345fe165f46
parentc3abc29e54a14953ddb26feeb62dd02d57925e52 (diff)
gfs2: Pass resource group to rgblk_free
Function rgblk_free can only deal with one resource group at a time, so pass that resource group is as a parameter. Several of the callers already have the resource group at hand, so we only need additional lookup code in a few places. Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com> Signed-off-by: Bob Peterson <rpeterso@redhat.com> Reviewed-by: Steven Whitehouse <swhiteho@redhat.com>
-rw-r--r--fs/gfs2/bmap.c4
-rw-r--r--fs/gfs2/dir.c5
-rw-r--r--fs/gfs2/rgrp.c44
-rw-r--r--fs/gfs2/rgrp.h6
-rw-r--r--fs/gfs2/xattr.c16
5 files changed, 35 insertions, 40 deletions
diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c
index 03128ed1f34e..5f3ea07ef5e2 100644
--- a/fs/gfs2/bmap.c
+++ b/fs/gfs2/bmap.c
@@ -1566,7 +1566,7 @@ more_rgrps:
1566 continue; 1566 continue;
1567 } 1567 }
1568 if (bstart) { 1568 if (bstart) {
1569 __gfs2_free_blocks(ip, bstart, (u32)blen, meta); 1569 __gfs2_free_blocks(ip, rgd, bstart, (u32)blen, meta);
1570 (*btotal) += blen; 1570 (*btotal) += blen;
1571 gfs2_add_inode_blocks(&ip->i_inode, -blen); 1571 gfs2_add_inode_blocks(&ip->i_inode, -blen);
1572 } 1572 }
@@ -1574,7 +1574,7 @@ more_rgrps:
1574 blen = 1; 1574 blen = 1;
1575 } 1575 }
1576 if (bstart) { 1576 if (bstart) {
1577 __gfs2_free_blocks(ip, bstart, (u32)blen, meta); 1577 __gfs2_free_blocks(ip, rgd, bstart, (u32)blen, meta);
1578 (*btotal) += blen; 1578 (*btotal) += blen;
1579 gfs2_add_inode_blocks(&ip->i_inode, -blen); 1579 gfs2_add_inode_blocks(&ip->i_inode, -blen);
1580 } 1580 }
diff --git a/fs/gfs2/dir.c b/fs/gfs2/dir.c
index 87a6dee88a62..daa14ab4e31b 100644
--- a/fs/gfs2/dir.c
+++ b/fs/gfs2/dir.c
@@ -2042,6 +2042,8 @@ static int leaf_dealloc(struct gfs2_inode *dip, u32 index, u32 len,
2042 bh = leaf_bh; 2042 bh = leaf_bh;
2043 2043
2044 for (blk = leaf_no; blk; blk = nblk) { 2044 for (blk = leaf_no; blk; blk = nblk) {
2045 struct gfs2_rgrpd *rgd;
2046
2045 if (blk != leaf_no) { 2047 if (blk != leaf_no) {
2046 error = get_leaf(dip, blk, &bh); 2048 error = get_leaf(dip, blk, &bh);
2047 if (error) 2049 if (error)
@@ -2052,7 +2054,8 @@ static int leaf_dealloc(struct gfs2_inode *dip, u32 index, u32 len,
2052 if (blk != leaf_no) 2054 if (blk != leaf_no)
2053 brelse(bh); 2055 brelse(bh);
2054 2056
2055 gfs2_free_meta(dip, blk, 1); 2057 rgd = gfs2_blk2rgrpd(sdp, blk, true);
2058 gfs2_free_meta(dip, rgd, blk, 1);
2056 gfs2_add_inode_blocks(&dip->i_inode, -1); 2059 gfs2_add_inode_blocks(&dip->i_inode, -1);
2057 } 2060 }
2058 2061
diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c
index 7fef6789fb92..ffe3032b1043 100644
--- a/fs/gfs2/rgrp.c
+++ b/fs/gfs2/rgrp.c
@@ -2215,28 +2215,21 @@ static void gfs2_alloc_extent(const struct gfs2_rbm *rbm, bool dinode,
2215/** 2215/**
2216 * rgblk_free - Change alloc state of given block(s) 2216 * rgblk_free - Change alloc state of given block(s)
2217 * @sdp: the filesystem 2217 * @sdp: the filesystem
2218 * @rgd: the resource group the blocks are in
2218 * @bstart: the start of a run of blocks to free 2219 * @bstart: the start of a run of blocks to free
2219 * @blen: the length of the block run (all must lie within ONE RG!) 2220 * @blen: the length of the block run (all must lie within ONE RG!)
2220 * @new_state: GFS2_BLKST_XXX the after-allocation block state 2221 * @new_state: GFS2_BLKST_XXX the after-allocation block state
2221 *
2222 * Returns: Resource group containing the block(s)
2223 */ 2222 */
2224 2223
2225static struct gfs2_rgrpd *rgblk_free(struct gfs2_sbd *sdp, u64 bstart, 2224static void rgblk_free(struct gfs2_sbd *sdp, struct gfs2_rgrpd *rgd,
2226 u32 blen, unsigned char new_state) 2225 u64 bstart, u32 blen, unsigned char new_state)
2227{ 2226{
2228 struct gfs2_rbm rbm; 2227 struct gfs2_rbm rbm;
2229 struct gfs2_bitmap *bi, *bi_prev = NULL; 2228 struct gfs2_bitmap *bi, *bi_prev = NULL;
2230 2229
2231 rbm.rgd = gfs2_blk2rgrpd(sdp, bstart, 1); 2230 rbm.rgd = rgd;
2232 if (!rbm.rgd) {
2233 if (gfs2_consist(sdp))
2234 fs_err(sdp, "block = %llu\n", (unsigned long long)bstart);
2235 return NULL;
2236 }
2237
2238 if (WARN_ON_ONCE(gfs2_rbm_from_block(&rbm, bstart))) 2231 if (WARN_ON_ONCE(gfs2_rbm_from_block(&rbm, bstart)))
2239 return NULL; 2232 return;
2240 while (blen--) { 2233 while (blen--) {
2241 bi = rbm_bi(&rbm); 2234 bi = rbm_bi(&rbm);
2242 if (bi != bi_prev) { 2235 if (bi != bi_prev) {
@@ -2253,8 +2246,6 @@ static struct gfs2_rgrpd *rgblk_free(struct gfs2_sbd *sdp, u64 bstart,
2253 gfs2_setbit(&rbm, false, new_state); 2246 gfs2_setbit(&rbm, false, new_state);
2254 gfs2_rbm_incr(&rbm); 2247 gfs2_rbm_incr(&rbm);
2255 } 2248 }
2256
2257 return rbm.rgd;
2258} 2249}
2259 2250
2260/** 2251/**
@@ -2470,20 +2461,19 @@ rgrp_error:
2470/** 2461/**
2471 * __gfs2_free_blocks - free a contiguous run of block(s) 2462 * __gfs2_free_blocks - free a contiguous run of block(s)
2472 * @ip: the inode these blocks are being freed from 2463 * @ip: the inode these blocks are being freed from
2464 * @rgd: the resource group the blocks are in
2473 * @bstart: first block of a run of contiguous blocks 2465 * @bstart: first block of a run of contiguous blocks
2474 * @blen: the length of the block run 2466 * @blen: the length of the block run
2475 * @meta: 1 if the blocks represent metadata 2467 * @meta: 1 if the blocks represent metadata
2476 * 2468 *
2477 */ 2469 */
2478 2470
2479void __gfs2_free_blocks(struct gfs2_inode *ip, u64 bstart, u32 blen, int meta) 2471void __gfs2_free_blocks(struct gfs2_inode *ip, struct gfs2_rgrpd *rgd,
2472 u64 bstart, u32 blen, int meta)
2480{ 2473{
2481 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); 2474 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
2482 struct gfs2_rgrpd *rgd;
2483 2475
2484 rgd = rgblk_free(sdp, bstart, blen, GFS2_BLKST_FREE); 2476 rgblk_free(sdp, rgd, bstart, blen, GFS2_BLKST_FREE);
2485 if (!rgd)
2486 return;
2487 trace_gfs2_block_alloc(ip, rgd, bstart, blen, GFS2_BLKST_FREE); 2477 trace_gfs2_block_alloc(ip, rgd, bstart, blen, GFS2_BLKST_FREE);
2488 rgd->rd_free += blen; 2478 rgd->rd_free += blen;
2489 rgd->rd_flags &= ~GFS2_RGF_TRIMMED; 2479 rgd->rd_flags &= ~GFS2_RGF_TRIMMED;
@@ -2498,16 +2488,18 @@ void __gfs2_free_blocks(struct gfs2_inode *ip, u64 bstart, u32 blen, int meta)
2498/** 2488/**
2499 * gfs2_free_meta - free a contiguous run of data block(s) 2489 * gfs2_free_meta - free a contiguous run of data block(s)
2500 * @ip: the inode these blocks are being freed from 2490 * @ip: the inode these blocks are being freed from
2491 * @rgd: the resource group the blocks are in
2501 * @bstart: first block of a run of contiguous blocks 2492 * @bstart: first block of a run of contiguous blocks
2502 * @blen: the length of the block run 2493 * @blen: the length of the block run
2503 * 2494 *
2504 */ 2495 */
2505 2496
2506void gfs2_free_meta(struct gfs2_inode *ip, u64 bstart, u32 blen) 2497void gfs2_free_meta(struct gfs2_inode *ip, struct gfs2_rgrpd *rgd,
2498 u64 bstart, u32 blen)
2507{ 2499{
2508 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); 2500 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
2509 2501
2510 __gfs2_free_blocks(ip, bstart, blen, 1); 2502 __gfs2_free_blocks(ip, rgd, bstart, blen, 1);
2511 gfs2_statfs_change(sdp, 0, +blen, 0); 2503 gfs2_statfs_change(sdp, 0, +blen, 0);
2512 gfs2_quota_change(ip, -(s64)blen, ip->i_inode.i_uid, ip->i_inode.i_gid); 2504 gfs2_quota_change(ip, -(s64)blen, ip->i_inode.i_uid, ip->i_inode.i_gid);
2513} 2505}
@@ -2519,9 +2511,10 @@ void gfs2_unlink_di(struct inode *inode)
2519 struct gfs2_rgrpd *rgd; 2511 struct gfs2_rgrpd *rgd;
2520 u64 blkno = ip->i_no_addr; 2512 u64 blkno = ip->i_no_addr;
2521 2513
2522 rgd = rgblk_free(sdp, blkno, 1, GFS2_BLKST_UNLINKED); 2514 rgd = gfs2_blk2rgrpd(sdp, blkno, true);
2523 if (!rgd) 2515 if (!rgd)
2524 return; 2516 return;
2517 rgblk_free(sdp, rgd, blkno, 1, GFS2_BLKST_UNLINKED);
2525 trace_gfs2_block_alloc(ip, rgd, blkno, 1, GFS2_BLKST_UNLINKED); 2518 trace_gfs2_block_alloc(ip, rgd, blkno, 1, GFS2_BLKST_UNLINKED);
2526 gfs2_trans_add_meta(rgd->rd_gl, rgd->rd_bits[0].bi_bh); 2519 gfs2_trans_add_meta(rgd->rd_gl, rgd->rd_bits[0].bi_bh);
2527 gfs2_rgrp_out(rgd, rgd->rd_bits[0].bi_bh->b_data); 2520 gfs2_rgrp_out(rgd, rgd->rd_bits[0].bi_bh->b_data);
@@ -2531,13 +2524,8 @@ void gfs2_unlink_di(struct inode *inode)
2531void gfs2_free_di(struct gfs2_rgrpd *rgd, struct gfs2_inode *ip) 2524void gfs2_free_di(struct gfs2_rgrpd *rgd, struct gfs2_inode *ip)
2532{ 2525{
2533 struct gfs2_sbd *sdp = rgd->rd_sbd; 2526 struct gfs2_sbd *sdp = rgd->rd_sbd;
2534 struct gfs2_rgrpd *tmp_rgd;
2535
2536 tmp_rgd = rgblk_free(sdp, ip->i_no_addr, 1, GFS2_BLKST_FREE);
2537 if (!tmp_rgd)
2538 return;
2539 gfs2_assert_withdraw(sdp, rgd == tmp_rgd);
2540 2527
2528 rgblk_free(sdp, rgd, ip->i_no_addr, 1, GFS2_BLKST_FREE);
2541 if (!rgd->rd_dinodes) 2529 if (!rgd->rd_dinodes)
2542 gfs2_consist_rgrpd(rgd); 2530 gfs2_consist_rgrpd(rgd);
2543 rgd->rd_dinodes--; 2531 rgd->rd_dinodes--;
diff --git a/fs/gfs2/rgrp.h b/fs/gfs2/rgrp.h
index 09519ae10fb6..b596c3d17988 100644
--- a/fs/gfs2/rgrp.h
+++ b/fs/gfs2/rgrp.h
@@ -51,8 +51,10 @@ extern int gfs2_alloc_blocks(struct gfs2_inode *ip, u64 *bn, unsigned int *n,
51extern int gfs2_rsqa_alloc(struct gfs2_inode *ip); 51extern int gfs2_rsqa_alloc(struct gfs2_inode *ip);
52extern void gfs2_rs_deltree(struct gfs2_blkreserv *rs); 52extern void gfs2_rs_deltree(struct gfs2_blkreserv *rs);
53extern void gfs2_rsqa_delete(struct gfs2_inode *ip, atomic_t *wcount); 53extern void gfs2_rsqa_delete(struct gfs2_inode *ip, atomic_t *wcount);
54extern void __gfs2_free_blocks(struct gfs2_inode *ip, u64 bstart, u32 blen, int meta); 54extern void __gfs2_free_blocks(struct gfs2_inode *ip, struct gfs2_rgrpd *rgd,
55extern void gfs2_free_meta(struct gfs2_inode *ip, u64 bstart, u32 blen); 55 u64 bstart, u32 blen, int meta);
56extern void gfs2_free_meta(struct gfs2_inode *ip, struct gfs2_rgrpd *rgd,
57 u64 bstart, u32 blen);
56extern void gfs2_free_di(struct gfs2_rgrpd *rgd, struct gfs2_inode *ip); 58extern void gfs2_free_di(struct gfs2_rgrpd *rgd, struct gfs2_inode *ip);
57extern void gfs2_unlink_di(struct inode *inode); 59extern void gfs2_unlink_di(struct inode *inode);
58extern int gfs2_check_blk_type(struct gfs2_sbd *sdp, u64 no_addr, 60extern int gfs2_check_blk_type(struct gfs2_sbd *sdp, u64 no_addr,
diff --git a/fs/gfs2/xattr.c b/fs/gfs2/xattr.c
index e11f77f080a0..996c915a9c97 100644
--- a/fs/gfs2/xattr.c
+++ b/fs/gfs2/xattr.c
@@ -283,7 +283,7 @@ static int ea_dealloc_unstuffed(struct gfs2_inode *ip, struct buffer_head *bh,
283 blen++; 283 blen++;
284 else { 284 else {
285 if (bstart) 285 if (bstart)
286 gfs2_free_meta(ip, bstart, blen); 286 gfs2_free_meta(ip, rgd, bstart, blen);
287 bstart = bn; 287 bstart = bn;
288 blen = 1; 288 blen = 1;
289 } 289 }
@@ -292,7 +292,7 @@ static int ea_dealloc_unstuffed(struct gfs2_inode *ip, struct buffer_head *bh,
292 gfs2_add_inode_blocks(&ip->i_inode, -1); 292 gfs2_add_inode_blocks(&ip->i_inode, -1);
293 } 293 }
294 if (bstart) 294 if (bstart)
295 gfs2_free_meta(ip, bstart, blen); 295 gfs2_free_meta(ip, rgd, bstart, blen);
296 296
297 if (prev && !leave) { 297 if (prev && !leave) {
298 u32 len; 298 u32 len;
@@ -1250,6 +1250,7 @@ static int ea_dealloc_indirect(struct gfs2_inode *ip)
1250{ 1250{
1251 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); 1251 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
1252 struct gfs2_rgrp_list rlist; 1252 struct gfs2_rgrp_list rlist;
1253 struct gfs2_rgrpd *rgd;
1253 struct buffer_head *indbh, *dibh; 1254 struct buffer_head *indbh, *dibh;
1254 __be64 *eablk, *end; 1255 __be64 *eablk, *end;
1255 unsigned int rg_blocks = 0; 1256 unsigned int rg_blocks = 0;
@@ -1302,8 +1303,7 @@ static int ea_dealloc_indirect(struct gfs2_inode *ip)
1302 gfs2_rlist_alloc(&rlist); 1303 gfs2_rlist_alloc(&rlist);
1303 1304
1304 for (x = 0; x < rlist.rl_rgrps; x++) { 1305 for (x = 0; x < rlist.rl_rgrps; x++) {
1305 struct gfs2_rgrpd *rgd = gfs2_glock2rgrp(rlist.rl_ghs[x].gh_gl); 1306 rgd = gfs2_glock2rgrp(rlist.rl_ghs[x].gh_gl);
1306
1307 rg_blocks += rgd->rd_length; 1307 rg_blocks += rgd->rd_length;
1308 } 1308 }
1309 1309
@@ -1320,6 +1320,7 @@ static int ea_dealloc_indirect(struct gfs2_inode *ip)
1320 1320
1321 eablk = (__be64 *)(indbh->b_data + sizeof(struct gfs2_meta_header)); 1321 eablk = (__be64 *)(indbh->b_data + sizeof(struct gfs2_meta_header));
1322 bstart = 0; 1322 bstart = 0;
1323 rgd = NULL;
1323 blen = 0; 1324 blen = 0;
1324 1325
1325 for (; eablk < end; eablk++) { 1326 for (; eablk < end; eablk++) {
@@ -1333,8 +1334,9 @@ static int ea_dealloc_indirect(struct gfs2_inode *ip)
1333 blen++; 1334 blen++;
1334 else { 1335 else {
1335 if (bstart) 1336 if (bstart)
1336 gfs2_free_meta(ip, bstart, blen); 1337 gfs2_free_meta(ip, rgd, bstart, blen);
1337 bstart = bn; 1338 bstart = bn;
1339 rgd = gfs2_blk2rgrpd(sdp, bstart, true);
1338 blen = 1; 1340 blen = 1;
1339 } 1341 }
1340 1342
@@ -1342,7 +1344,7 @@ static int ea_dealloc_indirect(struct gfs2_inode *ip)
1342 gfs2_add_inode_blocks(&ip->i_inode, -1); 1344 gfs2_add_inode_blocks(&ip->i_inode, -1);
1343 } 1345 }
1344 if (bstart) 1346 if (bstart)
1345 gfs2_free_meta(ip, bstart, blen); 1347 gfs2_free_meta(ip, rgd, bstart, blen);
1346 1348
1347 ip->i_diskflags &= ~GFS2_DIF_EA_INDIRECT; 1349 ip->i_diskflags &= ~GFS2_DIF_EA_INDIRECT;
1348 1350
@@ -1391,7 +1393,7 @@ static int ea_dealloc_block(struct gfs2_inode *ip)
1391 if (error) 1393 if (error)
1392 goto out_gunlock; 1394 goto out_gunlock;
1393 1395
1394 gfs2_free_meta(ip, ip->i_eattr, 1); 1396 gfs2_free_meta(ip, rgd, ip->i_eattr, 1);
1395 1397
1396 ip->i_eattr = 0; 1398 ip->i_eattr = 0;
1397 gfs2_add_inode_blocks(&ip->i_inode, -1); 1399 gfs2_add_inode_blocks(&ip->i_inode, -1);