Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable writes while initializing or growing volumes #209

Merged
merged 11 commits into from
Nov 15, 2023
8 changes: 4 additions & 4 deletions api/endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,15 +284,15 @@ func (a *api) handleGETContract(c jape.Context) {
}

func (a *api) handleGETVolume(c jape.Context) {
var id int
var id int64
if err := c.DecodeParam("id", &id); err != nil {
return
} else if id < 0 {
c.Error(errors.New("invalid volume id"), http.StatusBadRequest)
return
}

volume, err := a.volumes.Volume(int64(id))
volume, err := a.volumes.Volume(id)
if errors.Is(err, storage.ErrVolumeNotFound) {
c.Error(err, http.StatusNotFound)
return
Expand All @@ -303,7 +303,7 @@ func (a *api) handleGETVolume(c jape.Context) {
}

func (a *api) handlePUTVolume(c jape.Context) {
var id int
var id int64
if err := c.DecodeParam("id", &id); err != nil {
return
} else if id < 0 {
Expand All @@ -316,7 +316,7 @@ func (a *api) handlePUTVolume(c jape.Context) {
return
}

err := a.volumes.SetReadOnly(int64(id), req.ReadOnly)
err := a.volumes.SetReadOnly(id, req.ReadOnly)
if errors.Is(err, storage.ErrVolumeNotFound) {
c.Error(err, http.StatusNotFound)
return
Expand Down
12 changes: 6 additions & 6 deletions api/volumes.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ func (a *api) handlePOSTVolume(c jape.Context) {
}

func (a *api) handleDeleteVolume(c jape.Context) {
var id int
var id int64
var force bool
if err := c.DecodeParam("id", &id); err != nil {
return
Expand All @@ -163,12 +163,12 @@ func (a *api) handleDeleteVolume(c jape.Context) {
} else if err := c.DecodeForm("force", &force); err != nil {
return
}
err := a.volumeJobs.RemoveVolume(int64(id), force)
err := a.volumeJobs.RemoveVolume(id, force)
a.checkServerError(c, "failed to remove volume", err)
}

func (a *api) handlePUTVolumeResize(c jape.Context) {
var id int
var id int64
if err := c.DecodeParam("id", &id); err != nil {
return
} else if id < 0 {
Expand All @@ -181,19 +181,19 @@ func (a *api) handlePUTVolumeResize(c jape.Context) {
return
}

err := a.volumeJobs.ResizeVolume(int64(id), req.MaxSectors)
err := a.volumeJobs.ResizeVolume(id, req.MaxSectors)
a.checkServerError(c, "failed to resize volume", err)
}

func (a *api) handleDELETEVolumeCancelOp(c jape.Context) {
var id int
var id int64
if err := c.DecodeParam("id", &id); err != nil {
return
} else if id < 0 {
c.Error(errors.New("invalid volume id"), http.StatusBadRequest)
return
}

err := a.volumeJobs.Cancel(int64(id))
err := a.volumeJobs.Cancel(id)
a.checkServerError(c, "failed to cancel operation", err)
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/mattn/go-sqlite3 v1.14.17
gitlab.com/NebulousLabs/encoding v0.0.0-20200604091946-456c3dc907fe
go.sia.tech/core v0.1.12-0.20231011160830-b58e9e8ec3ce
go.sia.tech/jape v0.9.1-0.20230525021720-ecf031ecbffb
go.sia.tech/jape v0.10.0
go.sia.tech/renterd v0.6.0
go.sia.tech/siad v1.5.10-0.20230228235644-3059c0b930ca
go.sia.tech/web/hostd v0.26.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,8 @@ go.sia.tech/core v0.1.12-0.20231011160830-b58e9e8ec3ce h1:rRji+HxWtZEyXAyc/LSqS4
go.sia.tech/core v0.1.12-0.20231011160830-b58e9e8ec3ce/go.mod h1:3EoY+rR78w1/uGoXXVqcYdwSjSJKuEMI5bL7WROA27Q=
go.sia.tech/jape v0.9.1-0.20230525021720-ecf031ecbffb h1:yLDEqkqC19E/HgBoq2Uhw9oH3SMNRyeRjZ7Ep4dPKR8=
go.sia.tech/jape v0.9.1-0.20230525021720-ecf031ecbffb/go.mod h1:4QqmBB+t3W7cNplXPj++ZqpoUb2PeiS66RLpXmEGap4=
go.sia.tech/jape v0.10.0 h1:wsIURirNV29fvqxhvvbd0yhKh+9JeNZvz4haJUL/+yI=
go.sia.tech/jape v0.10.0/go.mod h1:4QqmBB+t3W7cNplXPj++ZqpoUb2PeiS66RLpXmEGap4=
go.sia.tech/mux v1.2.0 h1:ofa1Us9mdymBbGMY2XH/lSpY8itFsKIo/Aq8zwe+GHU=
go.sia.tech/mux v1.2.0/go.mod h1:Yyo6wZelOYTyvrHmJZ6aQfRoer3o4xyKQ4NmQLJrBSo=
go.sia.tech/renterd v0.6.0 h1:eEWftx9xOvYVeGCejmyTopxKAql+KvnHxh1kMk5GEAo=
Expand Down
2 changes: 2 additions & 0 deletions host/storage/consts_default.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@ package storage
import "time"

const (
resizeBatchSize = 64 // 256 MiB

cleanupInterval = 15 * time.Minute
)
2 changes: 2 additions & 0 deletions host/storage/consts_testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ package storage

const (
cleanupInterval = 0

resizeBatchSize = 4 // 16 MiB
)
2 changes: 1 addition & 1 deletion host/storage/recorder.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"go.uber.org/zap"
)

const flushInterval = 30 * time.Second
const flushInterval = time.Minute

type (
sectorAccessRecorder struct {
Expand Down
Loading