Merge tag 'ceph-for-6.9-rc1' of https://github.com/ceph/ceph-client
[linux-2.6-block.git] / mm / userfaultfd.c
index a0331ba9ae2a5caf6731a2ceed2daaa9230ffd91..712160cd41ecac1a875ad4afb5b565dddc4bc2f2 100644 (file)
@@ -1017,9 +1017,6 @@ static int move_present_pte(struct mm_struct *mm,
                goto out;
        }
 
-       folio_move_anon_rmap(src_folio, dst_vma);
-       WRITE_ONCE(src_folio->index, linear_page_index(dst_vma, dst_addr));
-
        orig_src_pte = ptep_clear_flush(src_vma, src_addr, src_pte);
        /* Folio got pinned from under us. Put it back and fail the move. */
        if (folio_maybe_dma_pinned(src_folio)) {
@@ -1028,6 +1025,9 @@ static int move_present_pte(struct mm_struct *mm,
                goto out;
        }
 
+       folio_move_anon_rmap(src_folio, dst_vma);
+       WRITE_ONCE(src_folio->index, linear_page_index(dst_vma, dst_addr));
+
        orig_dst_pte = mk_pte(&src_folio->page, dst_vma->vm_page_prot);
        /* Follow mremap() behavior and treat the entry dirty after the move */
        orig_dst_pte = pte_mkwrite(pte_mkdirty(orig_dst_pte), dst_vma);