Btrfs: incremental send, clear name from cache after orphanization
[firefly-linux-kernel-4.4.55.git] / fs / btrfs / send.c
index 571de5a08fe7996a31e80a8f0766735a6061a397..00cb924884f559dad05a06ab1cf3d11c6a017068 100644 (file)
@@ -3610,10 +3610,27 @@ verbose_printk("btrfs: process_recorded_refs %llu\n", sctx->cur_ino);
                        if (ret < 0)
                                goto out;
                        if (ret) {
+                               struct name_cache_entry *nce;
+
                                ret = orphanize_inode(sctx, ow_inode, ow_gen,
                                                cur->full_path);
                                if (ret < 0)
                                        goto out;
+                               /*
+                                * Make sure we clear our orphanized inode's
+                                * name from the name cache. This is because the
+                                * inode ow_inode might be an ancestor of some
+                                * other inode that will be orphanized as well
+                                * later and has an inode number greater than
+                                * sctx->send_progress. We need to prevent
+                                * future name lookups from using the old name
+                                * and get instead the orphan name.
+                                */
+                               nce = name_cache_search(sctx, ow_inode, ow_gen);
+                               if (nce) {
+                                       name_cache_delete(sctx, nce);
+                                       kfree(nce);
+                               }
                        } else {
                                ret = send_unlink(sctx, cur->full_path);
                                if (ret < 0)