[Ocfs2-tools-devel] a patch for bitmap_clear_range_generic.

tao.ma tao.ma at oracle.com
Fri Aug 25 00:32:14 PDT 2006


Hi all,
    I found a defect in libocfs2/bitmap.c and prepared a patch for this.
    This defect happens when I want to release a cluster. Although it 
seems that the cluster is released(return value is 0), fsck.ocfs2 find 
that the bit number in global-bitmap is set. So there is a error in 
bitmap releasing.
    After some investigation, I got the following result.
    When "ocfs2_free_clusters" want to release some clusters, the stack 
is like this.
#0  ocfs2_bitmap_clear_range_generic (bitmap=0x96a6288, len=1, 
first_bit=66314) at bitmap.c:749
#1  0x08051be2 in ocfs2_bitmap_clear_range (bitmap=0x96a6288, len=1, 
first_bit=66314) at bitmap.c:164
#2  0x0804bd04 in ocfs2_chain_free_range (fs=0x96a6008, 
cinode=0x96ab808, len=1, start_bit=66314) at chainalloc.c:365
#3  0x0804b160 in ocfs2_free_clusters (fs=0x96a6008, len=1, 
start_blkno=265256) at alloc.c:465
    You can see that when the ocfs2_clear_range_generic is called, the 
first_bit is a global offset of the cluster number.

errcode_t ocfs2_bitmap_clear_range_generic(ocfs2_bitmap *bitmap,
                                           uint64_t len,
                                           uint64_t first_bit)
{
        struct ocfs2_bitmap_region *br;
        uint64_t end;

        br = ocfs2_bitmap_lookup(bitmap, first_bit, len, NULL, NULL, NULL);
        if (!br)
                return OCFS2_ET_INVALID_BIT;

        for (end = first_bit + len; first_bit < end; first_bit++)
                clear_generic_shared(bitmap, br, first_bit + 
br->br_start_bit);

        return 0;
}

The function is quite simple. It will first get the right bitmap region, 
and then call clear_generic_shared to release it. Please note the 
"first_bit" here. Since "first_bit" is already a global offset, not a 
offset in this bitmap region, we don't need to add the start bit of the 
region. So with this wrong bit number, the clusters will not be released 
and the defect happens.

   

<http://www.oracle.com/cdc/>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bitmap_clear_range_generic.patch
Type: text/x-patch
Size: 907 bytes
Desc: not available
Url : http://oss.oracle.com/pipermail/ocfs2-tools-devel/attachments/20060825/0d51ed6a/bitmap_clear_range_generic.bin


More information about the Ocfs2-tools-devel mailing list