mirror of
https://github.com/pgsty/minio.git
synced 2026-08-09 15:53:28 +03:00
api: Add diskInfo as part of StatVol and ListVols. (#1349)
It is the bucket and volumes which needs to have this value rather than the DiskInfo API itself. Eventually this can be extended to show disk usage per Buckets/Volumes whenever we have that functionality. For now since buckets/volumes are thinly provisioned this is the right approach.
This commit is contained in:
committed by
Anand Babu (AB) Periasamy
parent
1284ecc6f2
commit
4cf73caf02
@@ -226,6 +226,12 @@ func (s fsStorage) MakeVol(volume string) (err error) {
|
||||
|
||||
// ListVols - list volumes.
|
||||
func (s fsStorage) ListVols() (volsInfo []VolInfo, err error) {
|
||||
// Get disk info to be populated for VolInfo.
|
||||
var diskInfo disk.Info
|
||||
diskInfo, err = disk.GetInfo(s.diskPath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
volsInfo, err = getAllUniqueVols(s.diskPath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -238,6 +244,9 @@ func (s fsStorage) ListVols() (volsInfo []VolInfo, err error) {
|
||||
volInfo := VolInfo{
|
||||
Name: volName,
|
||||
Created: vol.Created,
|
||||
Total: diskInfo.Total,
|
||||
Free: diskInfo.Free,
|
||||
FSType: diskInfo.FSType,
|
||||
}
|
||||
volsInfo[i] = volInfo
|
||||
}
|
||||
@@ -260,12 +269,21 @@ func (s fsStorage) StatVol(volume string) (volInfo VolInfo, err error) {
|
||||
}
|
||||
return VolInfo{}, err
|
||||
}
|
||||
// Get disk info, to be returned back along with volume info.
|
||||
var diskInfo disk.Info
|
||||
diskInfo, err = disk.GetInfo(s.diskPath)
|
||||
if err != nil {
|
||||
return VolInfo{}, err
|
||||
}
|
||||
// As os.Stat() doesn't carry other than ModTime(), use ModTime()
|
||||
// as CreatedTime.
|
||||
createdTime := st.ModTime()
|
||||
return VolInfo{
|
||||
Name: volume,
|
||||
Created: createdTime,
|
||||
Free: diskInfo.Free,
|
||||
Total: diskInfo.Total,
|
||||
FSType: diskInfo.FSType,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user