[Ocfs2-tools-devel] Re: [Ocfs2-devel] [patch 1/1] offline de-fragmentation tool

wengang wang wen.gang.wang at oracle.com
Mon Feb 4 17:57:44 PST 2008


Tao Ma wrote:
> wengang wang Wrote:
>> Hi Tao Ma,
>>
>> yes, this a demo version:).
>> I put it here just want our experts know it:).  If it's useful, will 
>> commit the well written version :-P
>>
>>>> +static int defrag1_move_data_to_front_on_all_group()
>>>> +{
>>>> +    int res;
>>>> +    struct o2_group *group;
>>>> +    struct o2_file_group *tmp;
>>>> +    int first_free_bit;
>>>> +
>>>> +    group = all_group_list.head;
>>>> +    printf("process in defrag1 ...\n");
>>>> +   +    while ( group) {
>>>> +        //move group 2 only for debug +        printf("defrag1 
>>>> working on group %d/%d...", group->group_num, all_group_list.count);
>>>> +
>>>> +        first_free_bit = get_first_free_bit(group->gd);
>>>> +        if (-1 == first_free_bit) {
>>>> +            //group full
>>>> +            group = group->next;
>>>> +            printf("done.\n");
>>>> +            continue;
>>>> +        }
>>>> +       +        tmp = group->file_group_list.head;
>>>> +        while (tmp) {
>>>> +            res = move_file_group_on_group(group, tmp);
>>>> +            if (res == -1) {
>>>> +                printf("move_file_group_on_group failed. %d\n", res);
>>>> +                return res;
>>>> +            }
>>>> +            tmp = tmp->next_in_group;
>>>> +        }
>>>> +        printf("done.\n");
>>>> +        group = group->next;
>>>> +    }
>>>> +
>>>> +    res = update_all_meta();
>>>>   
>>> You can't do it here. You really should do it immediately after your 
>>> move the cluster in move_file_group_on_group. Otherwise if the 
>>> system panic before this function, all the files' content is corrupted.
>>>
>> this tool needs to be run offline.
> There isn't concerned with online or offline. Even in offline, you 
> can't gurantee that everything is OK in move_file_group_on_group.
> If you run into some error in it, this function return directly and 
> leve the meta untouched. So the data is corrupted.
yea, in case of exception, it has problem.
at very first a version, a modify_file_meta is done just after copying 
data clusters. to speed up the whole process of defrag, changed as now.
while, since  offline defrag is not reasonable, won't make any 
improvements on it.

thanks very much for your review 8-)

wengang.




More information about the Ocfs2-tools-devel mailing list