Skip to content

Commit 8bee9dc

Browse files
committed
fix(dedupe): use a common blobs dir to simplify
Currently, our dedupe scheme is very complicated since master copy is kept in one of the repo dirs and if that image is deleted, the owning repo is changed, requiring multiple repo locks causing unnecessary contention.
1 parent 69e58b0 commit 8bee9dc

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

pkg/storage/imagestore/imagestore.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ func (is *ImageStore) PutImageManifest(repo, reference, mediaType string, //noli
633633
}
634634

635635
// write manifest to "blobs"
636-
dir := path.Join(is.rootDir, repo, ispec.ImageBlobsDir, mDigest.Algorithm().String())
636+
dir := path.Join(is.rootDir, "_blobs", mDigest.Algorithm().String())
637637
manifestPath := path.Join(dir, mDigest.Encoded())
638638

639639
binfo, err := is.storeDriver.Stat(manifestPath)
@@ -1017,7 +1017,7 @@ func (is *ImageStore) FinishBlobUpload(repo, uuid string, body io.Reader, dstDig
10171017
return zerr.ErrBadBlobDigest
10181018
}
10191019

1020-
dir := path.Join(is.rootDir, repo, ispec.ImageBlobsDir, dstDigest.Algorithm().String())
1020+
dir := path.Join(is.rootDir, "_blobs", dstDigest.Algorithm().String())
10211021

10221022
err = is.storeDriver.EnsureDir(dir)
10231023
if err != nil {
@@ -1260,7 +1260,8 @@ func (is *ImageStore) DeleteBlobUpload(repo, uuid string) error {
12601260

12611261
// BlobPath returns the repository path of a blob.
12621262
func (is *ImageStore) BlobPath(repo string, digest godigest.Digest) string {
1263-
return path.Join(is.rootDir, repo, ispec.ImageBlobsDir, digest.Algorithm().String(), digest.Encoded())
1263+
repo = "_blobs"
1264+
return path.Join(is.rootDir, repo, digest.Algorithm().String(), digest.Encoded())
12641265
}
12651266

12661267
func (is *ImageStore) GetAllDedupeReposCandidates(digest godigest.Digest) ([]string, error) {

0 commit comments

Comments
 (0)