mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
change to use fuse file system
This commit is contained in:
parent
45a0fda9bd
commit
180445f5a8
|
@ -11,7 +11,6 @@ import (
|
||||||
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
|
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
|
||||||
"github.com/chrislusf/seaweedfs/weed/security"
|
"github.com/chrislusf/seaweedfs/weed/security"
|
||||||
"github.com/chrislusf/seaweedfs/weed/storage/types"
|
"github.com/chrislusf/seaweedfs/weed/storage/types"
|
||||||
"github.com/hanwen/go-fuse/v2/fs"
|
|
||||||
"github.com/hanwen/go-fuse/v2/fuse"
|
"github.com/hanwen/go-fuse/v2/fuse"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
@ -141,9 +140,7 @@ func RunMount2(option *Mount2Options, umask os.FileMode) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
// mount fuse
|
// mount fuse
|
||||||
sec := time.Second
|
fuseMountOptions := &fuse.MountOptions{
|
||||||
opts := &fs.Options{
|
|
||||||
MountOptions: fuse.MountOptions{
|
|
||||||
AllowOther: *option.allowOthers,
|
AllowOther: *option.allowOthers,
|
||||||
Options: nil,
|
Options: nil,
|
||||||
MaxBackground: 128,
|
MaxBackground: 128,
|
||||||
|
@ -155,26 +152,14 @@ func RunMount2(option *Mount2Options, umask os.FileMode) bool {
|
||||||
Name: "seaweedfs",
|
Name: "seaweedfs",
|
||||||
SingleThreaded: false,
|
SingleThreaded: false,
|
||||||
DisableXAttrs: false,
|
DisableXAttrs: false,
|
||||||
Debug: false,
|
Debug: true,
|
||||||
EnableLocks: false,
|
EnableLocks: false,
|
||||||
ExplicitDataCacheControl: false,
|
ExplicitDataCacheControl: false,
|
||||||
// SyncRead: false, // set to false to enable the FUSE_CAP_ASYNC_READ capability
|
// SyncRead: false, // set to false to enable the FUSE_CAP_ASYNC_READ capability
|
||||||
DirectMount: true,
|
DirectMount: true,
|
||||||
DirectMountFlags: 0,
|
DirectMountFlags: 0,
|
||||||
// EnableAcl: false,
|
// EnableAcl: false,
|
||||||
},
|
|
||||||
EntryTimeout: &sec,
|
|
||||||
AttrTimeout: &sec,
|
|
||||||
NegativeTimeout: nil,
|
|
||||||
FirstAutomaticIno: 0,
|
|
||||||
OnAdd: nil,
|
|
||||||
NullPermissions: false,
|
|
||||||
UID: 0,
|
|
||||||
GID: 0,
|
|
||||||
ServerCallbacks: nil,
|
|
||||||
Logger: nil,
|
|
||||||
}
|
}
|
||||||
opts.Debug = true
|
|
||||||
|
|
||||||
// find mount point
|
// find mount point
|
||||||
mountRoot := filerMountRootPath
|
mountRoot := filerMountRootPath
|
||||||
|
@ -207,7 +192,7 @@ func RunMount2(option *Mount2Options, umask os.FileMode) bool {
|
||||||
UidGidMapper: uidGidMapper,
|
UidGidMapper: uidGidMapper,
|
||||||
})
|
})
|
||||||
|
|
||||||
server, err := fs.Mount(dir, seaweedFileSystem.Root(), opts)
|
server, err := fuse.NewServer(seaweedFileSystem, dir, fuseMountOptions)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Fatalf("Mount fail: %v", err)
|
glog.Fatalf("Mount fail: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -217,7 +202,7 @@ func RunMount2(option *Mount2Options, umask os.FileMode) bool {
|
||||||
|
|
||||||
fmt.Printf("This is SeaweedFS version %s %s %s\n", util.Version(), runtime.GOOS, runtime.GOARCH)
|
fmt.Printf("This is SeaweedFS version %s %s %s\n", util.Version(), runtime.GOOS, runtime.GOARCH)
|
||||||
|
|
||||||
server.Wait()
|
server.Serve()
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,6 +87,10 @@ func (wfs *WFS) Root() *Directory {
|
||||||
return &wfs.root
|
return &wfs.root
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (wfs *WFS) String() string {
|
||||||
|
return "seaweedfs"
|
||||||
|
}
|
||||||
|
|
||||||
func (option *Option) setupUniqueCacheDirectory() {
|
func (option *Option) setupUniqueCacheDirectory() {
|
||||||
cacheUniqueId := util.Md5String([]byte(option.MountDirectory + string(option.FilerAddresses[0]) + option.FilerMountRootPath + util.Version()))[0:8]
|
cacheUniqueId := util.Md5String([]byte(option.MountDirectory + string(option.FilerAddresses[0]) + option.FilerMountRootPath + util.Version()))[0:8]
|
||||||
option.uniqueCacheDir = path.Join(option.CacheDir, cacheUniqueId)
|
option.uniqueCacheDir = path.Join(option.CacheDir, cacheUniqueId)
|
||||||
|
|
|
@ -5,26 +5,19 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/chrislusf/seaweedfs/weed/glog"
|
"github.com/chrislusf/seaweedfs/weed/glog"
|
||||||
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
|
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
|
||||||
"github.com/hanwen/go-fuse/v2/fs"
|
|
||||||
"github.com/hanwen/go-fuse/v2/fuse"
|
"github.com/hanwen/go-fuse/v2/fuse"
|
||||||
"math"
|
"math"
|
||||||
"os"
|
|
||||||
"syscall"
|
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
const blockSize = 512
|
const blockSize = 512
|
||||||
|
|
||||||
var _ = fs.NodeStatfser(&Directory{})
|
|
||||||
|
|
||||||
type statsCache struct {
|
type statsCache struct {
|
||||||
filer_pb.StatisticsResponse
|
filer_pb.StatisticsResponse
|
||||||
lastChecked int64 // unix time in seconds
|
lastChecked int64 // unix time in seconds
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dir *Directory) Statfs(ctx context.Context, out *fuse.StatfsOut) syscall.Errno {
|
func (wfs *WFS) StatFs(cancel <-chan struct{}, in *fuse.InHeader, out *fuse.StatfsOut) (code fuse.Status) {
|
||||||
|
|
||||||
wfs := dir.wfs
|
|
||||||
|
|
||||||
glog.V(4).Infof("reading fs stats")
|
glog.V(4).Infof("reading fs stats")
|
||||||
|
|
||||||
|
@ -56,7 +49,7 @@ func (dir *Directory) Statfs(ctx context.Context, out *fuse.StatfsOut) syscall.E
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.V(0).Infof("filer Statistics: %v", err)
|
glog.V(0).Infof("filer Statistics: %v", err)
|
||||||
return fs.ToErrno(os.ErrInvalid)
|
return fuse.OK
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,5 +76,5 @@ func (dir *Directory) Statfs(ctx context.Context, out *fuse.StatfsOut) syscall.E
|
||||||
out.NameLen = 1024
|
out.NameLen = 1024
|
||||||
out.Frsize = uint32(blockSize)
|
out.Frsize = uint32(blockSize)
|
||||||
|
|
||||||
return fs.OK
|
return fuse.OK
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue