2023-08-04 10:40:21 -07:00
|
|
|
// Copyright (c) 2015-2023 MinIO, Inc.
|
2021-04-18 12:41:13 -07:00
|
|
|
//
|
|
|
|
// 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-08 23:07:38 +05:30
|
|
|
|
2016-08-18 16:23:42 -07:00
|
|
|
package cmd
|
2016-04-08 23:07:38 +05:30
|
|
|
|
2021-10-04 17:01:52 +01:00
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"errors"
|
|
|
|
|
|
|
|
"github.com/minio/minio/internal/logger"
|
|
|
|
)
|
2021-02-17 15:34:42 -08:00
|
|
|
|
2023-08-04 10:40:21 -07:00
|
|
|
// errMaxVersionsExceeded return error beyond 10000 (default) versions per object
|
|
|
|
var errMaxVersionsExceeded = StorageErr("maximum versions exceeded, please delete few versions to proceed")
|
|
|
|
|
2016-05-28 15:13:15 -07:00
|
|
|
// errUnexpected - unexpected error, requires manual intervention.
|
2020-08-03 18:17:48 -07:00
|
|
|
var errUnexpected = StorageErr("unexpected error, please report this issue at https://github.com/minio/minio/issues")
|
2016-05-28 15:13:15 -07:00
|
|
|
|
2024-01-12 14:48:44 -08:00
|
|
|
// errCorruptedFormat - corrupted format.
|
|
|
|
var errCorruptedFormat = StorageErr("corrupted format")
|
|
|
|
|
|
|
|
// errCorruptedBackend - corrupted backend.
|
|
|
|
var errCorruptedBackend = StorageErr("corrupted backend")
|
2016-05-20 02:22:22 -07:00
|
|
|
|
|
|
|
// errUnformattedDisk - unformatted disk found.
|
2022-08-04 16:10:08 -07:00
|
|
|
var errUnformattedDisk = StorageErr("unformatted drive found")
|
2016-05-20 02:22:22 -07:00
|
|
|
|
2020-10-24 13:23:08 -07:00
|
|
|
// errInconsistentDisk - inconsistent disk found.
|
2022-08-04 16:10:08 -07:00
|
|
|
var errInconsistentDisk = StorageErr("inconsistent drive found")
|
2020-10-24 13:23:08 -07:00
|
|
|
|
2020-05-07 16:12:16 -07:00
|
|
|
// errUnsupporteDisk - when disk does not support O_DIRECT flag.
|
2022-08-04 16:10:08 -07:00
|
|
|
var errUnsupportedDisk = StorageErr("drive does not support O_DIRECT")
|
2020-05-07 16:12:16 -07:00
|
|
|
|
2016-04-19 02:42:10 -07:00
|
|
|
// errDiskFull - cannot create volume or files when disk is full.
|
2022-08-04 16:10:08 -07:00
|
|
|
var errDiskFull = StorageErr("drive path full")
|
2016-04-08 23:07:38 +05:30
|
|
|
|
2020-06-12 20:04:01 -07:00
|
|
|
// errDiskNotDir - cannot use storage disk if its not a directory
|
2022-08-04 16:10:08 -07:00
|
|
|
var errDiskNotDir = StorageErr("drive is not directory or mountpoint")
|
2020-06-12 20:04:01 -07:00
|
|
|
|
2017-08-11 11:38:46 -07:00
|
|
|
// errDiskNotFound - cannot find the underlying configured disk anymore.
|
2022-08-04 16:10:08 -07:00
|
|
|
var errDiskNotFound = StorageErr("drive not found")
|
2016-05-09 18:57:39 -07:00
|
|
|
|
2024-01-24 13:36:44 -08:00
|
|
|
// errDiskOngoingReq - indicates if the disk has an on-going request in progress.
|
2023-11-22 13:46:17 -08:00
|
|
|
var errDiskOngoingReq = StorageErr("drive still did not complete the request")
|
|
|
|
|
2024-01-24 13:36:44 -08:00
|
|
|
// errDriveIsRoot - cannot use the disk since its a root disk.
|
|
|
|
var errDriveIsRoot = StorageErr("drive is part of root drive, will not be used")
|
|
|
|
|
2016-11-20 16:57:12 -08:00
|
|
|
// errFaultyRemoteDisk - remote disk is faulty.
|
2022-08-04 16:10:08 -07:00
|
|
|
var errFaultyRemoteDisk = StorageErr("remote drive is faulty")
|
2016-11-20 16:57:12 -08:00
|
|
|
|
|
|
|
// errFaultyDisk - disk is faulty.
|
2022-08-04 16:10:08 -07:00
|
|
|
var errFaultyDisk = StorageErr("drive is faulty")
|
2016-11-20 16:57:12 -08:00
|
|
|
|
2016-07-02 01:59:28 -07:00
|
|
|
// errDiskAccessDenied - we don't have write permissions on disk.
|
2022-08-04 16:10:08 -07:00
|
|
|
var errDiskAccessDenied = StorageErr("drive access denied")
|
2016-07-02 01:59:28 -07:00
|
|
|
|
2016-04-08 23:07:38 +05:30
|
|
|
// errFileNotFound - cannot find the file.
|
2020-01-14 18:45:17 -08:00
|
|
|
var errFileNotFound = StorageErr("file not found")
|
2016-04-08 23:07:38 +05:30
|
|
|
|
2020-06-12 20:04:01 -07:00
|
|
|
// errFileNotFound - cannot find requested file version.
|
|
|
|
var errFileVersionNotFound = StorageErr("file version not found")
|
|
|
|
|
2019-05-02 07:09:57 -07:00
|
|
|
// errTooManyOpenFiles - too many open files.
|
2020-09-28 19:39:32 -07:00
|
|
|
var errTooManyOpenFiles = StorageErr("too many open files, please increase 'ulimit -n'")
|
2019-05-02 07:09:57 -07:00
|
|
|
|
2016-05-12 01:25:02 +05:30
|
|
|
// errFileNameTooLong - given file name is too long than supported length.
|
2020-01-14 18:45:17 -08:00
|
|
|
var errFileNameTooLong = StorageErr("file name too long")
|
2016-05-12 01:25:02 +05:30
|
|
|
|
2016-04-08 23:07:38 +05:30
|
|
|
// errVolumeExists - cannot create same volume again.
|
2020-01-14 18:45:17 -08:00
|
|
|
var errVolumeExists = StorageErr("volume already exists")
|
2016-04-08 23:07:38 +05:30
|
|
|
|
2016-04-24 00:36:00 -07:00
|
|
|
// errIsNotRegular - not of regular file type.
|
2020-01-14 18:45:17 -08:00
|
|
|
var errIsNotRegular = StorageErr("not of regular file type")
|
2016-04-08 23:07:38 +05:30
|
|
|
|
2021-01-02 21:01:29 +01:00
|
|
|
// errPathNotFound - cannot find the path.
|
|
|
|
var errPathNotFound = StorageErr("path not found")
|
|
|
|
|
2016-04-08 23:07:38 +05:30
|
|
|
// errVolumeNotFound - cannot find the volume.
|
2020-01-14 18:45:17 -08:00
|
|
|
var errVolumeNotFound = StorageErr("volume not found")
|
2016-04-13 11:32:47 -07:00
|
|
|
|
2016-04-16 12:48:41 -07:00
|
|
|
// errVolumeNotEmpty - volume not empty.
|
2020-01-14 18:45:17 -08:00
|
|
|
var errVolumeNotEmpty = StorageErr("volume is not empty")
|
2016-04-16 12:48:41 -07:00
|
|
|
|
2016-06-02 16:34:15 -07:00
|
|
|
// errVolumeAccessDenied - cannot access volume, insufficient permissions.
|
2020-01-14 18:45:17 -08:00
|
|
|
var errVolumeAccessDenied = StorageErr("volume access denied")
|
2016-04-13 11:32:47 -07:00
|
|
|
|
2019-03-20 13:06:53 -07:00
|
|
|
// errFileAccessDenied - cannot access file, insufficient permissions.
|
2020-01-14 18:45:17 -08:00
|
|
|
var errFileAccessDenied = StorageErr("file access denied")
|
2017-05-16 14:21:52 -07:00
|
|
|
|
2019-10-01 13:12:15 -07:00
|
|
|
// errFileCorrupt - file has an unexpected size, or is not readable
|
2020-01-14 18:45:17 -08:00
|
|
|
var errFileCorrupt = StorageErr("file is corrupted")
|
2019-07-13 00:29:44 +01:00
|
|
|
|
2017-05-16 14:21:52 -07:00
|
|
|
// errBitrotHashAlgoInvalid - the algo for bit-rot hash
|
|
|
|
// verification is empty or invalid.
|
2020-01-14 18:45:17 -08:00
|
|
|
var errBitrotHashAlgoInvalid = StorageErr("bit-rot hash algorithm is invalid")
|
2017-05-16 14:21:52 -07:00
|
|
|
|
2017-08-15 15:10:50 -07:00
|
|
|
// errCrossDeviceLink - rename across devices not allowed.
|
2020-01-14 18:45:17 -08:00
|
|
|
var errCrossDeviceLink = StorageErr("Rename across devices not allowed, please fix your backend configuration")
|
2017-08-15 15:10:50 -07:00
|
|
|
|
2018-08-06 15:14:08 -07:00
|
|
|
// errLessData - returned when less data available than what was requested.
|
2020-01-14 18:45:17 -08:00
|
|
|
var errLessData = StorageErr("less data available than what was requested")
|
2018-08-06 15:14:08 -07:00
|
|
|
|
2019-01-17 04:58:18 -08:00
|
|
|
// errMoreData = returned when more data was sent by the caller than what it was supposed to.
|
2020-01-14 18:45:17 -08:00
|
|
|
var errMoreData = StorageErr("more data was sent than what was advertised")
|
2019-01-17 04:58:18 -08:00
|
|
|
|
2021-02-17 15:34:42 -08:00
|
|
|
// indicates readDirFn to return without further applying the fn()
|
|
|
|
var errDoneForNow = errors.New("done for now")
|
|
|
|
|
|
|
|
// errSkipFile returned by the fn() for readDirFn() when it needs
|
|
|
|
// to proceed to next entry.
|
|
|
|
var errSkipFile = errors.New("skip this file")
|
|
|
|
|
2023-11-28 08:39:21 -08:00
|
|
|
var errIgnoreFileContrib = errors.New("ignore this file's contribution toward data-usage")
|
|
|
|
|
2022-05-30 10:58:37 -07:00
|
|
|
// errXLBackend XL drive mode requires fresh deployment.
|
2022-08-04 16:10:08 -07:00
|
|
|
var errXLBackend = errors.New("XL backend requires fresh drive")
|
2022-05-30 10:58:37 -07:00
|
|
|
|
2020-06-12 20:04:01 -07:00
|
|
|
// StorageErr represents error generated by xlStorage call.
|
2020-01-14 18:45:17 -08:00
|
|
|
type StorageErr string
|
2017-05-16 14:21:52 -07:00
|
|
|
|
2020-01-14 18:45:17 -08:00
|
|
|
func (h StorageErr) Error() string {
|
2019-10-01 13:12:15 -07:00
|
|
|
return string(h)
|
2017-05-16 14:21:52 -07:00
|
|
|
}
|
2017-11-25 11:58:29 -08:00
|
|
|
|
|
|
|
// Collection of basic errors.
|
|
|
|
var baseErrs = []error{
|
|
|
|
errDiskNotFound,
|
|
|
|
errFaultyDisk,
|
|
|
|
errFaultyRemoteDisk,
|
|
|
|
}
|
|
|
|
|
|
|
|
var baseIgnoredErrs = baseErrs
|
2020-06-12 20:04:01 -07:00
|
|
|
|
|
|
|
// Is a one place function which converts all os.PathError
|
|
|
|
// into a more FS object layer friendly form, converts
|
|
|
|
// known errors into their typed form for top level
|
|
|
|
// interpretation.
|
|
|
|
func osErrToFileErr(err error) error {
|
|
|
|
if err == nil {
|
|
|
|
return nil
|
|
|
|
}
|
2020-11-23 08:36:49 -08:00
|
|
|
if osIsNotExist(err) {
|
2020-06-12 20:04:01 -07:00
|
|
|
return errFileNotFound
|
|
|
|
}
|
2020-11-23 08:36:49 -08:00
|
|
|
if osIsPermission(err) {
|
2020-06-12 20:04:01 -07:00
|
|
|
return errFileAccessDenied
|
|
|
|
}
|
2021-02-22 01:36:17 -08:00
|
|
|
if isSysErrNotDir(err) || isSysErrIsDir(err) {
|
2020-06-12 20:04:01 -07:00
|
|
|
return errFileNotFound
|
|
|
|
}
|
|
|
|
if isSysErrPathNotFound(err) {
|
|
|
|
return errFileNotFound
|
|
|
|
}
|
|
|
|
if isSysErrTooManyFiles(err) {
|
|
|
|
return errTooManyOpenFiles
|
|
|
|
}
|
|
|
|
if isSysErrHandleInvalid(err) {
|
|
|
|
return errFileNotFound
|
|
|
|
}
|
2020-08-04 12:09:41 -07:00
|
|
|
if isSysErrIO(err) {
|
|
|
|
return errFaultyDisk
|
|
|
|
}
|
|
|
|
if isSysErrInvalidArg(err) {
|
2021-10-04 17:01:52 +01:00
|
|
|
logger.LogIf(context.Background(), err)
|
2021-09-30 11:53:01 -07:00
|
|
|
// For some odd calls with O_DIRECT reads
|
|
|
|
// filesystems can return EINVAL, handle
|
|
|
|
// these as FileNotFound instead.
|
|
|
|
return errFileNotFound
|
2020-08-04 12:09:41 -07:00
|
|
|
}
|
|
|
|
if isSysErrNoSpace(err) {
|
|
|
|
return errDiskFull
|
|
|
|
}
|
2020-06-12 20:04:01 -07:00
|
|
|
return err
|
|
|
|
}
|