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

Tao Ma tao.ma at oracle.com
Mon Feb 4 17:24:01 PST 2008


wengang wang Wrote:
>>> +
>>> +/* find the record --ocfs2_extent_rec, which blkno is 
>>> old_data_blkno, change blkno to +new_data_blkno
>>> +*/
>>> +static inline int modify_file_meta(uint64_t file_blkno, uint64_t 
>>> from_blkno,
>>> +                    uint64_t to_blkno)
>>>   
>> Why go through the file once again? Since you have already iterate 
>> all the files, you may record the information there. So that you 
>> don't need to iterate it now the second time.
> can't hold all meta in memory for memory limitation. have to iterate 
> it again.
You only need to store the blkno and the type(inode or extent block), 
not the whole metadata. They are just a few bytes. You now save an 
extent rec,. so why not add them?
>
>>> +{
>>> +    struct ocfs2_dinode *inode;
>>> +    struct ocfs2_extent_list *el;
>>> +    int res;
>>> +
>>> +    if (!update_disk)
>>> +        return 0;
>>> +
>>> +    res = ocfs2_read_inode2(gbls.fs, file_blkno, 
>>> buf_modify_file_meta);
>>> +    if (res) {
>>> +        printf("ocfs2_read_inode2 %lu, failed. %d\n",file_blkno, res);
>>> +        return -1;
>>> +    }
>>> +    inode = (struct ocfs2_dinode *)buf_modify_file_meta;
>>> +    el= &(inode->id2.i_list);
>>> +
>>> +    res = find_and_change_extent_rec(el, buf_modify_file_meta, 
>>> file_blkno,
>>> +                        1, from_blkno, to_blkno);
>>> +    if (res == 1) {
>>> +        printf("such meta block %lu not found\n", from_blkno);
>>> +    }
>>> +
>>> +    return res;
>>> +}





More information about the Ocfs2-tools-devel mailing list