mirror of
https://github.com/cubefs/cubefs.git
synced 2026-08-02 02:00:56 +00:00
chore(master): update the codes according to review comments.#22834621
Signed-off-by: Wu Huocheng <wuhuocheng@oppo.com>
This commit is contained in:
parent
242eedf13d
commit
46bb136ee8
@ -8487,7 +8487,7 @@ func (m *Server) getMetaPartitionEmptyStatus(w http.ResponseWriter, r *http.Requ
|
||||
volStatus.MetaPartitions = append(volStatus.MetaPartitions, getMetaPartitionView(mp))
|
||||
}
|
||||
}
|
||||
if volStatus.EmptyCount > ReserveEmptyMetaPartition {
|
||||
if volStatus.EmptyCount > RsvEmptyMetaPartitionCnt {
|
||||
mpsStatus = append(mpsStatus, volStatus)
|
||||
}
|
||||
}
|
||||
@ -8521,9 +8521,9 @@ func (m *Server) freezeEmptyMetaPartition(w http.ResponseWriter, r *http.Request
|
||||
sendErrReply(w, r, &proto.HTTPReply{Code: proto.ErrCodeParamError, Msg: err.Error()})
|
||||
return
|
||||
}
|
||||
if count < ReserveEmptyMetaPartition {
|
||||
if count < RsvEmptyMetaPartitionCnt {
|
||||
// reserve 2 empty mp at least, not include the last one.
|
||||
count = ReserveEmptyMetaPartition
|
||||
count = RsvEmptyMetaPartitionCnt
|
||||
}
|
||||
|
||||
vol, err := m.cluster.getVol(name)
|
||||
@ -8538,8 +8538,8 @@ func (m *Server) freezeEmptyMetaPartition(w http.ResponseWriter, r *http.Request
|
||||
}
|
||||
|
||||
mps := vol.getSortMetaPartitions()
|
||||
if len(mps) <= ReserveEmptyMetaPartition {
|
||||
err = fmt.Errorf("the all meta partition number is less than %d", ReserveEmptyMetaPartition)
|
||||
if len(mps) <= RsvEmptyMetaPartitionCnt {
|
||||
err = fmt.Errorf("the all meta partition number is less than %d", RsvEmptyMetaPartitionCnt)
|
||||
sendErrReply(w, r, &proto.HTTPReply{Code: proto.ErrCodeParamError, Msg: err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
@ -249,7 +249,7 @@ const (
|
||||
|
||||
unusedFlashNodeFlashGroupID = 0
|
||||
defaultFlashGroupSlotsCount = 32
|
||||
ReserveEmptyMetaPartition = 2
|
||||
RsvEmptyMetaPartitionCnt = 2
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
@ -2082,20 +2082,6 @@ func (vol *Vol) isStorageClassInAllowed(storageClass uint32) (in bool) {
|
||||
return in
|
||||
}
|
||||
|
||||
type MetaPartitionSort []*MetaPartition
|
||||
|
||||
func (mps MetaPartitionSort) Len() int {
|
||||
return len(mps)
|
||||
}
|
||||
|
||||
func (mps MetaPartitionSort) Swap(i, j int) {
|
||||
mps[i], mps[j] = mps[j], mps[i]
|
||||
}
|
||||
|
||||
func (mps MetaPartitionSort) Less(i, j int) bool {
|
||||
return mps[i].Start < mps[j].Start
|
||||
}
|
||||
|
||||
func (vol *Vol) getSortMetaPartitions() (mps []*MetaPartition) {
|
||||
vol.mpsLock.RLock()
|
||||
mps = make([]*MetaPartition, 0, len(vol.MetaPartitions))
|
||||
@ -2104,7 +2090,7 @@ func (vol *Vol) getSortMetaPartitions() (mps []*MetaPartition) {
|
||||
}
|
||||
vol.mpsLock.RUnlock()
|
||||
|
||||
sort.Sort(MetaPartitionSort(mps))
|
||||
sort.Slice(mps, func(i, j int) bool { return mps[i].Start < mps[j].Start })
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@ -285,3 +285,5 @@ var (
|
||||
_ = (*metaPartition).fsmDelVerExtents
|
||||
_ = (*TransactionResource).copyGetTxRbInode
|
||||
)
|
||||
|
||||
const DelMetaPartitionHdr = "del_partition_"
|
||||
|
||||
@ -3063,7 +3063,7 @@ func (m *metadataManager) opRemoveEmptyMetaPartition(conn net.Conn, p *Packet,
|
||||
}
|
||||
|
||||
for _, entry := range entries {
|
||||
if entry.IsDir() && strings.HasPrefix(entry.Name(), "del_partition_") {
|
||||
if entry.IsDir() && strings.HasPrefix(entry.Name(), DelMetaPartitionHdr) {
|
||||
removeDir := path.Join(m.rootDir, entry.Name())
|
||||
os.RemoveAll(removeDir)
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user