Re: [PATCH RFC 02/19] iommufd: Dirty tracking for io_pagetable

Joao Martins
2022-05-02T11:58:38Z

On 4/30/22 00:51, Baolu Lu wrote:
> On 2022/4/29 05:09, Joao Martins wrote:
>> +int iopt_set_dirty_tracking(struct io_pagetable *iopt,
>> + struct iommu_domain *domain, bool enable)
>> +{
>> + struct iommu_domain *dom;
>> + unsigned long index;
>> + int ret = -EOPNOTSUPP;
>> +
>> + down_write(&iopt->iova_rwsem);
>> + if (!domain) {
>> + down_write(&iopt->domains_rwsem);
>> + xa_for_each(&iopt->domains, index, dom) {
>> + ret = iommu_set_dirty_tracking(dom, iopt, enable);
>> + if (ret < 0)
>> + break;
>
> Do you need to roll back to the original state before return failure?
> Partial domains have already had dirty bit tracking enabled.
>
Yeap, will fix the unwinding for next iteration.

>> + }
>> + up_write(&iopt->domains_rwsem);
>> + } else {
>> + ret = iommu_set_dirty_tracking(domain, iopt, enable);
>> + }
>> +
>> + up_write(&iopt->iova_rwsem);
>> + return ret;
>> +}
>
> Best regards,
> baolu