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

Tao Ma tao.ma at oracle.com
Mon Feb 4 06:44:21 PST 2008


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.




More information about the Ocfs2-tools-devel mailing list