55 "os"
66 "path/filepath"
77
8- log "github.com/sirupsen/logrus"
98 "github.com/docker/go-plugins-helpers/volume"
9+ log "github.com/sirupsen/logrus"
1010)
1111
1212const (
@@ -55,13 +55,15 @@ func (n nfsDriver) Mount(r *volume.MountRequest) (*volume.MountResponse, error)
5555 }
5656 }
5757
58- if n .mountm .HasMount (resolvedName ) && n . mountm . Count ( resolvedName ) > 0 {
58+ if n .mountm .HasMount (resolvedName ) {
5959 log .Infof ("Using existing NFS volume mount: %s" , hostdir )
6060 n .mountm .Increment (resolvedName )
6161 if err := run (fmt .Sprintf ("grep -c %s /proc/mounts" , hostdir )); err != nil {
6262 log .Infof ("Existing NFS volume not mounted, force remount." )
6363 // maintain count
64- n .mountm .Decrement (resolvedName )
64+ if n .mountm .Count (resolvedName ) > 0 {
65+ n .mountm .Decrement (resolvedName )
66+ }
6567 } else {
6668 //n.mountm.Increment(resolvedName)
6769 return & volume.MountResponse {Mountpoint : hostdir }, nil
@@ -71,6 +73,9 @@ func (n nfsDriver) Mount(r *volume.MountRequest) (*volume.MountResponse, error)
7173 log .Infof ("Mounting NFS volume %s on %s" , source , hostdir )
7274
7375 if err := createDest (hostdir ); err != nil {
76+ if n .mountm .Count (resolvedName ) > 0 {
77+ n .mountm .Decrement (resolvedName )
78+ }
7479 return nil , err
7580 }
7681
@@ -81,13 +86,15 @@ func (n nfsDriver) Mount(r *volume.MountRequest) (*volume.MountResponse, error)
8186 n .mountm .Add (resolvedName , hostdir )
8287
8388 if err := n .mountVolume (resolvedName , source , hostdir , n .version ); err != nil {
89+ n .mountm .Decrement (resolvedName )
8490 return nil , err
8591 }
8692
8793 if n .mountm .GetOption (resolvedName , ShareOpt ) != "" && n .mountm .GetOptionAsBool (resolvedName , CreateOpt ) {
8894 log .Infof ("Mount: Share and Create options enabled - using %s as sub-dir mount" , resolvedName )
8995 datavol := filepath .Join (hostdir , resolvedName )
9096 if err := createDest (filepath .Join (hostdir , resolvedName )); err != nil {
97+ n .mountm .Decrement (resolvedName )
9198 return nil , err
9299 }
93100 hostdir = datavol
0 commit comments