aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBob Peterson <rpeterso@redhat.com>2017-11-22 10:24:14 -0500
committerBob Peterson <rpeterso@redhat.com>2017-11-27 11:47:14 -0500
commita18c78c5f5e39978231cb30f037bdb634cd98f6c (patch)
tree06edaa41478fd8e959f5989e2f985768820bc58d
parent4fbd8d194f06c8a3fd2af1ce560ddb31f7ec8323 (diff)
GFS2: Combine gfs2_free_di with gfs2_free_uninit_di
Before this patch, function gfs2_free_di was 4 lines of code, and one of those lines was to call gfs2_free_uninit_di. Although unlikely, if function gfs2_free_uninit_di encountered an error finding the block to be freed, the error was silently ignored by the caller, which went ahead and improperly did a quota-change operation and meta_wipe despite the error. This patch combines the two functions into one to make the code more readable and fixes the bug by returning from the combined function before it takes those next incorrect steps. Signed-off-by: Bob Peterson <rpeterso@redhat.com>
-rw-r--r--fs/gfs2/rgrp.c10
1 files changed, 2 insertions, 8 deletions
diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c
index 95b2a57ded33..b52c5c3ac445 100644
--- a/fs/gfs2/rgrp.c
+++ b/fs/gfs2/rgrp.c
@@ -2453,12 +2453,12 @@ void gfs2_unlink_di(struct inode *inode)
2453 update_rgrp_lvb_unlinked(rgd, 1); 2453 update_rgrp_lvb_unlinked(rgd, 1);
2454} 2454}
2455 2455
2456static void gfs2_free_uninit_di(struct gfs2_rgrpd *rgd, u64 blkno) 2456void gfs2_free_di(struct gfs2_rgrpd *rgd, struct gfs2_inode *ip)
2457{ 2457{
2458 struct gfs2_sbd *sdp = rgd->rd_sbd; 2458 struct gfs2_sbd *sdp = rgd->rd_sbd;
2459 struct gfs2_rgrpd *tmp_rgd; 2459 struct gfs2_rgrpd *tmp_rgd;
2460 2460
2461 tmp_rgd = rgblk_free(sdp, blkno, 1, GFS2_BLKST_FREE); 2461 tmp_rgd = rgblk_free(sdp, ip->i_no_addr, 1, GFS2_BLKST_FREE);
2462 if (!tmp_rgd) 2462 if (!tmp_rgd)
2463 return; 2463 return;
2464 gfs2_assert_withdraw(sdp, rgd == tmp_rgd); 2464 gfs2_assert_withdraw(sdp, rgd == tmp_rgd);
@@ -2474,12 +2474,6 @@ static void gfs2_free_uninit_di(struct gfs2_rgrpd *rgd, u64 blkno)
2474 update_rgrp_lvb_unlinked(rgd, -1); 2474 update_rgrp_lvb_unlinked(rgd, -1);
2475 2475
2476 gfs2_statfs_change(sdp, 0, +1, -1); 2476 gfs2_statfs_change(sdp, 0, +1, -1);
2477}
2478
2479
2480void gfs2_free_di(struct gfs2_rgrpd *rgd, struct gfs2_inode *ip)
2481{
2482 gfs2_free_uninit_di(rgd, ip->i_no_addr);
2483 trace_gfs2_block_alloc(ip, rgd, ip->i_no_addr, 1, GFS2_BLKST_FREE); 2477 trace_gfs2_block_alloc(ip, rgd, ip->i_no_addr, 1, GFS2_BLKST_FREE);
2484 gfs2_quota_change(ip, -1, ip->i_inode.i_uid, ip->i_inode.i_gid); 2478 gfs2_quota_change(ip, -1, ip->i_inode.i_uid, ip->i_inode.i_gid);
2485 gfs2_meta_wipe(ip, ip->i_no_addr, 1); 2479 gfs2_meta_wipe(ip, ip->i_no_addr, 1);