Procházet zdrojové kódy

c8d/diff: Reuse mount, mount parent as read-only

The container rw layer may already be mounted, so it's not safe to use
it in another overlay mount. Use the ref counted mounter (which will
reuse the existing mount if it exists) to avoid that.

Also, mount the parent mounts (layers of the base image) in a read-only
mode.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
(cherry picked from commit 6da42ca8308fccf3ae5be75d599eeda61f7e41ed)
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
Paweł Gronowski před 2 roky
rodič
revize
74bf46aea6
1 změnil soubory, kde provedl 3 přidání a 8 odebrání
  1. 3 8
      daemon/containerd/image_changes.go

+ 3 - 8
daemon/containerd/image_changes.go

@@ -58,15 +58,10 @@ func (i *ImageService) Changes(ctx context.Context, container *container.Contain
 		}
 		}
 	}()
 	}()
 
 
-	mounts, err := snapshotter.Mounts(ctx, container.ID)
-	if err != nil {
-		return nil, err
-	}
-
 	var changes []archive.Change
 	var changes []archive.Change
-	err = mount.WithReadonlyTempMount(ctx, mounts, func(fs string) error {
-		return mount.WithTempMount(ctx, parent, func(root string) error {
-			changes, err = archive.ChangesDirs(fs, root)
+	err = i.PerformWithBaseFS(ctx, container, func(containerRootfs string) error {
+		return mount.WithReadonlyTempMount(ctx, parent, func(parentRootfs string) error {
+			changes, err = archive.ChangesDirs(containerRootfs, parentRootfs)
 			return err
 			return err
 		})
 		})
 	})
 	})