Skip to content

Commit

Permalink
select all blobbers if read is free (#1398)
Browse files Browse the repository at this point in the history
* select all blobbers if read is free

* fix remaining mask
  • Loading branch information
Hitenjain14 authored Feb 21, 2024
1 parent 9c4901f commit 3e80614
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
3 changes: 3 additions & 0 deletions zboxcore/sdk/allocation.go
Original file line number Diff line number Diff line change
Expand Up @@ -1151,6 +1151,9 @@ func (a *Allocation) processReadMarker(drs []*DownloadRequest) {
wg.Add(1)
go func(dr *DownloadRequest) {
defer wg.Done()
if isReadFree {
dr.freeRead = true
}
dr.processDownloadRequest()
var pos uint64
if !dr.skip {
Expand Down
14 changes: 9 additions & 5 deletions zboxcore/sdk/downloadworker.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ type DownloadRequest struct {
size int64
offset int64
bufferMap map[int]*zboxutil.DownloadBuffer
freeRead bool
}

type blockData struct {
Expand Down Expand Up @@ -179,7 +180,11 @@ func (req *DownloadRequest) downloadBlock(
skipDownload bool
)

for i := req.downloadMask; !i.Equals64(0); i = i.And(zboxutil.NewUint128(1).Lsh(pos).Not()) {
for i := mask; !i.Equals64(0); i = i.And(zboxutil.NewUint128(1).Lsh(pos).Not()) {
if c == requiredDownloads {
remainingMask = i
break
}
pos = uint64(i.TrailingZeros())
blockDownloadReq := &BlockDownloadRequest{
allocationID: req.allocationID,
Expand Down Expand Up @@ -220,10 +225,6 @@ func (req *DownloadRequest) downloadBlock(
}

c++
if c == requiredDownloads {
remainingMask = i
break
}
}

var failed int32
Expand Down Expand Up @@ -1025,6 +1026,9 @@ func (req *DownloadRequest) getFileMetaConsensus(fMetaResp []*fileMetaResponse)
if countThreshold > req.fullconsensus {
countThreshold = req.consensusThresh
}
if req.freeRead {
countThreshold = req.fullconsensus
}
for i := 0; i < len(fMetaResp); i++ {
fmr := fMetaResp[i]
if fmr.err != nil || fmr.fileref == nil {
Expand Down

0 comments on commit 3e80614

Please sign in to comment.