Skip to content

Commit

Permalink
Fix TestReadWriteMinimumMemory after "header hack"
Browse files Browse the repository at this point in the history
  • Loading branch information
vitalif committed Oct 5, 2023
1 parent bee8a9b commit f12d113
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
7 changes: 4 additions & 3 deletions internal/goofys.go
Original file line number Diff line number Diff line change
Expand Up @@ -529,10 +529,11 @@ func (fs *Goofys) FDCloser() {
}

// Try to reclaim some clean buffers
func (fs *Goofys) FreeSomeCleanBuffers(size int64) (int64, bool) {
func (fs *Goofys) FreeSomeCleanBuffers(origSize int64) (int64, bool) {
freed := int64(0)
haveDirty := false
// Free at least 5 MB
size := origSize
if size < 5*1024*1024 {
size = 5*1024*1024
}
Expand Down Expand Up @@ -640,7 +641,7 @@ func (fs *Goofys) FreeSomeCleanBuffers(size int64) (int64, bool) {
}
}
}
} else {
} else if inode.fs.partNum(buf.offset+buf.length-1) != inode.fs.partNum(inode.lastWriteEnd) {
haveDirty = true
}
if del >= 0 {
Expand All @@ -658,7 +659,7 @@ func (fs *Goofys) FreeSomeCleanBuffers(size int64) (int64, bool) {
break
}
}
if haveDirty {
if freed < origSize && haveDirty {
fs.bufferPool.mu.Unlock()
atomic.AddInt32(&fs.wantFree, 1)
fs.WakeupFlusherAndWait(true)
Expand Down
7 changes: 2 additions & 5 deletions internal/goofys_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -628,11 +628,8 @@ func (s *GoofysTest) TestMultipartWriteAndTruncate(t *C) {
}

func (s *GoofysTest) TestReadWriteMinimumMemory(t *C) {
if _, ok := s.cloud.(*ADLv1); ok {
s.fs.bufferPool.max = 20*1024*1024
} else {
s.fs.bufferPool.max = 10*1024*1024
}
// First part is fixed for "header hack", last part is "still written to"
s.fs.bufferPool.max = 20*1024*1024
s.testWriteFile(t, "testLargeFile", 21*1024*1024, 128*1024)
}

Expand Down

0 comments on commit f12d113

Please sign in to comment.