mirror of
https://github.com/minio/minio.git
synced 2025-11-09 21:49:46 -05:00
Add storage layer contexts (#10321)
Add context to all (non-trivial) calls to the storage layer. Contexts are propagated through the REST client. - `context.TODO()` is left in place for the places where it needs to be added to the caller. - `endWalkCh` could probably be removed from the walkers, but no changes so far. The "dangerous" part is that now a caller disconnecting *will* propagate down, so a "delete" operation will now be interrupted. In some cases we might want to disconnect this functionality so the operation completes if it has started, leaving the system in a cleaner state.
This commit is contained in:
@@ -35,47 +35,47 @@ type StorageAPI interface {
|
||||
GetDiskID() (string, error)
|
||||
SetDiskID(id string)
|
||||
|
||||
DiskInfo() (info DiskInfo, err error)
|
||||
DiskInfo(ctx context.Context) (info DiskInfo, err error)
|
||||
CrawlAndGetDataUsage(ctx context.Context, cache dataUsageCache) (dataUsageCache, error)
|
||||
|
||||
// Volume operations.
|
||||
MakeVol(volume string) (err error)
|
||||
MakeVolBulk(volumes ...string) (err error)
|
||||
ListVols() (vols []VolInfo, err error)
|
||||
StatVol(volume string) (vol VolInfo, err error)
|
||||
DeleteVol(volume string, forceDelete bool) (err error)
|
||||
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)
|
||||
|
||||
// WalkVersions in sorted order directly on disk.
|
||||
WalkVersions(volume, dirPath string, marker string, recursive bool, endWalkCh <-chan struct{}) (chan FileInfoVersions, error)
|
||||
WalkVersions(ctx context.Context, volume, dirPath, marker string, recursive bool, endWalkCh <-chan struct{}) (chan FileInfoVersions, error)
|
||||
// Walk in sorted order directly on disk.
|
||||
Walk(volume, dirPath string, marker string, recursive bool, endWalkCh <-chan struct{}) (chan FileInfo, error)
|
||||
Walk(ctx context.Context, volume, dirPath, marker string, recursive bool, endWalkCh <-chan struct{}) (chan FileInfo, error)
|
||||
// Walk in sorted order directly on disk.
|
||||
WalkSplunk(volume, dirPath string, marker string, endWalkCh <-chan struct{}) (chan FileInfo, error)
|
||||
WalkSplunk(ctx context.Context, volume, dirPath, marker string, endWalkCh <-chan struct{}) (chan FileInfo, error)
|
||||
|
||||
// Metadata operations
|
||||
DeleteVersion(volume, path string, fi FileInfo) error
|
||||
DeleteVersions(volume string, versions []FileInfo) []error
|
||||
WriteMetadata(volume, path string, fi FileInfo) error
|
||||
ReadVersion(volume, path, versionID string) (FileInfo, error)
|
||||
RenameData(srcVolume, srcPath, dataDir, dstVolume, dstPath string) error
|
||||
DeleteVersion(ctx context.Context, volume, path string, fi FileInfo) error
|
||||
DeleteVersions(ctx context.Context, volume string, versions []FileInfo) []error
|
||||
WriteMetadata(ctx context.Context, volume, path string, fi FileInfo) error
|
||||
ReadVersion(ctx context.Context, volume, path, versionID string) (FileInfo, error)
|
||||
RenameData(ctx context.Context, srcVolume, srcPath, dataDir, dstVolume, dstPath string) error
|
||||
|
||||
// File operations.
|
||||
ListDir(volume, dirPath string, count int) ([]string, error)
|
||||
ReadFile(volume string, path string, offset int64, buf []byte, verifier *BitrotVerifier) (n int64, err error)
|
||||
AppendFile(volume string, path string, buf []byte) (err error)
|
||||
CreateFile(volume, path string, size int64, reader io.Reader) error
|
||||
ReadFileStream(volume, path string, offset, length int64) (io.ReadCloser, error)
|
||||
RenameFile(srcVolume, srcPath, dstVolume, dstPath string) error
|
||||
CheckParts(volume string, path string, fi FileInfo) error
|
||||
CheckFile(volume string, path string) (err error)
|
||||
DeleteFile(volume string, path string) (err error)
|
||||
VerifyFile(volume, path string, fi FileInfo) error
|
||||
ListDir(ctx context.Context, volume, dirPath string, count int) ([]string, error)
|
||||
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)
|
||||
CreateFile(ctx context.Context, volume, path string, size int64, reader io.Reader) error
|
||||
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
|
||||
CheckFile(ctx context.Context, volume string, path string) (err error)
|
||||
DeleteFile(ctx context.Context, volume string, path string) (err error)
|
||||
VerifyFile(ctx context.Context, volume, path string, fi FileInfo) error
|
||||
|
||||
// Write all data, syncs the data to disk.
|
||||
WriteAll(volume string, path string, reader io.Reader) (err error)
|
||||
WriteAll(ctx context.Context, volume string, path string, reader io.Reader) (err error)
|
||||
|
||||
// Read all.
|
||||
ReadAll(volume string, path string) (buf []byte, err error)
|
||||
ReadAll(ctx context.Context, volume string, path string) (buf []byte, err error)
|
||||
}
|
||||
|
||||
// storageReader is an io.Reader view of a disk
|
||||
@@ -86,7 +86,7 @@ type storageReader struct {
|
||||
}
|
||||
|
||||
func (r *storageReader) Read(p []byte) (n int, err error) {
|
||||
nn, err := r.storage.ReadFile(r.volume, r.path, r.offset, p, nil)
|
||||
nn, err := r.storage.ReadFile(context.TODO(), r.volume, r.path, r.offset, p, nil)
|
||||
r.offset += nn
|
||||
n = int(nn)
|
||||
|
||||
@@ -103,7 +103,7 @@ type storageWriter struct {
|
||||
}
|
||||
|
||||
func (w *storageWriter) Write(p []byte) (n int, err error) {
|
||||
err = w.storage.AppendFile(w.volume, w.path, p)
|
||||
err = w.storage.AppendFile(context.TODO(), w.volume, w.path, p)
|
||||
if err == nil {
|
||||
n = len(p)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user