Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

what will happen while update partial block? #64

Closed
wangtuanjie opened this issue Jun 3, 2015 · 2 comments
Closed

what will happen while update partial block? #64

wangtuanjie opened this issue Jun 3, 2015 · 2 comments
Labels

Comments

@wangtuanjie
Copy link
Contributor

通过 writeBlock(ws io.WriteSeeker, index, bs int64, p []byte),更新一个block。
当len(p)小于block size时,是什么语义?

  1. 算错误,直接返回
  2. 更新前len(p)字节,并重新计算整个block的crc
@yutongp
Copy link
Contributor

yutongp commented Jun 3, 2015

@yunxing @xiang90 @yichengq Let's revisit and settle on an agreement. At block level, do we allow partly write/read on blocks except the very last block in the file?

I thought our assumption is ReadAt and WriteAt always use readBlock and writeBlock with len(p) == bsize and this is exactly how our implementation currently works.

My opinion is allowing len(p) < bsize make readBlock and writeBlock more complicated and we don't even use this logic flow in practice... So maybe a simple solution which just return error and don't handle this case is better. My concern also applies on #52

@yunxing
Copy link
Contributor

yunxing commented Jun 4, 2015

@yutongp
If we don't allow partial block write, we need to keep the length of the file somewhere. The write path for the last block becomes:

  1. Create a block with payload
  2. Fill the rest of the block with zeros
  3. Append the block to the end
  4. Update the file length in some databases (which we haven't figure out yet).

The problem is step 3 and 4 are not atomic, which 3 succeeds and 4 fails, we have no way to know what the length of the payload is.

However, I guess in that case, we could just use the old value in the database as its file length.

@yichengq yichengq added this to the 7/26 meet point milestone Jul 12, 2015
@yunxing yunxing closed this as completed Aug 23, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants