2021-04-18 15:41:13 -04:00
|
|
|
// Copyright (c) 2015-2021 MinIO, Inc.
|
|
|
|
//
|
|
|
|
// This file is part of MinIO Object Storage stack
|
|
|
|
//
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU Affero General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU Affero General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Affero General Public License
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2016-04-07 22:01:15 -04:00
|
|
|
|
2016-08-18 19:23:42 -04:00
|
|
|
package cmd
|
2016-04-07 22:01:15 -04:00
|
|
|
|
2017-08-14 21:08:42 -04:00
|
|
|
import (
|
2020-03-18 19:19:29 -04:00
|
|
|
"context"
|
2017-08-14 21:08:42 -04:00
|
|
|
"io"
|
2021-05-11 12:19:15 -04:00
|
|
|
"time"
|
2022-04-07 11:10:40 -04:00
|
|
|
|
2023-06-19 20:53:08 -04:00
|
|
|
"github.com/minio/madmin-go/v3"
|
2017-08-14 21:08:42 -04:00
|
|
|
)
|
2016-08-25 20:16:34 -04:00
|
|
|
|
2016-04-07 22:01:15 -04:00
|
|
|
// StorageAPI interface.
|
|
|
|
type StorageAPI interface {
|
2016-10-05 15:48:07 -04:00
|
|
|
// Stringified version of disk.
|
|
|
|
String() string
|
|
|
|
|
2016-08-25 20:16:34 -04:00
|
|
|
// Storage operations.
|
2021-05-11 12:19:15 -04:00
|
|
|
|
2022-03-09 14:38:54 -05:00
|
|
|
// Returns true if disk is online and its valid i.e valid format.json.
|
|
|
|
// This has nothing to do with if the drive is hung or not responding.
|
|
|
|
// For that individual storage API calls will fail properly. The purpose
|
|
|
|
// of this function is to know if the "drive" has "format.json" or not
|
|
|
|
// if it has a "format.json" then is it correct "format.json" or not.
|
|
|
|
IsOnline() bool
|
|
|
|
|
|
|
|
// Returns the last time this disk (re)-connected
|
|
|
|
LastConn() time.Time
|
|
|
|
|
|
|
|
// Indicates if disk is local or not.
|
2020-05-19 17:27:20 -04:00
|
|
|
IsLocal() bool
|
2020-09-28 22:39:32 -04:00
|
|
|
|
2022-03-09 14:38:54 -05:00
|
|
|
// Returns hostname if disk is remote.
|
|
|
|
Hostname() string
|
|
|
|
|
|
|
|
// Returns the entire endpoint.
|
|
|
|
Endpoint() Endpoint
|
|
|
|
|
|
|
|
// Close the disk, mark it purposefully closed, only implemented for remote disks.
|
2018-02-15 20:45:57 -05:00
|
|
|
Close() error
|
2022-03-09 14:38:54 -05:00
|
|
|
|
|
|
|
// Returns the unique 'uuid' of this disk.
|
2020-05-28 16:03:04 -04:00
|
|
|
GetDiskID() (string, error)
|
2022-03-09 14:38:54 -05:00
|
|
|
|
|
|
|
// Set a unique 'uuid' for this disk, only used when
|
|
|
|
// disk is replaced and formatted.
|
2019-10-25 13:37:53 -04:00
|
|
|
SetDiskID(id string)
|
2022-03-09 14:38:54 -05:00
|
|
|
|
|
|
|
// Returns healing information for a newly replaced disk,
|
|
|
|
// returns 'nil' once healing is complete or if the disk
|
|
|
|
// has never been replaced.
|
|
|
|
Healing() *healingTracker
|
2024-01-25 15:45:46 -05:00
|
|
|
DiskInfo(ctx context.Context, opts DiskInfoOptions) (info DiskInfo, err error)
|
2024-01-02 16:51:24 -05:00
|
|
|
NSScanner(ctx context.Context, cache dataUsageCache, updates chan<- dataUsageEntry, scanMode madmin.HealScanMode, shouldSleep func() bool) (dataUsageCache, error)
|
2016-08-25 20:16:34 -04:00
|
|
|
|
2016-04-07 22:01:15 -04:00
|
|
|
// Volume operations.
|
2020-09-04 12:45:06 -04:00
|
|
|
MakeVol(ctx context.Context, volume string) (err error)
|
|
|
|
MakeVolBulk(ctx context.Context, volumes ...string) (err error)
|
|
|
|
ListVols(ctx context.Context) (vols []VolInfo, err error)
|
|
|
|
StatVol(ctx context.Context, volume string) (vol VolInfo, err error)
|
|
|
|
DeleteVol(ctx context.Context, volume string, forceDelete bool) (err error)
|
2016-04-07 22:01:15 -04:00
|
|
|
|
2020-10-28 12:18:35 -04:00
|
|
|
// WalkDir will walk a directory on disk and return a metacache stream on wr.
|
|
|
|
WalkDir(ctx context.Context, opts WalkDirOptions, wr io.Writer) error
|
|
|
|
|
2020-06-12 23:04:01 -04:00
|
|
|
// Metadata operations
|
2023-12-29 18:52:41 -05:00
|
|
|
DeleteVersion(ctx context.Context, volume, path string, fi FileInfo, forceDelMarker bool, opts DeleteOptions) error
|
|
|
|
DeleteVersions(ctx context.Context, volume string, versions []FileInfoVersions, opts DeleteOptions) []error
|
2024-01-30 15:43:25 -05:00
|
|
|
WriteMetadata(ctx context.Context, origvolume, volume, path string, fi FileInfo) error
|
2023-08-25 10:58:11 -04:00
|
|
|
UpdateMetadata(ctx context.Context, volume, path string, fi FileInfo, opts UpdateMetadataOpts) error
|
2024-01-30 15:43:25 -05:00
|
|
|
ReadVersion(ctx context.Context, origvolume, volume, path, versionID string, opts ReadOptions) (FileInfo, error)
|
2022-04-20 15:49:05 -04:00
|
|
|
ReadXL(ctx context.Context, volume, path string, readData bool) (RawFileInfo, error)
|
2024-04-23 13:15:52 -04:00
|
|
|
RenameData(ctx context.Context, srcVolume, srcPath string, fi FileInfo, dstVolume, dstPath string, opts RenameOptions) (RenameDataResp, error)
|
2020-06-12 23:04:01 -04:00
|
|
|
|
2016-04-07 22:01:15 -04:00
|
|
|
// File operations.
|
2024-01-30 15:43:25 -05:00
|
|
|
ListDir(ctx context.Context, origvolume, volume, dirPath string, count int) ([]string, error)
|
2020-09-04 12:45:06 -04:00
|
|
|
ReadFile(ctx context.Context, volume string, path string, offset int64, buf []byte, verifier *BitrotVerifier) (n int64, err error)
|
|
|
|
AppendFile(ctx context.Context, volume string, path string, buf []byte) (err error)
|
2024-01-30 15:43:25 -05:00
|
|
|
CreateFile(ctx context.Context, origvolume, olume, path string, size int64, reader io.Reader) error
|
2020-09-04 12:45:06 -04:00
|
|
|
ReadFileStream(ctx context.Context, volume, path string, offset, length int64) (io.ReadCloser, error)
|
|
|
|
RenameFile(ctx context.Context, srcVolume, srcPath, dstVolume, dstPath string) error
|
|
|
|
CheckParts(ctx context.Context, volume string, path string, fi FileInfo) error
|
2023-12-29 18:52:41 -05:00
|
|
|
Delete(ctx context.Context, volume string, path string, opts DeleteOptions) (err error)
|
2020-09-04 12:45:06 -04:00
|
|
|
VerifyFile(ctx context.Context, volume, path string, fi FileInfo) error
|
2021-10-01 14:50:00 -04:00
|
|
|
StatInfoFile(ctx context.Context, volume, path string, glob bool) (stat []StatInfo, err error)
|
2022-07-19 11:35:29 -04:00
|
|
|
ReadMultiple(ctx context.Context, req ReadMultipleReq, resp chan<- ReadMultipleResp) error
|
2022-11-28 13:20:55 -05:00
|
|
|
CleanAbandonedData(ctx context.Context, volume string, path string) error
|
2016-06-25 17:51:06 -04:00
|
|
|
|
2018-11-14 09:18:35 -05:00
|
|
|
// Write all data, syncs the data to disk.
|
2020-11-02 19:14:31 -05:00
|
|
|
// Should be used for smaller payloads.
|
|
|
|
WriteAll(ctx context.Context, volume string, path string, b []byte) (err error)
|
2018-11-14 09:18:35 -05:00
|
|
|
|
2016-06-25 17:51:06 -04:00
|
|
|
// Read all.
|
2020-09-04 12:45:06 -04:00
|
|
|
ReadAll(ctx context.Context, volume string, path string) (buf []byte, err error)
|
2021-03-04 17:36:23 -05:00
|
|
|
GetDiskLoc() (poolIdx, setIdx, diskIdx int) // Retrieve location indexes.
|
2016-04-07 22:01:15 -04:00
|
|
|
}
|