@@ -160,14 +160,15 @@ func (pm *Manager) ReloadPools() error {
160
160
return err
161
161
}
162
162
163
- fsPools := pm .examineEntries (entries )
163
+ fsPools , fsManagerList := pm .examineEntries (entries )
164
164
165
165
if len (fsPools ) == 0 {
166
166
return errors .New ("no available pools" )
167
167
}
168
168
169
169
pm .mu .Lock ()
170
170
pm .fsManagerPool = fsPools
171
+ pm .fsManagerList = fsManagerList
171
172
pm .mu .Unlock ()
172
173
173
174
log .Msg ("Available storage pools: " , pm .describeAvailablePools ())
@@ -176,8 +177,9 @@ func (pm *Manager) ReloadPools() error {
176
177
return nil
177
178
}
178
179
179
- func (pm * Manager ) examineEntries (entries []os.FileInfo ) map [string ]FSManager {
180
+ func (pm * Manager ) examineEntries (entries []os.FileInfo ) ( map [string ]FSManager , * list. List ) {
180
181
fsManagers := make (map [string ]FSManager )
182
+ poolList := & list.List {}
181
183
182
184
for _ , entry := range entries {
183
185
if ! entry .IsDir () {
@@ -232,15 +234,16 @@ func (pm *Manager) examineEntries(entries []os.FileInfo) map[string]FSManager {
232
234
// TODO(akartasov): extract pool name.
233
235
fsManagers [entry .Name ()] = fsm
234
236
235
- if pm .Active () == nil || pm .Active ().Pool ().DSA .Before (pool .DSA ) {
236
- pm .fsManagerList .PushFront (fsm .Pool ().Name )
237
+ front := poolList .Front ()
238
+ if front == nil || front .Value == nil || fsManagers [front .Value .(string )].Pool ().DSA .Before (pool .DSA ) {
239
+ poolList .PushFront (fsm .Pool ().Name )
237
240
continue
238
241
}
239
242
240
- pm . fsManagerList .PushBack (fsm .Pool ().Name )
243
+ poolList .PushBack (fsm .Pool ().Name )
241
244
}
242
245
243
- return fsManagers
246
+ return fsManagers , poolList
244
247
}
245
248
246
249
// reloadBlockDevices gets filesystem types of block devices.
0 commit comments