MCPcopy
hub / github.com/containerd/containerd / Deactivate

Method Deactivate

core/mount/manager/manager.go:707–804  ·  view source on GitHub ↗
(ctx context.Context, name string)

Source from the content-addressed store, hash-verified

705}
706
707func (mm *mountManager) Deactivate(ctx context.Context, name string) error {
708 namespace, err := namespaces.NamespaceRequired(ctx)
709 if err != nil {
710 return err
711 }
712
713 var (
714 mid uint64
715 allActive []mount.ActiveMount
716 )
717
718 // First in a single transaction, mark the mounts as deactivated
719 if err := mm.db.Update(func(tx *bolt.Tx) error {
720 v1bkt := tx.Bucket([]byte("v1"))
721 if v1bkt == nil {
722 return fmt.Errorf("missing v1 bucket: %w", errdefs.ErrNotFound)
723 }
724
725 nsbkt := v1bkt.Bucket([]byte(namespace))
726 if nsbkt == nil {
727 return fmt.Errorf("missing namespace %q bucket: %w", namespace, errdefs.ErrNotFound)
728 }
729
730 mbkt := nsbkt.Bucket(bucketKeyMounts)
731 if mbkt == nil {
732 return fmt.Errorf("missing mounts bucket: %w", errdefs.ErrNotFound)
733 }
734 bkt := mbkt.Bucket([]byte(name))
735 if bkt == nil {
736 return fmt.Errorf("missing mount %q bucket: %w", name, errdefs.ErrNotFound)
737 }
738
739 mid = readID(bkt)
740
741 lid := bkt.Get(bucketKeyLease)
742 if lid != nil {
743 lssbkt := nsbkt.Bucket(bucketKeyLeases)
744 if lssbkt != nil {
745 lsbkt := lssbkt.Bucket(lid)
746 if lsbkt != nil {
747 if err = lsbkt.Delete([]byte(name)); err != nil {
748 return err
749 }
750 }
751 }
752 }
753
754 abkt := bkt.Bucket(bucketKeyActive)
755 if abkt != nil {
756 abkt.ForEachBucket(func(k []byte) error {
757 active, err := readActiveMount(abkt.Bucket(k))
758 if err != nil {
759 return err
760 }
761 allActive = append(allActive, active)
762 return nil
763 })
764 }

Callers

nothing calls this directly

Calls 11

NamespaceRequiredFunction · 0.92
UnmountFunction · 0.92
readActiveMountFunction · 0.85
readIDFunction · 0.70
UpdateMethod · 0.65
GetMethod · 0.65
DeleteMethod · 0.65
UnmountMethod · 0.65
RemoveAllMethod · 0.65
NameMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected