-
How to write after hitting a slice or creating a new slice is not well understood. Can someone help you understand it juicefs/pkg/chunk/cached_store.go Line 337 in f07634f func (c *wChunk) WriteAt(p []byte, off int64) (n int, err error) { // Fill previous blocks with zeros for n < len(p) {
} |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Basically this function is used to write data As wChunk is split to several Blocks for further writing to the object storage, The following figure may help you better understand the process:
|
Beta Was this translation helpful? Give feedback.
Basically this function is used to write data
p
to the slice (aka, wChunk). There is a fieldpages
in wChunk that is used to cache data, so what the function does is just splittingp
in an aligned way and copy bytes topages
.As wChunk is split to several Blocks for further writing to the object storage,
pages
is a list of memory blocks. For better memory management, the first block inpages
is split again to 64 KiB pages, in caselen(p)
is far smaller than BlockSize (defaults 4 MiB).The following figure may help you better understand the process: