Opened 7 years ago

Closed 7 years ago

#8889 closed enhancement (invalid)

Wrong data read from discarded block if transaction isn't flushed

Reported by: ahenriksson Owned by: axeld
Priority: normal Milestone: R1
Component: System/Kernel Version: R1/Development
Keywords: block cache Cc: axeld
Blocked By: Blocking:
Has a Patch: yes Platform: All


If a block has been discarded, but is still in an unflushed transaction, old cached data will be read instead of the data on the disk.

Attached is some code to reproduce the problem (can also be seen as a more detailed problem description), as well as my attempt at fixing it.

Attachments (2)

0001-Code-to-reproduce-block-cache-problem-with-discarded.patch (1.9 KB ) - added by ahenriksson 7 years ago.
0001-Handle-discarded-blocks-in-unflushed-transaction.patch (1.8 KB ) - added by ahenriksson 7 years ago.

Download all attachments as: .zip

Change History (8)

comment:1 by ahenriksson, 7 years ago

Has a Patch: set

comment:2 by anevilyak, 7 years ago

Milestone: R1R1/alpha4
Priority: normalhigh

comment:3 by ahenriksson, 7 years ago

Hrm, it seems like a cached_block ending up in this situation doesn't necessarily have a transaction, so the patch is wrong. Will have to investigate some more.

comment:4 by axeld, 7 years ago

Milestone: R1/alpha4R1
Priority: highnormal
Type: bugenhancement

AFAICT you are misusing block_cache_discard(): what the function tries to achieve is that the on disk block will not be written to anymore afterwards. While the block is removed when it is no longer used, it doesn't mean it's actually being removed. You are not supposed to mess with the disk directly when you are using the block cache -- you can't assume to find the actual on disk contents of that block after it has been discarded. From the POV of the block cache, the contents of that block are known to be irrelevant now.

The current functionality is needed only to make sure that the file cache and the block cache do not interfere with each other.

What is it that you are trying to do here? Why do you need to mess with the contents of the disk directly? In any case, if you need that functionality, you would need to add it.

comment:5 by ahenriksson, 7 years ago

I see, I suppose I was a bit hasty in taking it to the bug tracker. The problem I'm trying to solve is using write_pos() when moving files, where the blocks happen to be in the block cache, but I thought (wrongly) that the issue would affect other things as well. I'll add a "block_cache_forget()" function for this instead.

In any case, this report is invalid, thanks for having a look though.

comment:6 by korli, 7 years ago

Resolution: invalid
Status: newclosed
Note: See TracTickets for help on using tickets.