Re: [RFC ONLY 4/8] btrfs: add boilerplate code to insert raid extent

Qu Wenruo
2022-05-17T08:09:24Z

On 2022/5/17 16:05, Johannes Thumshirn wrote:
> On 17/05/2022 10:01, Qu Wenruo wrote:
>>> @@ -6700,6 +6713,12 @@ static void btrfs_end_bio(struct bio *bio)
>>> * go over the max number of errors
>>> */
>>> bio->bi_status = BLK_STS_OK;
>>> +
>>> + if (btrfs_op(bio) == BTRFS_MAP_WRITE &&
>>> + btrfs_need_stripe_tree_update(bioc)) {
>>> + btrfs_get_bioc(bioc);
>>> + schedule_work(&bioc->stripe_update_work);
>> Considering the stripe tree should be a 1:1 map for file extents, can't
>> we do it in btrfs_finish_ordered_io()?
>
> Unfortunately not at the moment. I need the stripes[] array from
> btrfs_io_context to record the per-disk physical locations. Another
> possibility would be to lift this array into btrfs_ordered_extent,
> then it can be done in btrfs_finish_ordered_io().

At least to me, lifting it to btrfs_ordered_extent() seems more reasonable.

One problem is, if we write the stripe to stripe tree, and a trans
committed, but power loss happened before btrfs_finish_ordered_io().

Then we would have an orphan stripe item in stripe tree I guess.

Then we may later hit EEXIST doing other stripe tree operations.

Thanks,
Qu