Skip to content

Commit

Permalink
add space for no margin
Browse files Browse the repository at this point in the history
  • Loading branch information
mohammadVatandoost committed Oct 12, 2021
1 parent 1f3d7e4 commit f1a8b06
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
19 changes: 9 additions & 10 deletions IO.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,15 @@ func (fse *FSEngine) Write(data []byte, fileID uint32, previousBlock uint32) (in
n := 0
var err error
var blocksID []uint32
if fse.cleaning == 0 {
blmArrayLen := len(fse.header.GetBLMArray())
if blmArrayLen > int(float64(fse.maxNumberOfBlocks)*0.9) {
fse.log.Infov("Cleaning Begin due to Space requirement",
"blmArrayLen", blmArrayLen)
// atomic.StoreUint32(&fse.cleaning, 1)
fse.NoSpace()
}
}
for {
if n >= dataSize {
if n == dataSize {
Expand Down Expand Up @@ -120,16 +129,6 @@ func (fse *FSEngine) Write(data []byte, fileID uint32, previousBlock uint32) (in
"blockID", blockID, "fileID", fileID)
return 0, []uint32{}, err
}
// ToDo: test seperatego routine
//if fse.cleaning == 0 {
// blmArrayLen := len(fse.header.GetBLMArray())
// if blmArrayLen > int(float64(fse.maxNumberOfBlocks)*0.9) {
// fse.log.Infov("Cleaning Begin due to Space requirement",
// "blmArrayLen", blmArrayLen)
// atomic.StoreUint32(&fse.cleaning, 1)
// go fse.NoSpace()
// }
//}

blocksID = append(blocksID, blockID)
if m != len(d) {
Expand Down
5 changes: 4 additions & 1 deletion blocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ import (
)

func (fse *FSEngine) NoSpace() uint32 {
//ToDo: test seperatego routine
//defer func() {
// atomic.StoreUint32(&fse.cleaning, 0)
// err := fse.header.UpdateFSHeader()
// if err != nil {
// fse.log.Info("can not update fs header in no space")
// }
//}()
counter := 0
for {
Expand Down
4 changes: 2 additions & 2 deletions file.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ type FSEngine struct {
crudMutex sync.Mutex
Cache *lru.Cache
eventsHandler Events
// cleaning uint32
Quit chan struct{}
cleaning uint32
Quit chan struct{}
}

// Close ...
Expand Down

0 comments on commit f1a8b06

Please sign in to comment.