Re: [PATCH 1/9] bcache: get rid of discard code from journal

"Coly Li" <[email protected]> Fri, 14 Nov 2025 17:03:27 +0800
Newsgroups org.kernel.vger.linux-bcache
Message-ID <[email protected]>
> 2025年11月14日 14:50,[email protected] 写道:
> 
> Hi Coly:
>  
> AFAICT SSD use write-after-erase mode to reuse a ssd block for writing and
> internally ssd firmware will gc those to be discarded blocks for future writes.
> so even write to a same logical bcache bucket it won’t be mapped to the same 
> physical ssd block, because ssd always needs a clean block for writing. 
>  
> So IMHO the discard op does have its function role, it could tell the firmware 
> to gc that bucket immediately while I’m not sure if we gain performance benefit
> from such journal discard ops.
>  
> Perhaps I misunderstood something, kindly if you could point me out.

The issue is the time when discard is issued for cache device (not backing device).
For enterprise SSD such discard hint is unnecessary, for low end consumer SSD it is too late.

In my testing, enterprise SSDs (e.g. Lenovo or memblaze ones) have enough internal reserved
space for gc, almost no performance impact with/without enabling cache device discard option.

For low end SATA or m.2 SSD, after issue discard bio then new data is writing onto SSD, the performance
number differs a lot comparing that I manually discard the SSD and then create cache device. I assume it
is because the internal reserved space is quite limited for gc. Such quite late discard hint doesn’t help any
and introduces extra latency.

This is why I call it useless.

Thanks.

Coly Li


>  
> Ps: I haven’t subscribe the mail list so I just paste the patch title for reply,
> Sorry if it makes inconvenient to anyone.  
>  
> Thanks!
> linfeng
>  
>  
> Following contents extracted from original patch.
>  
> From: Coly Li <[email protected]>
>  
> In bcache journal there is discard functionality but almost useless in
> reality. Because discard happens after a journal bucket is reclaimed,
> and the reclaimed bucket is allocated for new journaling immediately.
> There is no time for underlying SSD to use the discard hint for internal
> data management.
>  
> The discard code in bcache journal doesn't bring any performance
> optimization and wastes CPU cycles for issuing discard bios. Therefore
> this patch gits rid of it from journal.c and journal.h.
>  
> Signed-off-by: Coly Li <[email protected]>
> ---
> drivers/md/bcache/journal.c | 93 ++++---------------------------------
> drivers/md/bcache/journal.h | 13 ------
> 2 files changed, 8 insertions(+), 98 deletions(-)