Skip to content

Commit

Permalink
bugfix: fix some cold volume bug
Browse files Browse the repository at this point in the history
1. remove ebs-access path check
2. update datapartition after opening a cold file
3. cold files use TinyExtent when offset + size <= 1M

Signed-off-by: lixiang12407 <[email protected]>
  • Loading branch information
LeeLX authored and Victor1319 committed Apr 13, 2022
1 parent 4d74bcb commit 8782656
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 11 deletions.
6 changes: 0 additions & 6 deletions client/fuse.go
Original file line number Diff line number Diff line change
Expand Up @@ -780,11 +780,5 @@ func loadConfFromMaster(opt *proto.MountOptions) (err error) {
}
opt.EbsEndpoint = clusterInfo.EbsAddr
opt.EbsServicePath = clusterInfo.ServicePath
if proto.IsCold(opt.VolType) {
if opt.EbsBlockSize == 0 || opt.EbsEndpoint == "" || opt.EbsServicePath == "" {
return errors.New("cold volume ebs config is empty.")
}
log.LogDebugf("ebs config: EbsEndpoint(%v) EbsServicePath(%v) EbsBlockSize(%v)", opt.EbsEndpoint, opt.EbsServicePath, opt.EbsBlockSize)
}
return
}
4 changes: 4 additions & 0 deletions sdk/data/blobstore/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ func NewReader(config ClientConfig) (reader *Reader) {
reader.fileCache = config.FileCache
reader.cacheThreshold = config.CacheThreshold

if proto.IsCold(reader.volType) {
reader.ec.UpdateDataPartitionForColdVolume()
}

return
}

Expand Down
4 changes: 4 additions & 0 deletions sdk/data/stream/extent_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -468,3 +468,7 @@ func (client *ExtentClient) GetDataPartitionForWrite() error {
_, err := client.dataWrapper.GetDataPartitionForWrite(exclude)
return err
}

func (client *ExtentClient) UpdateDataPartitionForColdVolume() error {
return client.dataWrapper.UpdateDataPartition()
}
18 changes: 13 additions & 5 deletions sdk/data/stream/stream_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -408,12 +408,20 @@ func (s *Streamer) doWrite(data []byte, offset, size int, direct bool) (total in
storeMode int
)

// Small files are usually written in a single write, so use tiny extent
// store only for the first write operation.
if offset > 0 {
storeMode = proto.NormalExtentType
if proto.IsCold(s.client.volumeType) {
if offset + size > s.tinySizeLimit() {
storeMode = proto.NormalExtentType
} else {
storeMode = proto.TinyExtentType
}
} else {
storeMode = proto.TinyExtentType
// Small files are usually written in a single write, so use tiny extent
// store only for the first write operation.
if offset > 0 {
storeMode = proto.NormalExtentType
} else {
storeMode = proto.TinyExtentType
}
}

log.LogDebugf("doWrite enter: ino(%v) offset(%v) size(%v) storeMode(%v)", s.inode, offset, size, storeMode)
Expand Down
4 changes: 4 additions & 0 deletions sdk/data/wrapper/wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,10 @@ func (w *Wrapper) updateDataPartition(isInit bool) (err error) {
return w.updateDataPartitionByRsp(isInit, dpv.DataPartitions)
}

func (w *Wrapper) UpdateDataPartition() (err error) {
return w.updateDataPartition(false)
}

// getDataPartition will call master to get data partition info which not include in cache updated by
// updateDataPartition which may not take effect if nginx be placed for reduce the pressure of master
func (w *Wrapper) getDataPartition(isInit bool, dpId uint64) (err error) {
Expand Down

0 comments on commit 8782656

Please sign in to comment.