mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Parallel migration and optimizations
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
parent
0641429ad8
commit
a8f88ef403
9 changed files with 343 additions and 154 deletions
|
|
@ -196,7 +196,7 @@ func (ls *layerStore) applyTar(tx MetadataTransaction, ts io.Reader, parent stri
|
|||
digester := digest.Canonical.New()
|
||||
tr := io.TeeReader(ts, digester.Hash())
|
||||
|
||||
tsw, err := tx.TarSplitWriter()
|
||||
tsw, err := tx.TarSplitWriter(true)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -572,7 +572,7 @@ func (ls *layerStore) initMount(graphID, parent, mountLabel string, initFunc Mou
|
|||
return initID, nil
|
||||
}
|
||||
|
||||
func (ls *layerStore) assembleTar(graphID string, metadata io.ReadCloser, size *int64) (io.ReadCloser, error) {
|
||||
func (ls *layerStore) assembleTarTo(graphID string, metadata io.ReadCloser, size *int64, w io.Writer) error {
|
||||
type diffPathDriver interface {
|
||||
DiffPath(string) (string, func() error, error)
|
||||
}
|
||||
|
|
@ -582,34 +582,20 @@ func (ls *layerStore) assembleTar(graphID string, metadata io.ReadCloser, size *
|
|||
diffDriver = &naiveDiffPathDriver{ls.driver}
|
||||
}
|
||||
|
||||
defer metadata.Close()
|
||||
|
||||
// get our relative path to the container
|
||||
fsPath, releasePath, err := diffDriver.DiffPath(graphID)
|
||||
if err != nil {
|
||||
metadata.Close()
|
||||
return nil, err
|
||||
return err
|
||||
}
|
||||
defer releasePath()
|
||||
|
||||
pR, pW := io.Pipe()
|
||||
// this will need to be in a goroutine, as we are returning the stream of a
|
||||
// tar archive, but can not close the metadata reader early (when this
|
||||
// function returns)...
|
||||
go func() {
|
||||
defer releasePath()
|
||||
defer metadata.Close()
|
||||
|
||||
metaUnpacker := storage.NewJSONUnpacker(metadata)
|
||||
upackerCounter := &unpackSizeCounter{metaUnpacker, size}
|
||||
fileGetter := storage.NewPathFileGetter(fsPath)
|
||||
logrus.Debugf("Assembling tar data for %s from %s", graphID, fsPath)
|
||||
ots := asm.NewOutputTarStream(fileGetter, upackerCounter)
|
||||
defer ots.Close()
|
||||
if _, err := io.Copy(pW, ots); err != nil {
|
||||
pW.CloseWithError(err)
|
||||
return
|
||||
}
|
||||
pW.Close()
|
||||
}()
|
||||
return pR, nil
|
||||
metaUnpacker := storage.NewJSONUnpacker(metadata)
|
||||
upackerCounter := &unpackSizeCounter{metaUnpacker, size}
|
||||
fileGetter := storage.NewPathFileGetter(fsPath)
|
||||
logrus.Debugf("Assembling tar data for %s from %s", graphID, fsPath)
|
||||
return asm.WriteOutputTarStream(fileGetter, upackerCounter, w)
|
||||
}
|
||||
|
||||
func (ls *layerStore) Cleanup() error {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue