Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Juicedata
JuiceFS
提交
5c348843
JuiceFS
项目概览
Juicedata
/
JuiceFS
通知
10
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
JuiceFS
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
5c348843
编写于
4月 14, 2021
作者:
D
Davies Liu
提交者:
GitHub
4月 14, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
support case-insensi in Windows (#303)
上级
5d64490e
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
99 addition
and
9 deletion
+99
-9
cmd/mount.go
cmd/mount.go
+5
-1
cmd/mount_windows.go
cmd/mount_windows.go
+4
-1
pkg/meta/redis.go
pkg/meta/redis.go
+56
-4
pkg/meta/redis_test.go
pkg/meta/redis_test.go
+32
-0
pkg/winfsp/winfs.go
pkg/winfsp/winfs.go
+2
-3
未找到文件。
cmd/mount.go
浏览文件 @
5c348843
...
...
@@ -138,7 +138,11 @@ func mount(c *cli.Context) error {
}
logger
.
Infof
(
"Meta address: %s"
,
addr
)
var
rc
=
meta
.
RedisConfig
{
Retries
:
10
,
Strict
:
true
}
var
rc
=
meta
.
RedisConfig
{
Retries
:
10
,
Strict
:
true
,
CaseInsensi
:
strings
.
HasSuffix
(
mp
,
":"
)
&&
runtime
.
GOOS
==
"windows"
,
}
m
,
err
:=
meta
.
NewRedisMeta
(
addr
,
&
rc
)
if
err
!=
nil
{
logger
.
Fatalf
(
"Meta: %s"
,
err
)
...
...
cmd/mount_windows.go
浏览文件 @
5c348843
...
...
@@ -16,6 +16,8 @@
package
main
import
(
"strings"
"github.com/juicedata/juicefs/pkg/chunk"
"github.com/juicedata/juicefs/pkg/fs"
"github.com/juicedata/juicefs/pkg/meta"
...
...
@@ -56,5 +58,6 @@ func mount_main(conf *vfs.Config, m meta.Meta, store chunk.ChunkStore, c *cli.Co
if
err
!=
nil
{
logger
.
Fatalf
(
"Initialize failed: %s"
,
err
)
}
winfsp
.
Serve
(
conf
,
jfs
,
c
.
String
(
"o"
),
c
.
Float64
(
"file-cache-to"
),
c
.
Bool
(
"as-root"
),
c
.
Int
(
"delay-close"
))
winfsp
.
Serve
(
conf
,
jfs
,
c
.
String
(
"o"
),
c
.
Float64
(
"file-cache-to"
),
c
.
Bool
(
"as-root"
),
c
.
Int
(
"delay-close"
),
strings
.
HasSuffix
(
conf
.
Mountpoint
,
":"
))
}
pkg/meta/redis.go
浏览文件 @
5c348843
...
...
@@ -93,8 +93,9 @@ return {ino, redis.call('GET', "i" .. tostring(ino))}
// RedisConfig is config for Redis client.
type
RedisConfig
struct
{
Strict
bool
// update ctime
Retries
int
Strict
bool
// update ctime
Retries
int
CaseInsensi
bool
}
type
redisMeta
struct
{
...
...
@@ -458,13 +459,25 @@ func (r *redisMeta) Summary(ctx Context, inode Ino, summary *Summary) syscall.Er
return
0
}
func
(
r
*
redisMeta
)
resolveCase
(
ctx
Context
,
parent
Ino
,
name
string
)
*
Entry
{
var
entries
[]
*
Entry
_
=
r
.
Readdir
(
ctx
,
parent
,
0
,
&
entries
)
for
_
,
e
:=
range
entries
{
n
:=
string
(
e
.
Name
)
if
strings
.
EqualFold
(
name
,
n
)
{
return
e
}
}
return
nil
}
func
(
r
*
redisMeta
)
Lookup
(
ctx
Context
,
parent
Ino
,
name
string
,
inode
*
Ino
,
attr
*
Attr
)
syscall
.
Errno
{
var
foundIno
Ino
var
encodedAttr
[]
byte
var
err
error
entryKey
:=
r
.
entryKey
(
parent
)
if
len
(
r
.
shaLookup
)
>
0
&&
attr
!=
nil
{
if
len
(
r
.
shaLookup
)
>
0
&&
attr
!=
nil
&&
!
r
.
conf
.
CaseInsensi
{
var
res
interface
{}
res
,
err
=
r
.
rdb
.
EvalSha
(
ctx
,
r
.
shaLookup
,
[]
string
{
entryKey
,
name
})
.
Result
()
if
err
!=
nil
{
...
...
@@ -502,10 +515,19 @@ func (r *redisMeta) Lookup(ctx Context, parent Ino, name string, inode *Ino, att
}
else
{
var
buf
[]
byte
buf
,
err
=
r
.
rdb
.
HGet
(
ctx
,
entryKey
,
name
)
.
Bytes
()
if
err
==
nil
{
_
,
foundIno
=
r
.
parseEntry
(
buf
)
}
if
err
==
redis
.
Nil
&&
r
.
conf
.
CaseInsensi
{
e
:=
r
.
resolveCase
(
ctx
,
parent
,
name
)
if
e
!=
nil
{
foundIno
=
e
.
Inode
err
=
nil
}
}
if
err
!=
nil
{
return
errno
(
err
)
}
_
,
foundIno
=
r
.
parseEntry
(
buf
)
if
attr
!=
nil
{
encodedAttr
,
err
=
r
.
rdb
.
Get
(
ctx
,
r
.
inodeKey
(
foundIno
))
.
Bytes
()
}
...
...
@@ -895,6 +917,8 @@ func (r *redisMeta) mknod(ctx Context, parent Ino, name string, _type uint8, mod
return
err
}
else
if
err
==
nil
{
return
syscall
.
EEXIST
}
else
if
err
==
redis
.
Nil
&&
r
.
conf
.
CaseInsensi
&&
r
.
resolveCase
(
ctx
,
parent
,
name
)
!=
nil
{
return
syscall
.
EEXIST
}
now
:=
time
.
Now
()
...
...
@@ -947,6 +971,13 @@ func (r *redisMeta) Create(ctx Context, parent Ino, name string, mode uint16, cu
func
(
r
*
redisMeta
)
Unlink
(
ctx
Context
,
parent
Ino
,
name
string
)
syscall
.
Errno
{
buf
,
err
:=
r
.
rdb
.
HGet
(
ctx
,
r
.
entryKey
(
parent
),
name
)
.
Bytes
()
if
err
==
redis
.
Nil
&&
r
.
conf
.
CaseInsensi
{
if
e
:=
r
.
resolveCase
(
ctx
,
parent
,
name
);
e
!=
nil
{
name
=
string
(
e
.
Name
)
buf
=
r
.
packEntry
(
e
.
Attr
.
Typ
,
e
.
Inode
)
err
=
nil
}
}
if
err
!=
nil
{
return
errno
(
err
)
}
...
...
@@ -1037,6 +1068,13 @@ func (r *redisMeta) Rmdir(ctx Context, parent Ino, name string) syscall.Errno {
return
syscall
.
ENOTEMPTY
}
buf
,
err
:=
r
.
rdb
.
HGet
(
ctx
,
r
.
entryKey
(
parent
),
name
)
.
Bytes
()
if
err
==
redis
.
Nil
&&
r
.
conf
.
CaseInsensi
{
if
e
:=
r
.
resolveCase
(
ctx
,
parent
,
name
);
e
!=
nil
{
name
=
string
(
e
.
Name
)
buf
=
r
.
packEntry
(
e
.
Attr
.
Typ
,
e
.
Inode
)
err
=
nil
}
}
if
err
!=
nil
{
return
errno
(
err
)
}
...
...
@@ -1161,6 +1199,13 @@ func (r *redisMeta) Rmr(ctx Context, parent Ino, name string) syscall.Errno {
func
(
r
*
redisMeta
)
Rename
(
ctx
Context
,
parentSrc
Ino
,
nameSrc
string
,
parentDst
Ino
,
nameDst
string
,
inode
*
Ino
,
attr
*
Attr
)
syscall
.
Errno
{
buf
,
err
:=
r
.
rdb
.
HGet
(
ctx
,
r
.
entryKey
(
parentSrc
),
nameSrc
)
.
Bytes
()
if
err
==
redis
.
Nil
&&
r
.
conf
.
CaseInsensi
{
if
e
:=
r
.
resolveCase
(
ctx
,
parentSrc
,
nameSrc
);
e
!=
nil
{
nameSrc
=
string
(
e
.
Name
)
buf
=
r
.
packEntry
(
e
.
Attr
.
Typ
,
e
.
Inode
)
err
=
nil
}
}
if
err
!=
nil
{
return
errno
(
err
)
}
...
...
@@ -1172,6 +1217,13 @@ func (r *redisMeta) Rename(ctx Context, parentSrc Ino, nameSrc string, parentDst
return
0
}
buf
,
err
=
r
.
rdb
.
HGet
(
ctx
,
r
.
entryKey
(
parentDst
),
nameDst
)
.
Bytes
()
if
err
==
redis
.
Nil
&&
r
.
conf
.
CaseInsensi
{
if
e
:=
r
.
resolveCase
(
ctx
,
parentDst
,
nameDst
);
e
!=
nil
{
nameDst
=
string
(
e
.
Name
)
buf
=
r
.
packEntry
(
e
.
Attr
.
Typ
,
e
.
Inode
)
err
=
nil
}
}
if
err
!=
nil
&&
err
!=
redis
.
Nil
{
return
errno
(
err
)
}
...
...
pkg/meta/redis_test.go
浏览文件 @
5c348843
...
...
@@ -262,6 +262,38 @@ func TestRedisClient(t *testing.T) {
}
}
func
TestCaseIncensi
(
t
*
testing
.
T
)
{
var
conf
=
RedisConfig
{
CaseInsensi
:
true
}
m
,
err
:=
NewRedisMeta
(
"redis://127.0.0.1:6379/6"
,
&
conf
)
if
err
!=
nil
{
t
.
Logf
(
"redis is not available: %s"
,
err
)
t
.
Skip
()
}
_
=
m
.
Init
(
Format
{
Name
:
"test"
},
true
)
ctx
:=
Background
var
inode
Ino
var
attr
=
&
Attr
{}
_
=
m
.
Create
(
ctx
,
1
,
"foo"
,
0755
,
0
,
&
inode
,
attr
)
if
st
:=
m
.
Create
(
ctx
,
1
,
"Foo"
,
0755
,
0
,
&
inode
,
attr
);
st
!=
syscall
.
EEXIST
{
t
.
Fatalf
(
"create should fail with EEXIST"
)
}
if
st
:=
m
.
Lookup
(
ctx
,
1
,
"Foo"
,
&
inode
,
attr
);
st
!=
0
{
t
.
Fatalf
(
"lookup Foo should be OK"
)
}
if
st
:=
m
.
Rename
(
ctx
,
1
,
"Foo"
,
1
,
"bar"
,
&
inode
,
attr
);
st
!=
0
{
t
.
Fatalf
(
"rename Foo to bar should be OK"
)
}
if
st
:=
m
.
Unlink
(
ctx
,
1
,
"Bar"
);
st
!=
0
{
t
.
Fatalf
(
"unlink Bar should be OK"
)
}
if
st
:=
m
.
Mkdir
(
ctx
,
1
,
"Foo"
,
0755
,
0
,
0
,
&
inode
,
attr
);
st
!=
0
{
t
.
Fatalf
(
"mkdir Foo should be OK"
)
}
if
st
:=
m
.
Rmdir
(
ctx
,
1
,
"foo"
);
st
!=
0
{
t
.
Fatalf
(
"rmdir foo should be OK"
)
}
}
func
TestCompaction
(
t
*
testing
.
T
)
{
var
conf
RedisConfig
m
,
err
:=
NewRedisMeta
(
"redis://127.0.0.1:6379/8"
,
&
conf
)
...
...
pkg/winfsp/winfs.go
浏览文件 @
5c348843
...
...
@@ -22,7 +22,6 @@ import (
"os"
"path"
"runtime"
"strings"
"sync"
"syscall"
"time"
...
...
@@ -558,7 +557,7 @@ func (j *juice) Releasedir(path string, fh uint64) (e int) {
return
}
func
Serve
(
conf
*
vfs
.
Config
,
fs_
*
fs
.
FileSystem
,
fuseOpt
string
,
fileCacheTo
float64
,
asRoot
bool
,
delayClose
int
)
error
{
func
Serve
(
conf
*
vfs
.
Config
,
fs_
*
fs
.
FileSystem
,
fuseOpt
string
,
fileCacheTo
float64
,
asRoot
bool
,
delayClose
int
,
caseInsensi
bool
)
error
{
var
jfs
juice
jfs
.
conf
=
conf
jfs
.
fs
=
fs_
...
...
@@ -577,7 +576,7 @@ func Serve(conf *vfs.Config, fs_ *fs.FileSystem, fuseOpt string, fileCacheTo flo
if
fuseOpt
!=
""
{
options
+=
","
+
fuseOpt
}
host
.
SetCapCaseInsensitive
(
strings
.
Contains
(
conf
.
Mountpoint
,
":"
)
)
host
.
SetCapCaseInsensitive
(
caseInsensi
)
host
.
SetCapReaddirPlus
(
true
)
logger
.
Debugf
(
"mount point: %s, options: %s"
,
conf
.
Mountpoint
,
options
)
_
=
host
.
Mount
(
conf
.
Mountpoint
,
[]
string
{
"-o"
,
options
})
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录