aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Schmidt <patrick.schmidt@innogames.com>2023-03-15 20:37:25 +0100
committerGitHub <noreply@github.com>2023-03-15 12:37:25 -0700
commit71b33faef0925307880cf6752f1825efb2a96430 (patch)
tree8adec187322552d4116d1e70fbcfbf5f5446455f
parentf5854d13df2a46296c857005bb51e163fc20d4af (diff)
downloadseaweedfs-71b33faef0925307880cf6752f1825efb2a96430.tar.xz
seaweedfs-71b33faef0925307880cf6752f1825efb2a96430.zip
Skip parent directory creation in mount (#4310)
A POSIX filesystem does not implicitly create parent directories when they do not exist. Directories must be explicitly created and permissions be set. This also fixes a bug where asynchronous operations would create a file in the filer before the parent directory was created. If the file was a symlink or another special type of file the directory would inherit that type and become unusable in the mounted FS.
-rw-r--r--weed/mount/weedfs_dir_mkrm.go17
-rw-r--r--weed/mount/weedfs_link.go9
-rw-r--r--weed/mount/weedfs_symlink.go11
3 files changed, 23 insertions, 14 deletions
diff --git a/weed/mount/weedfs_dir_mkrm.go b/weed/mount/weedfs_dir_mkrm.go
index 9f03d81c2..e69c9796e 100644
--- a/weed/mount/weedfs_dir_mkrm.go
+++ b/weed/mount/weedfs_dir_mkrm.go
@@ -3,14 +3,16 @@ package mount
import (
"context"
"fmt"
- "github.com/hanwen/go-fuse/v2/fuse"
- "github.com/seaweedfs/seaweedfs/weed/filer"
- "github.com/seaweedfs/seaweedfs/weed/glog"
- "github.com/seaweedfs/seaweedfs/weed/pb/filer_pb"
"os"
"strings"
"syscall"
"time"
+
+ "github.com/hanwen/go-fuse/v2/fuse"
+
+ "github.com/seaweedfs/seaweedfs/weed/filer"
+ "github.com/seaweedfs/seaweedfs/weed/glog"
+ "github.com/seaweedfs/seaweedfs/weed/pb/filer_pb"
)
/** Create a directory
@@ -54,9 +56,10 @@ func (wfs *WFS) Mkdir(cancel <-chan struct{}, in *fuse.MkdirIn, name string, out
defer wfs.mapPbIdFromFilerToLocal(newEntry)
request := &filer_pb.CreateEntryRequest{
- Directory: string(dirFullPath),
- Entry: newEntry,
- Signatures: []int32{wfs.signature},
+ Directory: string(dirFullPath),
+ Entry: newEntry,
+ Signatures: []int32{wfs.signature},
+ SkipCheckParentDirectory: true,
}
glog.V(1).Infof("mkdir: %v", request)
diff --git a/weed/mount/weedfs_link.go b/weed/mount/weedfs_link.go
index cfff69dd9..15b7e081e 100644
--- a/weed/mount/weedfs_link.go
+++ b/weed/mount/weedfs_link.go
@@ -2,12 +2,14 @@ package mount
import (
"context"
+ "syscall"
+ "time"
+
"github.com/hanwen/go-fuse/v2/fuse"
+
"github.com/seaweedfs/seaweedfs/weed/filer"
"github.com/seaweedfs/seaweedfs/weed/glog"
"github.com/seaweedfs/seaweedfs/weed/pb/filer_pb"
- "syscall"
- "time"
)
/*
@@ -72,7 +74,8 @@ func (wfs *WFS) Link(cancel <-chan struct{}, in *fuse.LinkIn, name string, out *
HardLinkId: oldEntry.HardLinkId,
HardLinkCounter: oldEntry.HardLinkCounter,
},
- Signatures: []int32{wfs.signature},
+ Signatures: []int32{wfs.signature},
+ SkipCheckParentDirectory: true,
}
// apply changes to the filer, and also apply to local metaCache
diff --git a/weed/mount/weedfs_symlink.go b/weed/mount/weedfs_symlink.go
index e484c88db..8842ec3e6 100644
--- a/weed/mount/weedfs_symlink.go
+++ b/weed/mount/weedfs_symlink.go
@@ -3,13 +3,15 @@ package mount
import (
"context"
"fmt"
+ "os"
+ "syscall"
+ "time"
+
"github.com/hanwen/go-fuse/v2/fuse"
+
"github.com/seaweedfs/seaweedfs/weed/filer"
"github.com/seaweedfs/seaweedfs/weed/glog"
"github.com/seaweedfs/seaweedfs/weed/pb/filer_pb"
- "os"
- "syscall"
- "time"
)
/** Create a symbolic link */
@@ -42,7 +44,8 @@ func (wfs *WFS) Symlink(cancel <-chan struct{}, header *fuse.InHeader, target st
SymlinkTarget: target,
},
},
- Signatures: []int32{wfs.signature},
+ Signatures: []int32{wfs.signature},
+ SkipCheckParentDirectory: true,
}
err := wfs.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {