Skip to content

Commit

Permalink
optimize: resume nydusd processes parallelizilly
Browse files Browse the repository at this point in the history
This patch allows the snapshotter resumes the recovering nydusd daemons parallelizilly in the starting stage.

Signed-off-by: Nan Li <[email protected]>
  • Loading branch information
loheagn committed Aug 9, 2023
1 parent a6f4457 commit d37a00e
Showing 1 changed file with 24 additions and 15 deletions.
39 changes: 24 additions & 15 deletions pkg/filesystem/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"github.com/mohae/deepcopy"
"github.com/opencontainers/go-digest"
"github.com/pkg/errors"
"golang.org/x/sync/errgroup"

"github.com/containerd/containerd/log"
"github.com/containerd/containerd/snapshots"
Expand Down Expand Up @@ -120,22 +121,30 @@ func NewFileSystem(ctx context.Context, opt ...NewFSOpt) (*Filesystem, error) {
}

// Try to bring all persisted and stopped nydusd up and remount Rafs
eg, _ := errgroup.WithContext(context.Background())
for _, d := range recoveringDaemons {
d.ClearVestige()
fsManager, err := fs.getManager(d.States.FsDriver)
if err != nil {
return nil, errors.Wrapf(err, "get filesystem manager for daemon %s", d.States.ID)
}
if err := fsManager.StartDaemon(d); err != nil {
return nil, errors.Wrapf(err, "start daemon %s", d.ID())
}
if err := d.WaitUntilState(types.DaemonStateRunning); err != nil {
return nil, errors.Wrapf(err, "wait for daemon %s", d.ID())
}
if err := d.RecoveredMountInstances(); err != nil {
return nil, errors.Wrapf(err, "recover mounts for daemon %s", d.ID())
}
fs.TryRetainSharedDaemon(d)
d := d
eg.Go(func() error {
d.ClearVestige()
fsManager, err := fs.getManager(d.States.FsDriver)
if err != nil {
return errors.Wrapf(err, "get filesystem manager for daemon %s", d.States.ID)
}
if err := fsManager.StartDaemon(d); err != nil {
return errors.Wrapf(err, "start daemon %s", d.ID())
}
if err := d.WaitUntilState(types.DaemonStateRunning); err != nil {
return errors.Wrapf(err, "wait for daemon %s", d.ID())
}
if err := d.RecoveredMountInstances(); err != nil {
return errors.Wrapf(err, "recover mounts for daemon %s", d.ID())
}
fs.TryRetainSharedDaemon(d)
return nil
})
}
if err := eg.Wait(); err != nil {
return nil, err
}

for _, d := range liveDaemons {
Expand Down

0 comments on commit d37a00e

Please sign in to comment.