[Ocfs2-tools-devel] Patch for debugfs.ocfs2 icheck command

tao.ma tao.ma at oracle.com
Thu Sep 21 01:37:03 PDT 2006


Hi jie,
1 . I have a file in /tmp/a and two link file /c /d link to /tmp/a.
When I use icheck <block#>, only /tmp/a and /c shows. /d don't shows up.

2. In function find_blkno, there seems to be a memory leak.

>+static int find_blkno(ocfs2_filesys *fs, struct ocfs2_extent_list *el,
>+		      uint64_t blkno)
>+{
>+	struct ocfs2_extent_block *eb;
>+	struct ocfs2_extent_rec *rec;
>+	errcode_t ret = 0;
>+	char *buf = NULL;
>+	int i;
>+	int status = 0;
>+
>+	for (i = 0; i < el->l_next_free_rec; ++i) {
>+		rec = &(el->l_recs[i]);
>+		if (el->l_tree_depth) {
>+			ret = ocfs2_malloc_block(gbls.fs->fs_io, &buf);
>+			if (ret)
>+				goto bail;
>+
>+			ret = ocfs2_read_extent_block(fs, rec->e_blkno,
>+				buf);
>+			if (ret)
>+				goto bail;
>+
>+			eb = (struct ocfs2_extent_block *)buf;
>+
>+			if (find_blkno(fs, &(eb->h_list), blkno)) {
>+				status = 1;
>+				goto bail;
>+			}
>  
>
Here if we don't find blkno, the buf should be released because in next 
loop it will be allocated again.

>+		} else {
>+			if (rec->e_blkno <= blkno && blkno < rec->e_blkno +
>+			    ocfs2_clusters_to_blocks(fs, rec->e_clusters)) {
>+				status = 1;
>+				goto bail;
>+			}
>+		}
>+	}
>+bail:
>+	if (buf)
>+		ocfs2_free(&buf);
>+	return status;
>+}
>+
>+
>  
>








More information about the Ocfs2-tools-devel mailing list