Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
52301ce8
Unverified
提交
52301ce8
authored
2月 03, 2018
作者:
Whyrusleeping
提交者:
GitHub
2月 03, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #4578 from ipfs/feat/datastore-gc
Make repo gc call CollectGarbage on datastore
上级
864c960a
d7aa2f7d
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
37 行增加
和
4 行删除
+37
-4
gc.go
core/corerepo/gc.go
+2
-2
add_test.go
core/coreunix/add_test.go
+1
-1
gc.go
pin/gc/gc.go
+14
-1
datastores.go
repo/fsrepo/datastores.go
+20
-0
没有找到文件。
core/corerepo/gc.go
浏览文件 @
52301ce8
...
...
@@ -86,7 +86,7 @@ func GarbageCollect(n *core.IpfsNode, ctx context.Context) error {
if
err
!=
nil
{
return
err
}
rmed
:=
gc
.
GC
(
ctx
,
n
.
Blockstore
,
n
.
Pinning
,
roots
)
rmed
:=
gc
.
GC
(
ctx
,
n
.
Blockstore
,
n
.
Repo
.
Datastore
(),
n
.
Pinning
,
roots
)
return
CollectResult
(
ctx
,
rmed
,
nil
)
}
...
...
@@ -154,7 +154,7 @@ func GarbageCollectAsync(n *core.IpfsNode, ctx context.Context) <-chan gc.Result
return
out
}
return
gc
.
GC
(
ctx
,
n
.
Blockstore
,
n
.
Pinning
,
roots
)
return
gc
.
GC
(
ctx
,
n
.
Blockstore
,
n
.
Repo
.
Datastore
(),
n
.
Pinning
,
roots
)
}
func
PeriodicGC
(
ctx
context
.
Context
,
node
*
core
.
IpfsNode
)
error
{
...
...
core/coreunix/add_test.go
浏览文件 @
52301ce8
...
...
@@ -104,7 +104,7 @@ func TestAddGCLive(t *testing.T) {
gcstarted
:=
make
(
chan
struct
{})
go
func
()
{
defer
close
(
gcstarted
)
gcout
=
gc
.
GC
(
context
.
Background
(),
node
.
Blockstore
,
node
.
Pinning
,
nil
)
gcout
=
gc
.
GC
(
context
.
Background
(),
node
.
Blockstore
,
node
.
Repo
.
Datastore
(),
node
.
Pinning
,
nil
)
}()
// gc shouldnt start until we let the add finish its current file.
...
...
pin/gc/gc.go
浏览文件 @
52301ce8
...
...
@@ -11,6 +11,7 @@ import (
dag
"github.com/ipfs/go-ipfs/merkledag"
pin
"github.com/ipfs/go-ipfs/pin"
dstore
"gx/ipfs/QmPpegoMqhAEqjncrzArm7KVWAkCm78rqL2DPuNjhPrshg/go-datastore"
logging
"gx/ipfs/QmRb5jh8z2E8hMGN2tkvs1yHynUanqnZ3UeKwgN1i9P1F8/go-log"
cid
"gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid"
ipld
"gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
...
...
@@ -35,7 +36,7 @@ type Result struct {
// The routine then iterates over every block in the blockstore and
// deletes any block that is not found in the marked set.
//
func
GC
(
ctx
context
.
Context
,
bs
bstore
.
GCBlockstore
,
pn
pin
.
Pinner
,
bestEffortRoots
[]
*
cid
.
Cid
)
<-
chan
Result
{
func
GC
(
ctx
context
.
Context
,
bs
bstore
.
GCBlockstore
,
dstor
dstore
.
Datastore
,
pn
pin
.
Pinner
,
bestEffortRoots
[]
*
cid
.
Cid
)
<-
chan
Result
{
elock
:=
log
.
EventBegin
(
ctx
,
"GC.lockWait"
)
unlocker
:=
bs
.
GCLock
()
...
...
@@ -107,6 +108,18 @@ func GC(ctx context.Context, bs bstore.GCBlockstore, pn pin.Pinner, bestEffortRo
if
errors
{
output
<-
Result
{
Error
:
ErrCannotDeleteSomeBlocks
}
}
defer
log
.
EventBegin
(
ctx
,
"GC.datastore"
)
.
Done
()
gds
,
ok
:=
dstor
.
(
dstore
.
GCDatastore
)
if
!
ok
{
return
}
err
=
gds
.
CollectGarbage
()
if
err
!=
nil
{
output
<-
Result
{
Error
:
err
}
return
}
}()
return
output
...
...
repo/fsrepo/datastores.go
浏览文件 @
52301ce8
...
...
@@ -16,6 +16,7 @@ import (
ds
"gx/ipfs/QmPpegoMqhAEqjncrzArm7KVWAkCm78rqL2DPuNjhPrshg/go-datastore"
mount
"gx/ipfs/QmPpegoMqhAEqjncrzArm7KVWAkCm78rqL2DPuNjhPrshg/go-datastore/syncmount"
humanize
"gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize"
ldbopts
"gx/ipfs/QmbBhyDKsY4mbY6xsKt3qu9Y7FPvMJ6qbD8AMjYYvPRw1g/goleveldb/leveldb/opt"
badgerds
"gx/ipfs/Qmbjb3c2KRPVNZWSvQED8zAf12Brdbp3ksSnGdsJiytqUs/go-ds-badger"
levelds
"gx/ipfs/Qmbkc8BMfEixGCeKRuGGbf34mAjTb9xPmJ8Pm5gHU7ohZ4/go-ds-leveldb"
...
...
@@ -342,6 +343,8 @@ func (c measureDatastoreConfig) Create(path string) (repo.Datastore, error) {
type
badgerdsDatastoreConfig
struct
{
path
string
syncWrites
bool
vlogFileSize
int64
}
// BadgerdsDatastoreConfig returns a configuration stub for a badger datastore
...
...
@@ -366,6 +369,22 @@ func BadgerdsDatastoreConfig(params map[string]interface{}) (DatastoreConfig, er
}
}
vls
,
ok
:=
params
[
"vlogFileSize"
]
if
!
ok
{
// default to 1GiB
c
.
vlogFileSize
=
badgerds
.
DefaultOptions
.
ValueLogFileSize
}
else
{
if
vlogSize
,
ok
:=
vls
.
(
string
);
ok
{
s
,
err
:=
humanize
.
ParseBytes
(
vlogSize
)
if
err
!=
nil
{
return
nil
,
err
}
c
.
vlogFileSize
=
int64
(
s
)
}
else
{
return
nil
,
fmt
.
Errorf
(
"'vlogFileSize' field was not a string"
)
}
}
return
&
c
,
nil
}
...
...
@@ -389,6 +408,7 @@ func (c *badgerdsDatastoreConfig) Create(path string) (repo.Datastore, error) {
defopts
:=
badgerds
.
DefaultOptions
defopts
.
SyncWrites
=
c
.
syncWrites
defopts
.
ValueLogFileSize
=
c
.
vlogFileSize
return
badgerds
.
NewDatastore
(
p
,
&
defopts
)
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论