Skip to content

Commit 6bc0d74

Browse files
authored
Merge pull request #107 from NVIDIA/master
Fixes to problems with reference counting nfs mounts.
2 parents 9f36adf + 586b8b9 commit 6bc0d74

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
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 & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ func (n nfsDriver) Mount(r volume.MountRequest) volume.Response {
6060
if err := run(fmt.Sprintf("grep -c %s /proc/mounts", hostdir)); err != nil {
6161
log.Infof("Existing NFS volume not mounted, force remount.")
6262
} else {
63+
n.mountm.Increment(resolvedName)
6364
return volume.Response{Mountpoint: hostdir}
6465
}
6566
}
@@ -74,10 +75,11 @@ func (n nfsDriver) Mount(r volume.MountRequest) volume.Response {
7475
n.mountm.Create(resolvedName, hostdir, resOpts)
7576
}
7677

78+
n.mountm.Add(resolvedName, hostdir)
79+
7780
if err := n.mountVolume(resolvedName, source, hostdir, n.version); err != nil {
7881
return volume.Response{Err: err.Error()}
7982
}
80-
n.mountm.Add(resolvedName, hostdir)
8183

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

0 commit comments

Comments
 (0)