diff --git a/.travis.yml b/.travis.yml index d046c1b7a..082b333b0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,9 +4,9 @@ language: go os: - linux -- osx +#- osx -osx_image: xcode7.2 +#osx_image: xcode7.2 env: - ARCH=x86_64 diff --git a/cmd/fs-v1.go b/cmd/fs-v1.go index 8927f7e89..9ca856b8e 100644 --- a/cmd/fs-v1.go +++ b/cmd/fs-v1.go @@ -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, diff --git a/cmd/posix.go b/cmd/posix.go index 29f8c93ce..e0ce58f11 100644 --- a/cmd/posix.go +++ b/cmd/posix.go @@ -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 diff --git a/cmd/storage-interface.go b/cmd/storage-interface.go index db1380186..566ebbf5c 100644 --- a/cmd/storage-interface.go +++ b/cmd/storage-interface.go @@ -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) diff --git a/cmd/storage-rpc-client.go b/cmd/storage-rpc-client.go index 3788d30d3..795c64d3a 100644 --- a/cmd/storage-rpc-client.go +++ b/cmd/storage-rpc-client.go @@ -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) diff --git a/cmd/storage-rpc-server.go b/cmd/storage-rpc-server.go index 3357327b7..8b733a2e5 100644 --- a/cmd/storage-rpc-server.go +++ b/cmd/storage-rpc-server.go @@ -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 { diff --git a/cmd/xl-v1.go b/cmd/xl-v1.go index dd030d89f..b2c4e8d1d 100644 --- a/cmd/xl-v1.go +++ b/cmd/xl-v1.go @@ -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)