Skip to content

Commit

Permalink
fix add some log message
Browse files Browse the repository at this point in the history
  • Loading branch information
anysql committed Jan 7, 2025
1 parent 6003d10 commit 60720b1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
10 changes: 6 additions & 4 deletions cmd/rmr.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,15 @@ func openController(dpath string) (*os.File, error) {
func rmr(ctx *cli.Context) error {
setup(ctx, 1)
var flag uint8
var numThreads uint8
var numThreads int

numThreads = uint8(ctx.Int("threads"))
numThreads = ctx.Int("threads")
if numThreads < 2 {
numThreads = 2
}
if numThreads > 127 {
numThreads = 127
}
if ctx.Bool("skip-trash") {
if os.Getuid() != 0 {
logger.Fatalf("Only root can remove files directly")
Expand Down Expand Up @@ -109,8 +112,7 @@ func rmr(ctx *cli.Context) error {
wb.Put64(inode)
wb.Put8(uint8(len(name)))
wb.Put([]byte(name))
wb.Put8(flag)
wb.Put8(numThreads)
wb.Put8(flag + uint8(numThreads << 1))
_, err = f.Write(wb.Bytes())
if err != nil {
logger.Fatalf("write message: %s", err)
Expand Down
8 changes: 6 additions & 2 deletions pkg/meta/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,12 +351,16 @@ func (m *baseMeta) RemoveEx(ctx Context, parent Ino, name string, skipTrash bool
return m.Unlink(ctx, parent, name)
}
if numThreads <= 0 {
logger.Infof("Invalid threads number %d , auto adjust to 50 .", numThreads)
numThreads = 50
} else if numThreads < 2 {
logger.Infof("Invalid threads number %d , auto adjust to 2 .", numThreads)
numThreads = 2
} else if numThreads > 255 {
numThreads = 255
} else if numThreads > 127 {
logger.Infof("Invalid threads number %d , auto adjust to 127 .", numThreads)
numThreads = 127
}
logger.Infof("Start emptyEntry with %d concurrent threads .", numThreads)
concurrent := make(chan int, numThreads)
return m.emptyEntry(ctx, parent, name, inode, skipTrash, count, concurrent)
}
Expand Down
7 changes: 3 additions & 4 deletions pkg/vfs/internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,10 +300,9 @@ func (v *VFS) handleInternalMsg(ctx meta.Context, cmd uint32, r *utils.Buffer, o
var skipTrash bool
var numThreads uint8 = 50
if r.HasMore() {
skipTrash = r.Get8()&1 != 0
if r.HasMore() {
numThreads = r.Get8()
}
numThreads = r.Get8()
skipTrash = numThreads&1 != 0
numThreads = (numThreads >> 1)
}
var count uint64
var st syscall.Errno
Expand Down

0 comments on commit 60720b1

Please sign in to comment.