A new user interface for you! Read more...

File gfs2_edit_fix_memory_leak_in_savemeta_option.patch of Package cluster

commit 8feebc85ef943726de76a59fabedcb323f9dc36a
Author: Bob Peterson <bob@ganesha.(none)>
Date:   Fri Oct 1 08:30:09 2010 -0500

    gfs2_edit: Fix memory leak in savemeta option
    
    The savemeta option of gfs2_edit was not releasing its buffers
    after they were used, so they kept accumulating in memory.
    In large file systems, it was nearly impossible to save the metadata
    because it would run out of memory and start swapping to disk.
    
    rhbz#634623

diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
index e6cc0a2..10658a2 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -33,7 +33,6 @@ struct saved_metablock {
 };
 
 struct saved_metablock *savedata;
-struct gfs2_buffer_head *savebh;
 uint64_t last_fs_block, last_reported_block, blks_saved, total_out, pct;
 uint64_t journal_blocks[MAX_JOURNALS_SAVED];
 uint64_t gfs1_journal_size = 0; /* in blocks */
@@ -198,6 +197,7 @@ static int save_block(int fd, int out_fd, uint64_t blk)
 	int blktype, blklen, outsz;
 	uint16_t trailing0;
 	char *p;
+	struct gfs2_buffer_head *savebh;
 
 	if (blk > last_fs_block) {
 		fprintf(stderr, "\nWarning: bad block pointer '0x%llx' "
@@ -216,8 +216,10 @@ static int save_block(int fd, int out_fd, uint64_t blk)
 	   inode, not the block within the inode "blk". They may or may not
 	   be the same thing. */
 	if (get_gfs_struct_info(savebh, &blktype, &blklen) &&
-	    !block_is_systemfile())
+	    !block_is_systemfile()) {
+		brelse(savebh);
 		return 0; /* Not metadata, and not system file, so skip it */
+	}
 	trailing0 = 0;
 	p = &savedata->buf[blklen - 1];
 	while (*p=='\0' && trailing0 < sbd.bsize) {
@@ -255,6 +257,7 @@ static int save_block(int fd, int out_fd, uint64_t blk)
 	}
 	total_out += sizeof(savedata->blk) + sizeof(savedata->siglen) + outsz;
 	blks_saved++;
+	brelse(savebh);
 	return blktype;
 }