On Jan 21 2008 11:46, Chris Mason wrote:
>>
>> So basically I'm looking for functions to:
>> - insert a chunk into a file
>> - delete a chunk from a file
>> - move a chunk from one file into another
>
>Like most filesystems, btrfs stores metadata for extents keyed by the offset 
>into the file.  So, in order to insert one byte in the middle of the file, 
>you have to change all of the extent pointers after that byte in the file by 
>one.   This can be slow, although it is certainly faster than copying all the 
>data.
>
>It is very hard to provide slicing operations in place due to races with 
>truncate.  I'm not eager to dive into all of those corner cases.

Would not it work if we just lock the full inode? In other words...

int btrfs_slicemenice(...)
{
        lock(inode->i_something);
        /* possibly length slice operation */
        slice();
        unlock(inode->i_something);
}

int btrfs_truncate(...)
{
        lock(inode->i_something);
        inode->i_size = smaller;
        more_functions(inode);
        unlock();
}

_______________________________________________
Btrfs-devel mailing list
[email protected]
http://oss.oracle.com/mailman/listinfo/btrfs-devel

Reply via email to