[Ocfs2-tools-devel] [PATCH 3/4] defrag.ocfs2: Pass 2: Clear unused inode groups and extent block

Joel Becker Joel.Becker at oracle.com
Mon Jul 19 11:19:26 PDT 2010


On Tue, May 11, 2010 at 11:02:38PM -0500, Goldwyn Rodrigues wrote:
> +		if (gd->bg_blkno != blkno) {
> +			ret = OCFS2_CHAIN_ERROR;
> +			goto out;
> +		}

	Probably not necessary.

> +		verbosef("gd blkno:%"PRIu64" free:%d tot:%d\n",
> +				(uint64_t) gd->bg_blkno, gd->bg_free_bits_count,
> +				gd->bg_bits);
> +
> +		if ((gd->bg_free_bits_count + 1 == gd->bg_bits) &&
> +			ocfs2_test_bit(0, gd->bg_bitmap)) {
> +			/* Clear corresponding in global bitmap */
> +			verbosef("Freeing blkno %lu bits %u size %u\n",
> +					(uint64_t)gd->bg_blkno, gd->bg_bits,
> +					gd->bg_size);
> +			ret = ocfs2_free_clusters(fs, gd->bg_bits,
> +					gd->bg_blkno);

	Make sure you update the chain *before* you free the bits.
Think about what happens if the system crashes in the middle of this
operation.  Currently, you'll have free bits in the global bitmap.  On
reboot, some file might get allocated there and dup with this group
descriptor.  That can cause much more serious corruption.  If you relink
the chain first and then crash, you just have unusable bits in the
bitmap.  fsck will detect them.

Joel

-- 

Life's Little Instruction Book #139

	"Never deprive someone of hope; it might be all they have."

Joel Becker
Consulting Software Developer
Oracle
E-mail: joel.becker at oracle.com
Phone: (650) 506-8127



More information about the Ocfs2-tools-devel mailing list