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

Baolu Lu
2022-04-29T23:51:51Z

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.

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

Best regards,
baolu