mirror of
https://github.com/cubefs/cubefs.git
synced 2026-08-02 02:00:56 +00:00
chore(data): change get store used size log level
Signed-off-by: NaturalSelect <huangzhibin1@oppo.com>
This commit is contained in:
parent
025d2ff89c
commit
402da3957d
@ -1033,7 +1033,7 @@ func (s *ExtentStore) GetStoreUsedSize() (used int64) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if log.EnableDebug() {
|
if log.EnableDebug() {
|
||||||
log.LogDebugf("[GetStoreUsedSize] store(%v) tiny extent(%v) size(%v)", s.dataPath, einfo.FileID, strutil.FormatSize(uint64(size)))
|
log.LogDebugf("[GetStoreUsedSize] store(%v) tiny extent(%v) size(%v) raw(%v)", s.dataPath, einfo.FileID, strutil.FormatSize(uint64(size)), size)
|
||||||
}
|
}
|
||||||
used += size
|
used += size
|
||||||
tinyTotal += uint64(size)
|
tinyTotal += uint64(size)
|
||||||
@ -1046,10 +1046,14 @@ func (s *ExtentStore) GetStoreUsedSize() (used int64) {
|
|||||||
}
|
}
|
||||||
actualSize, err := s.getFileDiskUsed(path.Join(s.dataPath, strconv.FormatInt(int64(einfo.FileID), 10)))
|
actualSize, err := s.getFileDiskUsed(path.Join(s.dataPath, strconv.FormatInt(int64(einfo.FileID), 10)))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.LogErrorf("[GetStoreUsedSize] store(%v) failed to get normal extent(%v) disk used", s.dataPath, einfo.FileID)
|
if os.IsNotExist(err) {
|
||||||
|
log.LogInfof("[GetStoreUsedSize] store(%v) extent(%v) already be deleted, skip", s.dataPath, einfo.FileID)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
log.LogErrorf("[GetStoreUsedSize] store(%v) failed to get normal extent(%v) disk used, err(%v)", s.dataPath, einfo.FileID, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
log.LogDebugf("[GetStoreUsedSize] store(%v) normal extent(%v) size(%v), actual size(%v)", s.dataPath, einfo.FileID, strutil.FormatSize(uint64(size)), strutil.FormatSize(uint64(actualSize)))
|
log.LogDebugf("[GetStoreUsedSize] store(%v) normal extent(%v) size(%v) raw(%v), actual size(%v) raw(%v)", s.dataPath, einfo.FileID, strutil.FormatSize(uint64(size)), size, strutil.FormatSize(uint64(actualSize)), actualSize)
|
||||||
if actualSize < size {
|
if actualSize < size {
|
||||||
log.LogWarnf("[GetStoreUsedSize] store(%v) normal extent(%v) actual size(%v), size(%v) einfo size(%v) snapshot off(%v)", s.dataPath, einfo.FileID, strutil.FormatSize(uint64(actualSize)), strutil.FormatSize(uint64(size)), strutil.FormatSize(einfo.Size), strutil.FormatSize(einfo.SnapshotDataOff))
|
log.LogWarnf("[GetStoreUsedSize] store(%v) normal extent(%v) actual size(%v), size(%v) einfo size(%v) snapshot off(%v)", s.dataPath, einfo.FileID, strutil.FormatSize(uint64(actualSize)), strutil.FormatSize(uint64(size)), strutil.FormatSize(einfo.Size), strutil.FormatSize(einfo.SnapshotDataOff))
|
||||||
}
|
}
|
||||||
@ -1059,7 +1063,7 @@ func (s *ExtentStore) GetStoreUsedSize() (used int64) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if log.EnableInfo() {
|
if log.EnableInfo() {
|
||||||
log.LogInfof("[GetStoreUsedSize] store(%v) total size(%v) tiny total(%v) normal total(%v)", s.dataPath, strutil.FormatSize(uint64(used)), strutil.FormatSize(tinyTotal), strutil.FormatSize(normalTotal))
|
log.LogInfof("[GetStoreUsedSize] store(%v) total size(%v) raw(%v) tiny total(%v) raw(%v) normal total(%v) raw(%v)", s.dataPath, strutil.FormatSize(uint64(used)), used, strutil.FormatSize(tinyTotal), tinyTotal, strutil.FormatSize(normalTotal), normalTotal)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@ -49,7 +49,7 @@ func ParseSize(sizeStr string) (size uint64, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type SuffixPair struct {
|
type SuffixPair struct {
|
||||||
Size uint64
|
Size float64
|
||||||
Suffix string
|
Suffix string
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,22 +84,7 @@ func FormatSize(size uint64) (sizeStr string) {
|
|||||||
if size == 0 {
|
if size == 0 {
|
||||||
return "0"
|
return "0"
|
||||||
}
|
}
|
||||||
var pair SuffixPair
|
return FormatSizeFloat(float64(size))
|
||||||
for _, suffixPair := range suffixTable {
|
|
||||||
if size >= suffixPair.Size {
|
|
||||||
pair = suffixPair
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
break
|
|
||||||
}
|
|
||||||
if pair.Size == 0 {
|
|
||||||
sizeStr = fmt.Sprintf("invalid %v", size)
|
|
||||||
} else {
|
|
||||||
size /= pair.Size
|
|
||||||
sizeStr = fmt.Sprintf("%v%v", size, pair.Suffix)
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func ParsePercent(valStr string) (val float64, err error) {
|
func ParsePercent(valStr string) (val float64, err error) {
|
||||||
@ -120,3 +105,27 @@ func FormatPercent(val float64) (valStr string) {
|
|||||||
valStr = fmt.Sprintf("%v%%", val*100)
|
valStr = fmt.Sprintf("%v%%", val*100)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func formatFloatAndTrimSuffix(v float64) (str string) {
|
||||||
|
str = fmt.Sprintf("%.3f", v)
|
||||||
|
str = strings.TrimSuffix(str, ".000")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func FormatSizeFloat(val float64) (sizeStr string) {
|
||||||
|
if val <= 1 {
|
||||||
|
sizeStr = formatFloatAndTrimSuffix(val)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var pair SuffixPair
|
||||||
|
for _, suffixPair := range suffixTable {
|
||||||
|
if val >= suffixPair.Size {
|
||||||
|
pair = suffixPair
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
break
|
||||||
|
}
|
||||||
|
val /= float64(pair.Size)
|
||||||
|
sizeStr = fmt.Sprintf("%v%v", formatFloatAndTrimSuffix(val), pair.Suffix)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user