Checksum verification during a file read #17062
-
Hello, I was wondering how the checksum is verified during a file read. Assume a linux user is reading a file from the dataset. If I understand correctly, the zfs will get the target dnode according to the linux vfs inode. And the zio tree will be constructed in the following order: root zio -> zio read on dnode -> zio read on indirect node(s) -> zio read on file data If my understanding is correct, is the checksum verification starts from the target file data and goes up to the dnode? Thanks for your help. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
ZIO tree is not built all at once the way you describe it, but the idea is right. Since checksum is a part of any block pointer, any read can be verified. The moment you import the pool, you implicitly trust one single block pointer stored in uberblock. After that every new block pointer you use to read something is stored in some other block that you have already verified with checksums from its respective block pointer, etc. So the chain of protection is: Data block -> indirect block(s) -> dnodes block -> dnodes indirect block(s) -> objset -> ... -> meta-objset -> ... -> uberblock. But verification obviously starts from uberblock and goes the opposite way to the data block, since you can not trust any information from a block that is not verified yet. |
Beta Was this translation helpful? Give feedback.
@Jinnan-Guo It is spread. To issue that single read operation, we should have got its block pointer somewhere earlier. Which means we should have verified a checksum of a block where the pointer was stored, etc all the way up to uberblock read at the time of import. We don't need to verify again what we already verified once.