btrfs / btrfs-todo

An issues only repo to organize our TODO items
21 stars 2 forks source link

Handle NODATASUM better with DATA_RELOC inode #27

Open josefbacik opened 2 years ago

josefbacik commented 2 years ago

Currently when we do the DATA_RELOC inode we'll copy in data extents to the reloc inode, and then copy them back to where they belong. However if we evict those pages we'll have to re-read them from the DATA_RELOC inode.

If we are relocating a NODATASUM extent this won't have checksums, however we don't keep track of that anywhere, so we treat any missing checksum on a DATA_RELOC inode as being part of an inode that had NODATASUM set.

This is definitely the normal case, however there could be a bug where we really should have a csum, and we won't know there was a problem until we go to re-read the original inode and can no longer find the csum for that inode.

We should fix this to look up the inode we're relocating the data for and check and see if it's got NODATASUM set, and then set NODATASUM on the range for the DATA_RELOC inode. This way we won't actually try to look up the csum for this range in the first place, and then we can treat any missing csum at read time as a real bug.