Skip to content

Commit b2867cf

Browse files
Fixes to problems with reference counting nfs mounts.
1 parent 4bfe7ba commit b2867cf

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

netshare/drivers/mounts.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ func (m *mountManager) Increment(name string) int {
141141

142142
func (m *mountManager) Decrement(name string) int {
143143
c, found := m.mounts[name]
144-
if found {
144+
if found && c.connections > 0 {
145145
c.connections--
146146
}
147147
return 0

netshare/drivers/nfs.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ func (n nfsDriver) Mount(r volume.MountRequest) volume.Response {
5656

5757
if n.mountm.HasMount(resolvedName) && n.mountm.Count(resolvedName) > 0 {
5858
log.Infof("Using existing NFS volume mount: %s", hostdir)
59-
n.mountm.Increment(resolvedName)
6059
if err := run(fmt.Sprintf("mountpoint -q %s", hostdir)); err != nil {
6160
log.Infof("Existing NFS volume not mounted, force remount.")
6261
} else {
62+
n.mountm.Increment(resolvedName)
6363
return volume.Response{Mountpoint: hostdir}
6464
}
6565
}
@@ -74,10 +74,11 @@ func (n nfsDriver) Mount(r volume.MountRequest) volume.Response {
7474
n.mountm.Create(resolvedName, hostdir, resOpts)
7575
}
7676

77+
n.mountm.Add(resolvedName, hostdir)
78+
7779
if err := n.mountVolume(resolvedName, source, hostdir, n.version); err != nil {
7880
return volume.Response{Err: err.Error()}
7981
}
80-
n.mountm.Add(resolvedName, hostdir)
8182

8283
if n.mountm.GetOption(resolvedName, ShareOpt) != "" && n.mountm.GetOptionAsBool(resolvedName, CreateOpt) {
8384
log.Infof("Mount: Share and Create options enabled - using %s as sub-dir mount", resolvedName)

0 commit comments

Comments
 (0)