From b9b142b6ea8a69d5aba87b15839de6291ba08c95 Mon Sep 17 00:00:00 2001 From: jiefenghuang Date: Fri, 27 Dec 2024 11:02:00 +0800 Subject: [PATCH] cmd/gc: fix delete slice Signed-off-by: jiefenghuang --- cmd/gc.go | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/cmd/gc.go b/cmd/gc.go index 954511660730..dccef33222af 100644 --- a/cmd/gc.go +++ b/cmd/gc.go @@ -29,6 +29,7 @@ import ( osync "github.com/juicedata/juicefs/pkg/sync" "github.com/juicedata/juicefs/pkg/utils" "github.com/juicedata/juicefs/pkg/vfs" + "github.com/pkg/errors" "github.com/urfave/cli/v2" ) @@ -122,27 +123,13 @@ func gc(ctx *cli.Context) error { var wg sync.WaitGroup var delSpin *utils.Bar - var sliceChan chan meta.Slice // pending delete slices if delete || compact { delSpin = progress.AddCountSpinner("Cleaned pending slices") - sliceChan = make(chan meta.Slice, 10240) m.OnMsg(meta.DeleteSlice, func(args ...interface{}) error { delSpin.Increment() - sliceChan <- meta.Slice{Id: args[0].(uint64), Size: args[1].(uint32)} - return nil + return store.Remove(args[0].(uint64), int(args[1].(uint32))) }) - for i := 0; i < threads; i++ { - wg.Add(1) - go func() { - defer wg.Done() - for s := range sliceChan { - if err := store.Remove(s.Id, int(s.Size)); err != nil { - logger.Warnf("remove %d_%d: %s", s.Id, s.Size, err) - } - } - }() - } } c := meta.WrapContext(ctx.Context) @@ -367,11 +354,8 @@ func gc(ctx *cli.Context) error { } } m.OnMsg(meta.DeleteSlice, func(args ...interface{}) error { - return nil + return errors.New("stop deleting slice") }) - if sliceChan != nil { - close(sliceChan) - } close(leakedObj) wg.Wait() if delete || compact {