提交 dc0d3ee1 编写于 作者: D Davies Liu

add more logging for gc

上级 733a1a4c
......@@ -148,14 +148,29 @@ func gc(ctx *cli.Context) error {
length := args[1].(uint32)
return store.Remove(chunkid, int(length))
}))
var nc, ns, nb int
var lastLog time.Time
m.OnMsg(meta.CompactChunk, meta.MsgCallback(func(args ...interface{}) error {
slices := args[0].([]meta.Slice)
chunkid := args[1].(uint64)
return vfs.Compact(chunkConf, store, slices, chunkid)
err = vfs.Compact(chunkConf, store, slices, chunkid)
nc++
for _, s := range slices {
ns++
nb += int(s.Len)
}
if time.Since(lastLog) > time.Second && isatty.IsTerminal(os.Stderr.Fd()) {
logger.Infof("Compacted %d chunks (%d slices, %d bytes).\r", nc, ns, nb)
lastLog = time.Now()
}
return err
}))
logger.Infof("start to compact chunks ...")
err := m.CompactAll(meta.Background)
if err != 0 {
logger.Errorf("compact all chunks: %s", err)
} else {
logger.Infof("Compacted %d chunks (%d slices, %d bytes).", nc, ns, nb)
}
}
......
......@@ -2014,8 +2014,8 @@ func (r *redisMeta) compactChunk(inode Ino, indx uint32) {
// the slices will be formed as a tree after buildSlice(),
// we should create new one (or remove the link in tree)
ss = readSlices(vals[skipped:])
first := *ss[0]
// copy the first slice so it will not be updated by buildSlice
first := *ss[0]
chunks = buildSlice(ss)
pos, size = 0, 0
if chunks[0].Chunkid == 0 {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册