Skip to content

Commit

Permalink
nfs: support object store and full-featured sync (#3823)
Browse files Browse the repository at this point in the history
close #3702

---------

Signed-off-by: xixi <[email protected]>
Co-authored-by: Davies Liu <[email protected]>
  • Loading branch information
Hexilee and davies authored Oct 7, 2023
1 parent cda20c6 commit 5bf6136
Show file tree
Hide file tree
Showing 6 changed files with 414 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ juicefs: Makefile cmd/*.go pkg/*/*.go go.*
go build -ldflags="$(LDFLAGS)" -o juicefs .

juicefs.lite: Makefile cmd/*.go pkg/*/*.go
go build -tags nogateway,nowebdav,nocos,nobos,nohdfs,noibmcos,noobs,nooss,noqingstor,noscs,nosftp,noswift,noupyun,noazure,nogs,noufile,nob2,nosqlite,nomysql,nopg,notikv,nobadger,noetcd \
go build -tags nogateway,nowebdav,nocos,nobos,nohdfs,noibmcos,noobs,nooss,noqingstor,noscs,nosftp,noswift,noupyun,noazure,nogs,noufile,nob2,nonfs,nosqlite,nomysql,nopg,notikv,nobadger,noetcd \
-ldflags="$(LDFLAGS)" -o juicefs.lite .

juicefs.ceph: Makefile cmd/*.go pkg/*/*.go
Expand Down
2 changes: 2 additions & 0 deletions cmd/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,8 @@ func createSyncStorage(uri string, conf *sync.Config) (object.ObjectStorage, err
if os.Getenv(endpoint) != "" {
conf.Env[endpoint] = os.Getenv(endpoint)
}
} else if name == "nfs" {
endpoint = u.Host + u.Path
} else if !conf.NoHTTPS && supportHTTPS(name, u.Host) {
endpoint = "https://" + u.Host
} else {
Expand Down
8 changes: 8 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ require (
github.com/urfave/cli/v2 v2.19.3
github.com/vbauerster/mpb/v7 v7.0.3
github.com/viki-org/dnscache v0.0.0-20130720023526-c70c1f23c5d8
github.com/vmware/go-nfs-client v0.0.0-20190605212624-d43b92724c1b
github.com/volcengine/ve-tos-golang-sdk/v2 v2.5.3
github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a
go.etcd.io/etcd v3.3.27+incompatible
Expand All @@ -80,6 +81,11 @@ require (
xorm.io/xorm v1.0.7
)

require (
github.com/rasky/go-xdr v0.0.0-20170124162913-1a41d1a06c93 // indirect
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
)

require (
cloud.google.com/go v0.102.1 // indirect
cloud.google.com/go/iam v0.3.0 // indirect
Expand Down Expand Up @@ -258,3 +264,5 @@ replace xorm.io/xorm v1.0.7 => gitea.com/davies/xorm v1.0.8-0.20220528043536-552
replace github.com/huaweicloud/huaweicloud-sdk-go-obs v3.21.12+incompatible => github.com/juicedata/huaweicloud-sdk-go-obs v3.22.12-0.20230228031208-386e87b5c091+incompatible

replace github.com/urfave/cli/v2 v2.19.3 => github.com/juicedata/cli/v2 v2.19.4-0.20230605075551-9c9c5c0dce83

replace github.com/vmware/go-nfs-client v0.0.0-20190605212624-d43b92724c1b => github.com/juicedata/go-nfs-client v0.0.0-20230619072909-36eec939432b
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,8 @@ github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/juicedata/cli/v2 v2.19.4-0.20230605075551-9c9c5c0dce83 h1:RyHTka3jCnTaUqfRYjlwcQlr53aasmkvHEbYLXthqr8=
github.com/juicedata/cli/v2 v2.19.4-0.20230605075551-9c9c5c0dce83/go.mod h1:1CNUng3PtjQMtRzJO4FMXBQvkGtuYRxxiR9xMa7jMwI=
github.com/juicedata/go-nfs-client v0.0.0-20230619072909-36eec939432b h1:tZixumON7boPNeTPBkaD5ObOUJ8DaES4VL17XMrY0BU=
github.com/juicedata/go-nfs-client v0.0.0-20230619072909-36eec939432b/go.mod h1:xOMqi3lOrcGe9uZLnSzgaq94Vc3oz6VPCNDLJUnXpKs=
github.com/juicedata/go-fuse/v2 v2.1.1-0.20230726081302-124dbfa991d7 h1:4evzoVz1/AZfk9tqxWdzVYTMl2dC7VjEJHfaSFDrKS8=
github.com/juicedata/go-fuse/v2 v2.1.1-0.20230726081302-124dbfa991d7/go.mod h1:B1nGE/6RBFyBRC1RRnf23UpwCdyJ31eukw34oAKukAc=
github.com/juicedata/godaemon v0.0.0-20210629045518-3da5144a127d h1:kpQMvNZJKGY3PTt7OSoahYc4nM0HY67SvK0YyS0GLwA=
Expand Down Expand Up @@ -898,6 +900,8 @@ github.com/qiniu/go-sdk/v7 v7.15.0 h1:vkxZZHM2Ed0qHeIx7NF3unXav+guaVIXlEsCCkpQAw
github.com/qiniu/go-sdk/v7 v7.15.0/go.mod h1:nqoYCNo53ZlGA521RvRethvxUDvXKt4gtYXOwye868w=
github.com/qiniu/x v1.10.5/go.mod h1:03Ni9tj+N2h2aKnAz+6N0Xfl8FwMEDRC2PAlxekASDs=
github.com/rainycape/memcache v0.0.0-20150622160815-1031fa0ce2f2/go.mod h1:7tZKcyumwBO6qip7RNQ5r77yrssm9bfCowcLEBcU5IA=
github.com/rasky/go-xdr v0.0.0-20170124162913-1a41d1a06c93 h1:UVArwN/wkKjMVhh2EQGC0tEc1+FqiLlvYXY5mQ2f8Wg=
github.com/rasky/go-xdr v0.0.0-20170124162913-1a41d1a06c93/go.mod h1:Nfe4efndBz4TibWycNE+lqyJZiMX4ycx+QKV8Ta0f/o=
github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
github.com/redis/go-redis/v9 v9.0.2 h1:BA426Zqe/7r56kCcvxYLWe1mkaz71LKF77GwgFzSxfE=
github.com/redis/go-redis/v9 v9.0.2/go.mod h1:/xDTe9EF1LM61hek62Poq2nzQSGj0xSrEtEHbBQevps=
Expand Down
6 changes: 3 additions & 3 deletions pkg/object/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ func (d *filestore) Head(key string) (Object, error) {
if err != nil {
return nil, err
}
return d.toFile(key, fi, false), nil
return toFile(key, fi, false), nil
}

func (d *filestore) toFile(key string, fi fs.FileInfo, isSymlink bool) *file {
func toFile(key string, fi fs.FileInfo, isSymlink bool) *file {
size := fi.Size()
if fi.IsDir() {
size = 0
Expand Down Expand Up @@ -299,7 +299,7 @@ func (d *filestore) List(prefix, marker, delimiter string, limit int64, followLi
continue
}
info := e.Info()
f := d.toFile(key, info, e.isSymlink)
f := toFile(key, info, e.isSymlink)
objs = append(objs, f)
if len(objs) == int(limit) {
break
Expand Down
Loading

0 comments on commit 5bf6136

Please sign in to comment.