Skip to content

Commit

Permalink
Changes required for Silo refactoring loopholelabs/silo#42
Browse files Browse the repository at this point in the history
Signed-off-by: Jimmy Moore <jamesmoore@loopholelabs.io>
  • Loading branch information
jimmyaxod committed Oct 30, 2024
1 parent 1f612a8 commit fceb264
Show file tree
Hide file tree
Showing 11 changed files with 78 additions and 83 deletions.
17 changes: 10 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ go 1.22.5

toolchain go1.22.6

replace github.com/loopholelabs/silo => ../silo/

require (
github.com/coreos/go-iptables v0.8.0
github.com/freddierice/go-losetup/v2 v2.0.1
Expand Down Expand Up @@ -37,20 +39,21 @@ require (
github.com/golang/snappy v0.0.4 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/hashicorp/hcl/v2 v2.20.0 // indirect
github.com/hashicorp/hcl/v2 v2.21.0 // indirect
github.com/jmoiron/sqlx v1.4.0 // indirect
github.com/josharian/native v1.1.0 // indirect
github.com/klauspost/cpuid/v2 v2.2.8 // indirect
github.com/lib/pq v1.10.9 // indirect
github.com/loopholelabs/logging v0.3.1 // indirect
github.com/mdlayher/genetlink v1.3.2 // indirect
github.com/mdlayher/netlink v1.7.2 // indirect
github.com/mdlayher/socket v0.4.1 // indirect
github.com/minio/md5-simd v1.1.2 // indirect
github.com/minio/minio-go/v7 v7.0.73 // indirect
github.com/minio/minio-go/v7 v7.0.77 // indirect
github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7 // indirect
github.com/montanaflynn/stats v0.7.1 // indirect
github.com/redis/go-redis/v9 v9.6.1 // indirect
github.com/rs/xid v1.5.0 // indirect
github.com/rs/xid v1.6.0 // indirect
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
github.com/xdg-go/scram v1.1.2 // indirect
github.com/xdg-go/stringprep v1.0.4 // indirect
Expand All @@ -63,11 +66,11 @@ require (
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
go4.org/netipx v0.0.0-20231129151722-fdeea329fbba // indirect
golang.org/x/crypto v0.25.0 // indirect
golang.org/x/crypto v0.26.0 // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/net v0.27.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/text v0.16.0 // indirect
golang.org/x/net v0.28.0 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/text v0.17.0 // indirect
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240604185151-ef581f913117 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240604185151-ef581f913117 // indirect
Expand Down
44 changes: 18 additions & 26 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/hashicorp/hcl/v2 v2.20.0 h1:l++cRs/5jQOiKVvqXZm/P1ZEfVXJmvLS9WSVxkaeTb4=
github.com/hashicorp/hcl/v2 v2.20.0/go.mod h1:WmcD/Ym72MDOOx5F62Ly+leloeu6H7m0pG7VBiU6pQk=
github.com/hashicorp/hcl/v2 v2.21.0 h1:lve4q/o/2rqwYOgUg3y3V2YPyD1/zkCLGjIV74Jit14=
github.com/hashicorp/hcl/v2 v2.21.0/go.mod h1:62ZYHrXgPoX8xBnzl8QzbWq4dyDsDtfCRgIq1rbJEvA=
github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU=
github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
github.com/jmoiron/sqlx v1.4.0 h1:1PLqN7S1UYp5t4SrVVnt4nUVNemrDAtxlulVe+Qgm3o=
Expand All @@ -107,20 +107,14 @@ github.com/klauspost/compress v1.17.11/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90
github.com/klauspost/cpuid/v2 v2.0.1/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
github.com/klauspost/cpuid/v2 v2.2.8 h1:+StwCXwm9PdpiEkPyzBXIy+M9KUb4ODm0Zarf1kS5BM=
github.com/klauspost/cpuid/v2 v2.2.8/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348 h1:MtvEpTB6LX3vkb4ax0b5D2DHbNAUsen0Gx5wZoq3lV4=
github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k=
github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/lithammer/shortuuid/v4 v4.0.0 h1:QRbbVkfgNippHOS8PXDkti4NaWeyYfcBTHtw7k08o4c=
github.com/lithammer/shortuuid/v4 v4.0.0/go.mod h1:Zs8puNcrvf2rV9rTH51ZLLcj7ZXqQI3lv67aw4KiB1Y=
github.com/loopholelabs/goroutine-manager v0.1.1 h1:qpN9XcfNKp7aw8YI3YoIisCWZHK7/bAdnXs28ZhkM70=
github.com/loopholelabs/goroutine-manager v0.1.1/go.mod h1:d0r+/HNqnDR/6AXv4Mbz0dJZ7P0nATksCjkt5WWDsqA=
github.com/loopholelabs/silo v0.0.8 h1:fsqm6VQDlFJt65wo1LCBaAlsGrSjTNGBNP2ypJAWP+A=
github.com/loopholelabs/silo v0.0.8/go.mod h1:fzq0X9KAWGPCWK4uZ96DgF9Ed+eu9wBmpB5ZX64OHMk=
github.com/loopholelabs/logging v0.3.1 h1:VA9DF3WrbmvJC1uQJ/XcWgz8KWXydWwe3BdDiMbN2FY=
github.com/loopholelabs/logging v0.3.1/go.mod h1:uRDUydiqPqKbZkb0WoQ3dfyAcJ2iOMhxdEafZssLVv0=
github.com/lufia/plan9stats v0.0.0-20240513124658-fba389f38bae h1:dIZY4ULFcto4tAFlj1FYZl8ztUZ13bdq+PLY+NOfbyI=
github.com/lufia/plan9stats v0.0.0-20240513124658-fba389f38bae/go.mod h1:ilwx/Dta8jXAgpFYFvSWEMwxmbWXyiUHkd5FwyKhb5k=
github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY=
Expand All @@ -137,8 +131,8 @@ github.com/metal-stack/go-ipam v1.14.0 h1:rz2sJkDt+ugzrT6JylD+NfCN/f6eZuG+WVqbcx
github.com/metal-stack/go-ipam v1.14.0/go.mod h1:zwqaFJWzMs3iMY5v0+h9UeTAq6MHqAzPNnkKxNpwCqY=
github.com/minio/md5-simd v1.1.2 h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34=
github.com/minio/md5-simd v1.1.2/go.mod h1:MzdKDxYpY2BT9XQFocsiZf/NKVtR7nkE4RoEpN+20RM=
github.com/minio/minio-go/v7 v7.0.73 h1:qr2vi96Qm7kZ4v7LLebjte+MQh621fFWnv93p12htEo=
github.com/minio/minio-go/v7 v7.0.73/go.mod h1:qydcVzV8Hqtj1VtEocfxbmVFa2siu6HGa+LDEPogjD8=
github.com/minio/minio-go/v7 v7.0.77 h1:GaGghJRg9nwDVlNbwYjSDJT1rqltQkBFDsypWX1v3Bw=
github.com/minio/minio-go/v7 v7.0.77/go.mod h1:AVM3IUN6WwKzmwBxVdjzhH8xq+f57JSbbvzqvUzR6eg=
github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7 h1:DpOJ2HYzCv8LZP15IdmG+YdwD2luVPHITV96TkirNBM=
github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo=
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
Expand Down Expand Up @@ -175,12 +169,8 @@ github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 h1:o4JXh1EVt
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE=
github.com/redis/go-redis/v9 v9.6.1 h1:HHDteefn6ZkTtY5fGUE8tj8uy85AHk6zP7CpzIAM0y4=
github.com/redis/go-redis/v9 v9.6.1/go.mod h1:0C0c6ycQsdpVNQpxb1njEQIqkx5UcsM8FJCQLgE9+RA=
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
github.com/rs/xid v1.5.0 h1:mKX4bl4iPYJtEIxp6CYiUuLQ/8DYMoz0PUdtGgMFRVc=
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ=
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
github.com/rs/xid v1.6.0 h1:fV591PaemRlL6JfRxGDEPl69wICngIQ3shQtzfy2gxU=
github.com/rs/xid v1.6.0/go.mod h1:7XoLgs4eV+QndskICGsho+ADou8ySMSjJKDIan90Nz0=
github.com/shirou/gopsutil/v3 v3.24.5 h1:i0t8kL+kQTvpAYToeuiVk3TgDeKOFioZO3Ztz/iZ9pI=
github.com/shirou/gopsutil/v3 v3.24.5/go.mod h1:bsoOS1aStSs9ErQ1WWfxllSeS1K5D+U30r2NfcubMVk=
github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFtM=
Expand Down Expand Up @@ -221,6 +211,8 @@ github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo
github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
github.com/zclconf/go-cty v1.13.0 h1:It5dfKTTZHe9aeppbNOda3mN7Ag7sg6QkBNm6TkyFa0=
github.com/zclconf/go-cty v1.13.0/go.mod h1:YKQzy/7pZ7iq2jNFzy5go57xdxdWoLLpaEp4u238AE0=
github.com/zclconf/go-cty-debug v0.0.0-20240509010212-0d6042c53940 h1:4r45xpDWB6ZMSMNJFMOjqrGHynW3DIBuR2H9j0ug+Mo=
github.com/zclconf/go-cty-debug v0.0.0-20240509010212-0d6042c53940/go.mod h1:CmBdvvj3nqzfzJ6nTCIwDTPZ56aVGvDrmztiO5g3qrM=
go.etcd.io/etcd/api/v3 v3.5.14 h1:vHObSCxyB9zlF60w7qzAdTcGaglbJOpSj1Xj9+WGxq0=
go.etcd.io/etcd/api/v3 v3.5.14/go.mod h1:BmtWcRlQvwa1h3G2jvKYwIQy4PkHlDej5t7uLMUdJUU=
go.etcd.io/etcd/client/pkg/v3 v3.5.14 h1:SaNH6Y+rVEdxfpA2Jr5wkEvN6Zykme5+YnbCkxvuWxQ=
Expand Down Expand Up @@ -249,8 +241,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30=
golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M=
golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw=
golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54=
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
Expand All @@ -262,14 +254,14 @@ golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLL
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys=
golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE=
golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE=
golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190606203320-7fc4e5ec1444/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
Expand All @@ -287,8 +279,8 @@ golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc=
golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
Expand Down
18 changes: 9 additions & 9 deletions pkg/mounter/migrate_from.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,22 +115,22 @@ func MigrateFromAndMount(

stage2InputsLock sync.Mutex

pro *protocol.ProtocolRW
pro *protocol.RW
)
if len(readers) > 0 && len(writers) > 0 { // Only open the protocol if we want passed in readers and writers
pro = protocol.NewProtocolRW(
pro = protocol.NewRW(
protocolCtx, // We don't track this because we return the wait function
readers,
writers,
func(ctx context.Context, p protocol.Protocol, index uint32) {
var (
from *protocol.FromProtocol
local *waitingcache.WaitingCacheLocal
local *waitingcache.Local
)
from = protocol.NewFromProtocol(
ctx,
index,
func(di *packets.DevInfo) storage.StorageProvider {
func(di *packets.DevInfo) storage.Provider {
// No need to `defer goroutineManager.HandlePanics` here - panics bubble upwards

base := ""
Expand Down Expand Up @@ -161,7 +161,7 @@ func MigrateFromAndMount(
System: "file",
Location: base,
Size: fmt.Sprintf("%v", di.Size),
BlockSize: fmt.Sprintf("%v", di.Block_size),
BlockSize: fmt.Sprintf("%v", di.BlockSize),
Expose: true,
})
if err != nil {
Expand All @@ -171,8 +171,8 @@ func MigrateFromAndMount(
deviceCloseFuncs = append(deviceCloseFuncs, device.Shutdown) // defer device.Shutdown()
deviceCloseFuncsLock.Unlock()

var remote *waitingcache.WaitingCacheRemote
local, remote = waitingcache.NewWaitingCache(src, int(di.Block_size))
var remote *waitingcache.Remote
local, remote = waitingcache.NewWaitingCache(src, int(di.BlockSize))
local.NeedAt = func(offset int64, length int32) {
// Only access the `from` protocol if it's not already closed
select {
Expand Down Expand Up @@ -206,7 +206,7 @@ func MigrateFromAndMount(
migratedMounter.stage2Inputs = append(migratedMounter.stage2Inputs, migrateFromAndMountStage{
name: di.Name,

blockSize: di.Block_size,
blockSize: di.BlockSize,

id: index,
remote: true,
Expand Down Expand Up @@ -419,7 +419,7 @@ func MigrateFromAndMount(
}

var (
local storage.StorageProvider
local storage.Provider
dev storage.ExposedStorage
)
if strings.TrimSpace(input.Overlay) == "" || strings.TrimSpace(input.State) == "" {
Expand Down
14 changes: 7 additions & 7 deletions pkg/mounter/migrate_to.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func (migratableMounter *MigratableMounter) MigrateTo(
defer goroutineManager.StopAllGoroutines()
defer goroutineManager.CreateBackgroundPanicCollector()()

pro := protocol.NewProtocolRW(
pro := protocol.NewRW(
goroutineManager.Context(),
readers,
writers,
Expand Down Expand Up @@ -189,14 +189,14 @@ func (migratableMounter *MigratableMounter) MigrateTo(
}
})

cfg := migrator.NewMigratorConfig().WithBlockSize(int(input.prev.prev.prev.blockSize))
cfg := migrator.NewConfig().WithBlockSize(int(input.prev.prev.prev.blockSize))
cfg.Concurrency = map[int]int{
storage.BlockTypeAny: concurrency,
storage.BlockTypeStandard: concurrency,
storage.BlockTypeDirty: concurrency,
storage.BlockTypePriority: concurrency,
}
cfg.Locker_handler = func() {
cfg.LockerHandler = func() {
defer goroutineManager.CreateBackgroundPanicCollector()()

if err := to.SendEvent(&packets.Event{
Expand All @@ -213,7 +213,7 @@ func (migratableMounter *MigratableMounter) MigrateTo(
panic(errors.Join(ErrCouldNotSendPostLockEvent, err))
}
}
cfg.Unlocker_handler = func() {
cfg.UnlockerHandler = func() {
defer goroutineManager.CreateBackgroundPanicCollector()()

if err := to.SendEvent(&packets.Event{
Expand All @@ -230,16 +230,16 @@ func (migratableMounter *MigratableMounter) MigrateTo(
panic(errors.Join(ErrCouldNotSendPostUnlockEvent, err))
}
}
cfg.Error_handler = func(b *storage.BlockInfo, err error) {
cfg.ErrorHandler = func(b *storage.BlockInfo, err error) {
defer goroutineManager.CreateBackgroundPanicCollector()()

if err != nil {
panic(errors.Join(registry.ErrCouldNotContinueWithMigration, err))
}
}
cfg.Progress_handler = func(p *migrator.MigrationProgress) {
cfg.ProgressHandler = func(p *migrator.MigrationProgress) {
if hook := hooks.OnDeviceInitialMigrationProgress; hook != nil {
hook(uint32(index), input.prev.prev.prev.remote, p.Ready_blocks, p.Total_blocks)
hook(uint32(index), input.prev.prev.prev.remote, p.ReadyBlocks, p.TotalBlocks)
}
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/mounter/stages.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type migrateFromAndMountStage struct {
id uint32
remote bool

storage storage.StorageProvider
storage storage.Provider
device storage.ExposedStorage
}

Expand All @@ -31,7 +31,7 @@ type makeMigratableDeviceStage struct {
storage *modules.Lockable
orderer *blocks.PriorityBlockOrder
totalBlocks int
dirtyRemote *dirtytracker.DirtyTrackerRemote
dirtyRemote *dirtytracker.Remote
}

type migrateToStage struct {
Expand Down
18 changes: 9 additions & 9 deletions pkg/peer/migrate_from.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,22 +109,22 @@ func (peer *Peer[L, R, G]) MigrateFrom(

stage2InputsLock sync.Mutex

pro *protocol.ProtocolRW
pro *protocol.RW
)
if len(readers) > 0 && len(writers) > 0 { // Only open the protocol if we want passed in readers and writers
pro = protocol.NewProtocolRW(
pro = protocol.NewRW(
protocolCtx, // We don't track this because we return the wait function
readers,
writers,
func(ctx context.Context, p protocol.Protocol, index uint32) {
var (
from *protocol.FromProtocol
local *waitingcache.WaitingCacheLocal
local *waitingcache.Local
)
from = protocol.NewFromProtocol(
ctx,
index,
func(di *packets.DevInfo) storage.StorageProvider {
func(di *packets.DevInfo) storage.Provider {
// No need to `defer goroutineManager.HandlePanics` here - panics bubble upwards

base := ""
Expand Down Expand Up @@ -155,7 +155,7 @@ func (peer *Peer[L, R, G]) MigrateFrom(
System: "file",
Location: base,
Size: fmt.Sprintf("%v", di.Size),
BlockSize: fmt.Sprintf("%v", di.Block_size),
BlockSize: fmt.Sprintf("%v", di.BlockSize),
Expose: true,
})
if err != nil {
Expand All @@ -167,8 +167,8 @@ func (peer *Peer[L, R, G]) MigrateFrom(
deviceCloseFuncs = append(deviceCloseFuncs, peer.runner.Close) // defer runner.Close()
deviceCloseFuncsLock.Unlock()

var remote *waitingcache.WaitingCacheRemote
local, remote = waitingcache.NewWaitingCache(src, int(di.Block_size))
var remote *waitingcache.Remote
local, remote = waitingcache.NewWaitingCache(src, int(di.BlockSize))
local.NeedAt = func(offset int64, length int32) {
// Only access the `from` protocol if it's not already closed
select {
Expand Down Expand Up @@ -202,7 +202,7 @@ func (peer *Peer[L, R, G]) MigrateFrom(
migratedPeer.stage2Inputs = append(migratedPeer.stage2Inputs, migrateFromStage{
name: di.Name,

blockSize: di.Block_size,
blockSize: di.BlockSize,

id: index,
remote: true,
Expand Down Expand Up @@ -452,7 +452,7 @@ func (peer *Peer[L, R, G]) MigrateFrom(
}

var (
local storage.StorageProvider
local storage.Provider
dev storage.ExposedStorage
)
if strings.TrimSpace(input.Overlay) == "" || strings.TrimSpace(input.State) == "" {
Expand Down
Loading

0 comments on commit fceb264

Please sign in to comment.