commit 0827d8708cef94e2f063a8fd9071f468f7eeec54 Author: Bob Peterson <bob@ganesha.peterson> Date: Mon Jan 25 14:34:16 2010 -0600 fsck.gfs2: Free metadata list memory we don't need This patch modifies function check_metatree so that it frees up metadata from memory for heights it's no longer interested in. This patches a memory leak. rhbz#455300 diff --git a/gfs2/fsck/metawalk.c b/gfs2/fsck/metawalk.c index 9e87b86..6939437 100644 --- a/gfs2/fsck/metawalk.c +++ b/gfs2/fsck/metawalk.c @@ -1311,6 +1311,21 @@ int check_metatree(struct gfs2_inode *ip, struct metawalk_fxns *pass) return error; } + /* Free the metalist buffers from heights we don't need to check. + For the rest we'll free as we check them to save time. + metalist[0] will only have the dinode bh, so we can skip it. */ + for (i = 1; i < height - 1; i++) { + list = &metalist[i]; + while (!osi_list_empty(list)) { + bh = osi_list_entry(list->next, + struct gfs2_buffer_head, b_altlist); + if (bh == ip->i_bh) + osi_list_del(&bh->b_altlist); + else + brelse(bh); + } + } + /* check data blocks */ list = &metalist[height - 1]; if (ip->i_di.di_blocks > COMFORTABLE_BLKS)