server: Fetch StorageInfo() from underlying disks transparently. (#2549)

Fixes #2511
master
Harshavardhana 8 years ago
parent fa6e9540a8
commit 339425fd52
  1. 4
      .travis.yml
  2. 5
      cmd/fs-v1.go
  3. 6
      cmd/posix.go
  4. 5
      cmd/storage-interface.go
  5. 15
      cmd/storage-rpc-client.go
  6. 15
      cmd/storage-rpc-server.go
  7. 18
      cmd/xl-v1.go

@ -4,9 +4,9 @@ language: go
os:
- linux
- osx
#- osx
osx_image: xcode7.2
#osx_image: xcode7.2
env:
- ARCH=x86_64

@ -26,7 +26,6 @@ import (
"sort"
"strings"
"github.com/minio/minio/pkg/disk"
"github.com/minio/minio/pkg/mimedb"
)
@ -146,8 +145,8 @@ func (fs fsObjects) Shutdown() error {
// StorageInfo - returns underlying storage statistics.
func (fs fsObjects) StorageInfo() StorageInfo {
info, err := disk.GetInfo(fs.physicalDisk)
fatalIf(err, "Unable to get disk info "+fs.physicalDisk)
info, err := fs.storage.DiskInfo()
errorIf(err, "Unable to get disk info %#v", fs.storage)
return StorageInfo{
Total: info.Total,
Free: info.Free,

@ -160,6 +160,12 @@ func checkDiskFree(diskPath string, minFreeDisk int64) (err error) {
return nil
}
// DiskInfo provides current information about disk space usage,
// total free inodes and underlying filesystem.
func (s *posix) DiskInfo() (info disk.Info, err error) {
return getDiskInfo(s.diskPath)
}
// getVolDir - will convert incoming volume names to
// corresponding valid volume names on the backend in a platform
// compatible way for all operating systems. If volume is not found

@ -16,8 +16,13 @@
package cmd
import "github.com/minio/minio/pkg/disk"
// StorageAPI interface.
type StorageAPI interface {
// Storage operations.
DiskInfo() (info disk.Info, err error)
// Volume operations.
MakeVol(volume string) (err error)
ListVols() (vols []VolInfo, err error)

@ -21,6 +21,8 @@ import (
"path"
"strconv"
"strings"
"github.com/minio/minio/pkg/disk"
)
type networkStorage struct {
@ -110,7 +112,16 @@ func newRPCClient(networkPath string) (StorageAPI, error) {
return ndisk, nil
}
// MakeVol - make a volume.
// DiskInfo - fetch disk information for a remote disk.
func (n networkStorage) DiskInfo() (info disk.Info, err error) {
args := GenericArgs{}
if err = n.rpcClient.Call("Storage.DiskInfoHandler", &args, &info); err != nil {
return disk.Info{}, err
}
return info, nil
}
// MakeVol - create a volume on a remote disk.
func (n networkStorage) MakeVol(volume string) error {
reply := GenericReply{}
args := GenericVolArgs{Vol: volume}
@ -120,7 +131,7 @@ func (n networkStorage) MakeVol(volume string) error {
return nil
}
// ListVols - List all volumes.
// ListVols - List all volumes on a remote disk.
func (n networkStorage) ListVols() (vols []VolInfo, err error) {
ListVols := ListVolsReply{}
err = n.rpcClient.Call("Storage.ListVolsHandler", &GenericArgs{}, &ListVols)

@ -24,6 +24,7 @@ import (
"strings"
router "github.com/gorilla/mux"
"github.com/minio/minio/pkg/disk"
)
// Storage server implements rpc primitives to facilitate exporting a
@ -53,7 +54,19 @@ func (s *storageServer) LoginHandler(args *RPCLoginArgs, reply *RPCLoginReply) e
return nil
}
/// Volume operations handlers
/// Storage operations handlers.
// DiskInfoHandler - disk info handler is rpc wrapper for DiskInfo operation.
func (s *storageServer) DiskInfoHandler(args *GenericArgs, reply *disk.Info) error {
if !isRPCTokenValid(args.Token) {
return errInvalidToken
}
info, err := s.storage.DiskInfo()
*reply = info
return err
}
/// Volume operations handlers.
// MakeVolHandler - make vol handler is rpc wrapper for MakeVol operation.
func (s *storageServer) MakeVolHandler(args *GenericVolArgs, reply *GenericReply) error {

@ -50,12 +50,11 @@ const (
// xlObjects - Implements XL object layer.
type xlObjects struct {
physicalDisks []string // Collection of regular disks.
storageDisks []StorageAPI // Collection of initialized backend disks.
dataBlocks int // dataBlocks count caculated for erasure.
parityBlocks int // parityBlocks count calculated for erasure.
readQuorum int // readQuorum minimum required disks to read data.
writeQuorum int // writeQuorum minimum required disks to write data.
storageDisks []StorageAPI // Collection of initialized backend disks.
dataBlocks int // dataBlocks count caculated for erasure.
parityBlocks int // parityBlocks count calculated for erasure.
readQuorum int // readQuorum minimum required disks to read data.
writeQuorum int // writeQuorum minimum required disks to write data.
// ListObjects pool management.
listPool *treeWalkPool
@ -186,7 +185,6 @@ func newXLObjects(disks, ignoredDisks []string) (ObjectLayer, error) {
// Initialize xl objects.
xl := xlObjects{
physicalDisks: disks,
storageDisks: newPosixDisks,
dataBlocks: dataBlocks,
parityBlocks: parityBlocks,
@ -222,10 +220,10 @@ func (d byDiskTotal) Less(i, j int) bool {
// StorageInfo - returns underlying storage statistics.
func (xl xlObjects) StorageInfo() StorageInfo {
var disksInfo []disk.Info
for _, diskPath := range xl.physicalDisks {
info, err := disk.GetInfo(diskPath)
for _, storageDisk := range xl.storageDisks {
info, err := storageDisk.DiskInfo()
if err != nil {
errorIf(err, "Unable to fetch disk info for "+diskPath)
errorIf(err, "Unable to fetch disk info for %#v", storageDisk)
continue
}
disksInfo = append(disksInfo, info)

Loading…
Cancel
Save