Re: gen wraparound warning: is this a problem?

"Coly Li" <[email protected]> Thu, 25 Sep 2025 00:04:55 +0800
Newsgroups org.kernel.vger.linux-bcache
Message-ID <[email protected]>
> 2025年9月10日 23:54,Nix <[email protected]> 写道:
> 
> On 8 Sep 2025, Coly Li verbalised:
> 
>>> 2025年9月7日 22:37,Nix <[email protected]> 写道:
>>> 
>>> So, out of the blue, I just got this for my long-standing writearound
>>> bcache setup (which covers my rootfs and $HOME, so I kind of care that
>>> it keeps working):
> 
> (Oh, this is kernel 6.15.6 -- but that's only since Jul 20th. Before
> that, I was running 5.16.19 right back to April 2022, yes, I know... so
> it's possible this wasn't touched by *5.16* and thus this is a bug that
> was fixed long ago.)

IMHO this might not be a kernel bug, and just about time.

> 
>>> These both map to this in bch_inc_gen():
>>> 
>>>    WARN_ON_ONCE(ca->set->need_gc > BUCKET_GC_GEN_MAX);
>> 
>> It seems a bucket has not been touched by garbage collection for a long time.
> 
> Not too surprising: half-terabyte cache, and the xfs filesystems it
> backs only has 1.5TiB of data on it and not all of it is accessed
> frequently, and some is bypassed... so it can take a long time to gc
> through the entire cache :) it took months just to fill it.
> 

Copied.



>>> Is this something the admin needs to do something about? (And, if it's
>>> not and bcache recovers smoothly, as so far it seems to -- though I
>>> haven't tried to remount it since the warning -- why do we warn about
>>> it at all?)
>> 
>> I don’t know why this bucket is not touched by GC for such a long
>> time. It should not happen in my expectation.
> 
> It's possible that *no* buckets were touched for a long time.
> 

Yeah, I assumed for that.


>> To make sure everything is safe, I would suggest to writeback all the
>> dirty datas into backing device, detach the cache device, re-make the
>> cache device and attach backing device to it again.
> 
> There is no dirty data (writethrough cache)... and this is backing the
> rootfs, among other things, so IIRC detaching is quite difficult and
> panic-prone to do (it's been many years, but I believe you can't do it
> while mounted?). I'll schedule it for the next reboot…

If there is no dirty data on the cache, the cache device can be safely detached
from backing device while the bcache device is mounted.

echo 1 > /sys/block/<backing dev>/bcache/detach

Hope it works.

Thanks.

Coly Li