btrfs: send: fix invalid path for unlink operations after parent orphanization
[sfrench/cifs-2.6.git] / fs / btrfs / send.c
index bd69db72acc5e4b73480d772579dea3d507dfc9d..a2b3c594379d6bb434fdfa4b996bf7ffd3a3c434 100644 (file)
@@ -4064,6 +4064,17 @@ static int process_recorded_refs(struct send_ctx *sctx, int *pending_move)
                                if (ret < 0)
                                        goto out;
                        } else {
+                               /*
+                                * If we previously orphanized a directory that
+                                * collided with a new reference that we already
+                                * processed, recompute the current path because
+                                * that directory may be part of the path.
+                                */
+                               if (orphanized_dir) {
+                                       ret = refresh_ref_path(sctx, cur);
+                                       if (ret < 0)
+                                               goto out;
+                               }
                                ret = send_unlink(sctx, cur->full_path);
                                if (ret < 0)
                                        goto out;