Hi Josef,
I hope it's ok to piggy back on this thread for the following question:

I see that in btrfs_cross_ref_exist()=>check_committed_ref() path,
there is the following check:

if (btrfs_extent_generation(leaf, ei) <=
    btrfs_root_last_snapshot(&root->root_item))
        goto out;

So this basically means that after we have taken a snap of a subvol,
then all subvol's extents must be COW'ed, even if we delete the snap a
minute later.
I wonder, why is that so?
Is this because file extents can be shared indirectly, like when we
create a snap, we only COW the root and only mark all root's
*immediate* children shared in the extent tree?
Can the new backref walking code be used here to check more
accurately, if the extent is shared by anybody else?

Thanks,
Alex.



On Mon, Feb 25, 2013 at 9:00 PM, Aastha Mehta <aasth...@gmail.com> wrote:
> Ah okay, I now see how it works. Thanks a lot for your response.
>
> Regards,
> Aastha.
>
>
> On 25 February 2013 18:27, Josef Bacik <jba...@fusionio.com> wrote:
>> On Mon, Feb 25, 2013 at 08:15:40AM -0700, Aastha Mehta wrote:
>>> Thanks again Josef.
>>>
>>> I understood that cow_file_range is called for a regular file. Just to
>>> clarify, in cow_file_range is cow done at the time of reserving
>>> extents in the extent btree for the io to be done in this delalloc? I
>>> see the following comment above find_free_extent() which is called
>>> while trying to reserve extents:
>>>
>>> /*
>>>  * walks the btree of allocated extents and find a hole of a given size.
>>>  * The key ins is changed to record the hole:
>>>  * ins->objectid == block start
>>>  * ins->flags = BTRFS_EXTENT_ITEM_KEY
>>>  * ins->offset == number of blocks
>>>  * Any available blocks before search_start are skipped.
>>>  */
>>>
>>> This seems to be the only place where a cow might be done, because a
>>> key is being inserted into an extent which modifies it.
>>>
>>
>> The key isn't inserted at this time, it's just returned with those values 
>> for us
>> to do as we please.  There is no update of the btree until
>> insert_reserved_extent/btrfs_mark_extent_written in btrfs_finish_ordered_io.
>> Thanks,
>>
>> Josef
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to