2023-08-04 17:40:21 +00:00
|
|
|
// Copyright (c) 2015-2023 MinIO, Inc.
|
2021-04-18 19:41:13 +00: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 17:37:38 +00:00
|
|
|
|
2016-08-18 23:23:42 +00:00
|
|
|
package cmd
|
2016-04-08 17:37:38 +00:00
|
|
|
|
2021-10-04 16:01:52 +00:00
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"errors"
|
|
|
|
|
|
|
|
"github.com/minio/minio/internal/logger"
|
|
|
|
)
|
2021-02-17 23:34:42 +00:00
|
|
|
|
2023-08-04 17:40:21 +00: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 22:13:15 +00:00
|
|
|
// errUnexpected - unexpected error, requires manual intervention.
|
2020-08-04 01:17:48 +00:00
|
|
|
var errUnexpected = StorageErr("unexpected error, please report this issue at https://github.com/minio/minio/issues")
|
2016-05-28 22:13:15 +00:00
|
|
|
|
2016-05-20 09:22:22 +00:00
|
|
|
// errCorruptedFormat - corrupted backend format.
|
2022-08-04 23:10:08 +00:00
|
|
|
var errCorruptedFormat = StorageErr("corrupted backend format, specified drive mount has unexpected previous content")
|
2016-05-20 09:22:22 +00:00
|
|
|
|
|
|
|
// errUnformattedDisk - unformatted disk found.
|
2022-08-04 23:10:08 +00:00
|
|
|
var errUnformattedDisk = StorageErr("unformatted drive found")
|
2016-05-20 09:22:22 +00:00
|
|
|
|
2020-10-24 20:23:08 +00:00
|
|
|
// errInconsistentDisk - inconsistent disk found.
|
2022-08-04 23:10:08 +00:00
|
|
|
var errInconsistentDisk = StorageErr("inconsistent drive found")
|
2020-10-24 20:23:08 +00:00
|
|
|
|
2020-05-07 23:12:16 +00:00
|
|
|
// errUnsupporteDisk - when disk does not support O_DIRECT flag.
|
2022-08-04 23:10:08 +00:00
|
|
|
var errUnsupportedDisk = StorageErr("drive does not support O_DIRECT")
|
2020-05-07 23:12:16 +00:00
|
|
|
|
2016-04-19 09:42:10 +00:00
|
|
|
// errDiskFull - cannot create volume or files when disk is full.
|
2022-08-04 23:10:08 +00:00
|
|
|
var errDiskFull = StorageErr("drive path full")
|
2016-04-08 17:37:38 +00:00
|
|
|
|
2020-06-13 03:04:01 +00:00
|
|
|
// errDiskNotDir - cannot use storage disk if its not a directory
|
2022-08-04 23:10:08 +00:00
|
|
|
var errDiskNotDir = StorageErr("drive is not directory or mountpoint")
|
2020-06-13 03:04:01 +00:00
|
|
|
|
2017-08-11 18:38:46 +00:00
|
|
|
// errDiskNotFound - cannot find the underlying configured disk anymore.
|
2022-08-04 23:10:08 +00:00
|
|
|
var errDiskNotFound = StorageErr("drive not found")
|
2016-05-10 01:57:39 +00:00
|
|
|
|
2016-11-21 00:57:12 +00:00
|
|
|
// errFaultyRemoteDisk - remote disk is faulty.
|
2022-08-04 23:10:08 +00:00
|
|
|
var errFaultyRemoteDisk = StorageErr("remote drive is faulty")
|
2016-11-21 00:57:12 +00:00
|
|
|
|
|
|
|
// errFaultyDisk - disk is faulty.
|
2022-08-04 23:10:08 +00:00
|
|
|
var errFaultyDisk = StorageErr("drive is faulty")
|
2016-11-21 00:57:12 +00:00
|
|
|
|
2016-07-02 08:59:28 +00:00
|
|
|
// errDiskAccessDenied - we don't have write permissions on disk.
|
2022-08-04 23:10:08 +00:00
|
|
|
var errDiskAccessDenied = StorageErr("drive access denied")
|
2016-07-02 08:59:28 +00:00
|
|
|
|
2016-04-08 17:37:38 +00:00
|
|
|
// errFileNotFound - cannot find the file.
|
2020-01-15 02:45:17 +00:00
|
|
|
var errFileNotFound = StorageErr("file not found")
|
2016-04-08 17:37:38 +00:00
|
|
|
|
2020-06-13 03:04:01 +00:00
|
|
|
// errFileNotFound - cannot find requested file version.
|
|
|
|
var errFileVersionNotFound = StorageErr("file version not found")
|
|
|
|
|
2019-05-02 14:09:57 +00:00
|
|
|
// errTooManyOpenFiles - too many open files.
|
2020-09-29 02:39:32 +00:00
|
|
|
var errTooManyOpenFiles = StorageErr("too many open files, please increase 'ulimit -n'")
|
2019-05-02 14:09:57 +00:00
|
|
|
|
2016-05-11 19:55:02 +00:00
|
|
|
// errFileNameTooLong - given file name is too long than supported length.
|
2020-01-15 02:45:17 +00:00
|
|
|
var errFileNameTooLong = StorageErr("file name too long")
|
2016-05-11 19:55:02 +00:00
|
|
|
|
2016-04-08 17:37:38 +00:00
|
|
|
// errVolumeExists - cannot create same volume again.
|
2020-01-15 02:45:17 +00:00
|
|
|
var errVolumeExists = StorageErr("volume already exists")
|
2016-04-08 17:37:38 +00:00
|
|
|
|
2016-04-24 07:36:00 +00:00
|
|
|
// errIsNotRegular - not of regular file type.
|
2020-01-15 02:45:17 +00:00
|
|
|
var errIsNotRegular = StorageErr("not of regular file type")
|
2016-04-08 17:37:38 +00:00
|
|
|
|
2021-01-02 20:01:29 +00:00
|
|
|
// errPathNotFound - cannot find the path.
|
|
|
|
var errPathNotFound = StorageErr("path not found")
|
|
|
|
|
2016-04-08 17:37:38 +00:00
|
|
|
// errVolumeNotFound - cannot find the volume.
|
2020-01-15 02:45:17 +00:00
|
|
|
var errVolumeNotFound = StorageErr("volume not found")
|
2016-04-13 18:32:47 +00:00
|
|
|
|
2016-04-16 19:48:41 +00:00
|
|
|
// errVolumeNotEmpty - volume not empty.
|
2020-01-15 02:45:17 +00:00
|
|
|
var errVolumeNotEmpty = StorageErr("volume is not empty")
|
2016-04-16 19:48:41 +00:00
|
|
|
|
2016-06-02 23:34:15 +00:00
|
|
|
// errVolumeAccessDenied - cannot access volume, insufficient permissions.
|
2020-01-15 02:45:17 +00:00
|
|
|
var errVolumeAccessDenied = StorageErr("volume access denied")
|
2016-04-13 18:32:47 +00:00
|
|
|
|
2019-03-20 20:06:53 +00:00
|
|
|
// errFileAccessDenied - cannot access file, insufficient permissions.
|
2020-01-15 02:45:17 +00:00
|
|
|
var errFileAccessDenied = StorageErr("file access denied")
|
2017-05-16 21:21:52 +00:00
|
|
|
|
2019-10-01 20:12:15 +00:00
|
|
|
// errFileCorrupt - file has an unexpected size, or is not readable
|
2020-01-15 02:45:17 +00:00
|
|
|
var errFileCorrupt = StorageErr("file is corrupted")
|
2019-07-12 23:29:44 +00:00
|
|
|
|
2017-05-16 21:21:52 +00:00
|
|
|
// errBitrotHashAlgoInvalid - the algo for bit-rot hash
|
|
|
|
// verification is empty or invalid.
|
2020-01-15 02:45:17 +00:00
|
|
|
var errBitrotHashAlgoInvalid = StorageErr("bit-rot hash algorithm is invalid")
|
2017-05-16 21:21:52 +00:00
|
|
|
|
2017-08-15 22:10:50 +00:00
|
|
|
// errCrossDeviceLink - rename across devices not allowed.
|
2020-01-15 02:45:17 +00:00
|
|
|
var errCrossDeviceLink = StorageErr("Rename across devices not allowed, please fix your backend configuration")
|
2017-08-15 22:10:50 +00:00
|
|
|
|
2018-08-06 22:14:08 +00:00
|
|
|
// errLessData - returned when less data available than what was requested.
|
2020-01-15 02:45:17 +00:00
|
|
|
var errLessData = StorageErr("less data available than what was requested")
|
2018-08-06 22:14:08 +00:00
|
|
|
|
2019-01-17 12:58:18 +00:00
|
|
|
// errMoreData = returned when more data was sent by the caller than what it was supposed to.
|
2020-01-15 02:45:17 +00:00
|
|
|
var errMoreData = StorageErr("more data was sent than what was advertised")
|
2019-01-17 12:58:18 +00:00
|
|
|
|
2021-02-17 23:34:42 +00: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")
|
|
|
|
|
2022-05-30 17:58:37 +00:00
|
|
|
// errXLBackend XL drive mode requires fresh deployment.
|
2022-08-04 23:10:08 +00:00
|
|
|
var errXLBackend = errors.New("XL backend requires fresh drive")
|
2022-05-30 17:58:37 +00:00
|
|
|
|
2020-06-13 03:04:01 +00:00
|
|
|
// StorageErr represents error generated by xlStorage call.
|
2020-01-15 02:45:17 +00:00
|
|
|
type StorageErr string
|
2017-05-16 21:21:52 +00:00
|
|
|
|
2020-01-15 02:45:17 +00:00
|
|
|
func (h StorageErr) Error() string {
|
2019-10-01 20:12:15 +00:00
|
|
|
return string(h)
|
2017-05-16 21:21:52 +00:00
|
|
|
}
|
2017-11-25 19:58:29 +00:00
|
|
|
|
|
|
|
// Collection of basic errors.
|
|
|
|
var baseErrs = []error{
|
|
|
|
errDiskNotFound,
|
|
|
|
errFaultyDisk,
|
|
|
|
errFaultyRemoteDisk,
|
|
|
|
}
|
|
|
|
|
|
|
|
var baseIgnoredErrs = baseErrs
|
2020-06-13 03:04:01 +00: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 16:36:49 +00:00
|
|
|
if osIsNotExist(err) {
|
2020-06-13 03:04:01 +00:00
|
|
|
return errFileNotFound
|
|
|
|
}
|
2020-11-23 16:36:49 +00:00
|
|
|
if osIsPermission(err) {
|
2020-06-13 03:04:01 +00:00
|
|
|
return errFileAccessDenied
|
|
|
|
}
|
2021-02-22 09:36:17 +00:00
|
|
|
if isSysErrNotDir(err) || isSysErrIsDir(err) {
|
2020-06-13 03:04:01 +00:00
|
|
|
return errFileNotFound
|
|
|
|
}
|
|
|
|
if isSysErrPathNotFound(err) {
|
|
|
|
return errFileNotFound
|
|
|
|
}
|
|
|
|
if isSysErrTooManyFiles(err) {
|
|
|
|
return errTooManyOpenFiles
|
|
|
|
}
|
|
|
|
if isSysErrHandleInvalid(err) {
|
|
|
|
return errFileNotFound
|
|
|
|
}
|
2020-08-04 19:09:41 +00:00
|
|
|
if isSysErrIO(err) {
|
|
|
|
return errFaultyDisk
|
|
|
|
}
|
|
|
|
if isSysErrInvalidArg(err) {
|
2021-10-04 16:01:52 +00:00
|
|
|
logger.LogIf(context.Background(), err)
|
2021-09-30 18:53:01 +00:00
|
|
|
// For some odd calls with O_DIRECT reads
|
|
|
|
// filesystems can return EINVAL, handle
|
|
|
|
// these as FileNotFound instead.
|
|
|
|
return errFileNotFound
|
2020-08-04 19:09:41 +00:00
|
|
|
}
|
|
|
|
if isSysErrNoSpace(err) {
|
|
|
|
return errDiskFull
|
|
|
|
}
|
2020-06-13 03:04:01 +00:00
|
|
|
return err
|
|
|
|
}
|