Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Juicedata
JuiceFS
提交
158a8689
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 搜索 >>
提交
158a8689
编写于
5月 13, 2021
作者:
D
Davies Liu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rename slice_ref to chunk_ref
上级
83845711
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
13 addition
and
13 deletion
+13
-13
pkg/meta/sql.go
pkg/meta/sql.go
+12
-12
pkg/meta/sql_test.go
pkg/meta/sql_test.go
+1
-1
未找到文件。
pkg/meta/sql.go
浏览文件 @
158a8689
...
...
@@ -72,7 +72,7 @@ type chunk struct {
Indx
uint32
`xorm:"unique(chunk) notnull"`
Slices
[]
byte
`xorm:"blob notnull"`
}
type
slice
Ref
struct
{
type
chunk
Ref
struct
{
Chunkid
uint64
`xorm:"pk"`
Size
uint32
`xorm:"notnull"`
Refs
int
`xorm:"notnull"`
...
...
@@ -163,7 +163,7 @@ func (m *dbMeta) Init(format Format, force bool) error {
if
err
:=
m
.
engine
.
Sync2
(
new
(
node
),
new
(
edge
),
new
(
symlink
),
new
(
xattr
));
err
!=
nil
{
logger
.
Fatalf
(
"create table node, edge, symlink, xattr: %s"
,
err
)
}
if
err
:=
m
.
engine
.
Sync2
(
new
(
chunk
),
new
(
slice
Ref
));
err
!=
nil
{
if
err
:=
m
.
engine
.
Sync2
(
new
(
chunk
),
new
(
chunk
Ref
));
err
!=
nil
{
logger
.
Fatalf
(
"create table chunk, chunk_ref: %s"
,
err
)
}
if
err
:=
m
.
engine
.
Sync2
(
new
(
session
),
new
(
sustained
),
new
(
delfile
));
err
!=
nil
{
...
...
@@ -1590,7 +1590,7 @@ func (m *dbMeta) Write(ctx Context, inode Ino, indx uint32, off uint32, slice Sl
return
err
}
}
if
_
,
err
:=
s
.
Insert
(
slice
Ref
{
slice
.
Chunkid
,
slice
.
Size
,
1
});
err
!=
nil
{
if
_
,
err
:=
s
.
Insert
(
chunk
Ref
{
slice
.
Chunkid
,
slice
.
Size
,
1
});
err
!=
nil
{
return
err
}
_
,
err
=
s
.
Update
(
&
n
,
&
node
{
Inode
:
inode
})
...
...
@@ -1665,7 +1665,7 @@ func (m *dbMeta) CopyFileRange(ctx Context, fin Ino, offIn uint64, fout Ino, off
return
err
}
if
s
.
Chunkid
>
0
{
if
_
,
err
:=
ses
.
Exec
(
"update jfs_
slice
_ref set refs=refs+1 where chunkid = ? AND size = ?"
,
s
.
Chunkid
,
s
.
Size
);
err
!=
nil
{
if
_
,
err
:=
ses
.
Exec
(
"update jfs_
chunk
_ref set refs=refs+1 where chunkid = ? AND size = ?"
,
s
.
Chunkid
,
s
.
Size
);
err
!=
nil
{
return
err
}
}
...
...
@@ -1765,12 +1765,12 @@ func (m *dbMeta) cleanupSlices() {
return
err
})
var
ck
slice
Ref
var
ck
chunk
Ref
rows
,
err
:=
m
.
engine
.
Where
(
"refs <= 0"
)
.
Rows
(
&
ck
)
if
err
!=
nil
{
continue
}
var
cks
[]
slice
Ref
var
cks
[]
chunk
Ref
for
rows
.
Next
()
{
if
rows
.
Scan
(
&
ck
)
==
nil
{
cks
=
append
(
cks
,
ck
)
...
...
@@ -1793,7 +1793,7 @@ func (m *dbMeta) deleteSlice(chunkid uint64, size uint32) {
logger
.
Warnf
(
"delete chunk %d (%d bytes): %s"
,
chunkid
,
size
,
err
)
}
else
{
err
=
m
.
txn
(
func
(
ses
*
xorm
.
Session
)
error
{
_
,
err
=
ses
.
Exec
(
"delete from jfs_
slice
_ref where chunkid=?"
,
chunkid
)
_
,
err
=
ses
.
Exec
(
"delete from jfs_
chunk
_ref where chunkid=?"
,
chunkid
)
return
err
})
if
err
!=
nil
{
...
...
@@ -1815,7 +1815,7 @@ func (m *dbMeta) deleteChunk(inode Ino, indx uint32) error {
}
ss
=
readSliceBuf
(
c
.
Slices
)
for
_
,
s
:=
range
ss
{
_
,
err
=
ses
.
Exec
(
"update jfs_
slice
_ref set refs=refs-1 where chunkid=? AND size=?"
,
s
.
chunkid
,
s
.
size
)
_
,
err
=
ses
.
Exec
(
"update jfs_
chunk
_ref set refs=refs-1 where chunkid=? AND size=?"
,
s
.
chunkid
,
s
.
size
)
if
err
!=
nil
{
return
err
}
...
...
@@ -1941,12 +1941,12 @@ func (m *dbMeta) compactChunk(inode Ino, indx uint32, force bool) {
return
err
}
// create the key to tracking it
if
n
,
err
:=
s
.
Insert
(
slice
Ref
{
chunkid
,
size
,
1
});
err
!=
nil
||
n
==
0
{
if
n
,
err
:=
s
.
Insert
(
chunk
Ref
{
chunkid
,
size
,
1
});
err
!=
nil
||
n
==
0
{
return
err
}
ses
:=
s
for
_
,
s
:=
range
ss
{
if
_
,
err
:=
ses
.
Exec
(
"update jfs_
slice
_ref set refs=refs-1 where chunkid=? and size=?"
,
s
.
chunkid
,
s
.
size
);
err
!=
nil
{
if
_
,
err
:=
ses
.
Exec
(
"update jfs_
chunk
_ref set refs=refs-1 where chunkid=? and size=?"
,
s
.
chunkid
,
s
.
size
);
err
!=
nil
{
return
err
}
}
...
...
@@ -1954,7 +1954,7 @@ func (m *dbMeta) compactChunk(inode Ino, indx uint32, force bool) {
})
// there could be false-negative that the compaction is successful, double-check
if
err
!=
nil
{
var
c
=
slice
Ref
{
Chunkid
:
chunkid
}
var
c
=
chunk
Ref
{
Chunkid
:
chunkid
}
ok
,
e
:=
m
.
engine
.
Get
(
&
c
)
if
e
==
nil
{
if
ok
{
...
...
@@ -1971,7 +1971,7 @@ func (m *dbMeta) compactChunk(inode Ino, indx uint32, force bool) {
m
.
deleteSlice
(
chunkid
,
size
)
}
else
if
err
==
nil
{
for
_
,
s
:=
range
ss
{
var
ref
=
slice
Ref
{
Chunkid
:
s
.
chunkid
}
var
ref
=
chunk
Ref
{
Chunkid
:
s
.
chunkid
}
ok
,
err
:=
m
.
engine
.
Get
(
&
ref
)
if
err
==
nil
&&
ok
&&
ref
.
Refs
<=
0
{
m
.
deleteSlice
(
s
.
chunkid
,
s
.
size
)
...
...
pkg/meta/sql_test.go
浏览文件 @
158a8689
...
...
@@ -41,7 +41,7 @@ func TestMySQLClient(t *testing.T) {
m
.
engine
.
DropTables
(
&
edge
{})
m
.
engine
.
DropTables
(
&
symlink
{})
m
.
engine
.
DropTables
(
&
chunk
{})
m
.
engine
.
DropTables
(
&
slice
Ref
{})
m
.
engine
.
DropTables
(
&
chunk
Ref
{})
m
.
engine
.
DropTables
(
&
session
{})
m
.
engine
.
DropTables
(
&
sustained
{})
m
.
engine
.
DropTables
(
&
xattr
{})
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录