Re: [PATCH v2 0/1] bcache: track active bypass writes to prevent stale cache reads

From: Coly Li

Date: Wed Jun 17 2026 - 07:08:49 EST


> 2026年6月17日 18:33,Ankit Kapoor <ankitkap@xxxxxxxxxx> 写道:
>
> Hi Coly,
>
> This is v2 of the patch to fix a race condition between read cache
> misses and bypass writes.
>
> Changes in v2:
> Instead of deferring key invalidation, we now explicitly track active
> bypass writes using dynamically allocated pages (modeled closely after
> md-bitmap.c as suggested by Coly). We use this tracking information
> during cache miss reads to determine if the read must also bypass the
> cache.
>
> The active bypass writes are tracked by dividing the backing device
> space into 32MB chunks and maintaining concurrent write refcounts. The
> memory overhead is minimal; a single 4KB page covers 64 GB of backing
> device space in the chosen approach.
>
> Implementation Approaches Evaluated:
> When designing this, we evaluated three synchronization approaches:
> 1. Global Spinlock
> 2. Page-level Spinlock (Chosen Approach)
> 3. Atomic Counters (Lockless)

Thanks, patch received. I will response you after reviewed them.

Coly Li