1
// Copyright 2023 The CubeFS Authors.
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
7
// http://www.apache.org/licenses/LICENSE-2.0
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
12
// implied. See the License for the specific language governing
13
// permissions and limitations under the License.
22
"github.com/cubefs/cubefs/util/log"
25
type LcConfiguration struct {
31
Expire *ExpirationConfig
37
type ExpirationConfig struct {
42
type FilterConfig struct {
47
RuleEnabled string = "Enabled"
48
RuleDisabled string = "Disabled"
51
func (lcConf *LcConfiguration) GenEnabledRuleTasks() []*RuleTask {
52
tasks := make([]*RuleTask, 0)
53
for _, r := range lcConf.Rules {
54
if r.Status != RuleEnabled {
55
log.LogDebugf("GenEnabledRuleTasks: skip disabled rule(%v) in volume(%v)", r.ID, lcConf.VolName)
59
Id: fmt.Sprintf("%s:%s", lcConf.VolName, r.ID),
60
VolName: lcConf.VolName,
63
tasks = append(tasks, task)
64
log.LogDebugf("GenEnabledRuleTasks: RuleTask(%v) generated from rule(%v) in volume(%v)", *task, r.ID, lcConf.VolName)
69
// ----------------------------------------------
73
type LcNodeRuleTaskRequest struct {
85
type LcNodeRuleTaskResponse struct {
94
LcNodeRuleTaskStatistics
97
type LcNodeRuleTaskStatistics struct {
100
TotalInodeScannedNum int64
104
ErrorSkippedNum int64
107
// ----------------------------------
110
type ScanDentry struct {
111
ParentId uint64 `json:"pid"` // FileID value of the parent inode.
112
Inode uint64 `json:"inode"` // FileID value of the current inode.
113
Name string `json:"name"` // Name of the current dentry.
114
Path string `json:"path"` // Path of the current dentry.
115
Type uint32 `json:"type"` // Type of the current dentry.
118
type BatchDentries struct {
120
dentries map[uint64]*ScanDentry
123
func NewBatchDentries() *BatchDentries {
124
return &BatchDentries{
125
dentries: make(map[uint64]*ScanDentry),
129
func (f *BatchDentries) Append(dentry *ScanDentry) {
132
f.dentries[dentry.Inode] = dentry
135
func (f *BatchDentries) Len() int {
138
return len(f.dentries)
141
func (f *BatchDentries) BatchGetAndClear() (map[uint64]*ScanDentry, []uint64) {
144
dentries := f.dentries
146
for i := range f.dentries {
147
inodes = append(inodes, i)
149
f.dentries = make(map[uint64]*ScanDentry)
150
return dentries, inodes