Skip to content

Commit

Permalink
Merge pull request #209 from SiaFoundation/nate/no-lock-volume-grow
Browse files Browse the repository at this point in the history
Enable writes while initializing or growing volumes
  • Loading branch information
n8maninger committed Nov 15, 2023
2 parents a9c197a + c59e085 commit 069cb08
Show file tree
Hide file tree
Showing 10 changed files with 401 additions and 216 deletions.
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

0 comments on commit 069cb08

Please sign in to comment.