linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] block: fix 'kmem_cache of name 'bio-108' already exists'
@ 2025-02-28 13:26 Ming Lei
  2025-02-28 14:09 ` Jens Axboe
  2025-03-03 15:39 ` Christoph Hellwig
  0 siblings, 2 replies; 4+ messages in thread
From: Ming Lei @ 2025-02-28 13:26 UTC (permalink / raw)
  To: Jens Axboe, linux-block; +Cc: Ming Lei, Guangwu Zhang

Device mapper bioset often has big bio_slab size, which can be more than
1000, then 8byte can't hold the slab name any more, cause the kmem_cache
allocation warning of 'kmem_cache of name 'bio-108' already exists'.

Fix the warning by extending bio_slab->name to 12 bytes, but fix output
of /proc/slabinfo

Reported-by: Guangwu Zhang <guazhang@redhat.com>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
 block/bio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/block/bio.c b/block/bio.c
index f0c416e5931d..6ac5983ba51e 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -77,7 +77,7 @@ struct bio_slab {
 	struct kmem_cache *slab;
 	unsigned int slab_ref;
 	unsigned int slab_size;
-	char name[8];
+	char name[12];
 };
 static DEFINE_MUTEX(bio_slab_lock);
 static DEFINE_XARRAY(bio_slabs);
-- 
2.47.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] block: fix 'kmem_cache of name 'bio-108' already exists'
  2025-02-28 13:26 [PATCH] block: fix 'kmem_cache of name 'bio-108' already exists' Ming Lei
@ 2025-02-28 14:09 ` Jens Axboe
  2025-03-03 15:39 ` Christoph Hellwig
  1 sibling, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2025-02-28 14:09 UTC (permalink / raw)
  To: linux-block, Ming Lei; +Cc: Guangwu Zhang


On Fri, 28 Feb 2025 21:26:56 +0800, Ming Lei wrote:
> Device mapper bioset often has big bio_slab size, which can be more than
> 1000, then 8byte can't hold the slab name any more, cause the kmem_cache
> allocation warning of 'kmem_cache of name 'bio-108' already exists'.
> 
> Fix the warning by extending bio_slab->name to 12 bytes, but fix output
> of /proc/slabinfo
> 
> [...]

Applied, thanks!

[1/1] block: fix 'kmem_cache of name 'bio-108' already exists'
      (no commit info)

Best regards,
-- 
Jens Axboe




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] block: fix 'kmem_cache of name 'bio-108' already exists'
  2025-02-28 13:26 [PATCH] block: fix 'kmem_cache of name 'bio-108' already exists' Ming Lei
  2025-02-28 14:09 ` Jens Axboe
@ 2025-03-03 15:39 ` Christoph Hellwig
  2025-03-04  1:30   ` Ming Lei
  1 sibling, 1 reply; 4+ messages in thread
From: Christoph Hellwig @ 2025-03-03 15:39 UTC (permalink / raw)
  To: Ming Lei; +Cc: Jens Axboe, linux-block, Guangwu Zhang

On Fri, Feb 28, 2025 at 09:26:56PM +0800, Ming Lei wrote:
> Device mapper bioset often has big bio_slab size, which can be more than
> 1000, then 8byte can't hold the slab name any more, cause the kmem_cache
> allocation warning of 'kmem_cache of name 'bio-108' already exists'.
> 
> Fix the warning by extending bio_slab->name to 12 bytes, but fix output
> of /proc/slabinfo
> 
> Reported-by: Guangwu Zhang <guazhang@redhat.com>
> Signed-off-by: Ming Lei <ming.lei@redhat.com>
> ---
>  block/bio.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/block/bio.c b/block/bio.c
> index f0c416e5931d..6ac5983ba51e 100644
> --- a/block/bio.c
> +++ b/block/bio.c
> @@ -77,7 +77,7 @@ struct bio_slab {
>  	struct kmem_cache *slab;
>  	unsigned int slab_ref;
>  	unsigned int slab_size;
> -	char name[8];
> +	char name[12];

Can you please turn this into a pointer and use kasprintf to fill
it?  That way we fix the string overflow problem for real and don't
need to doctor around it the next time someone uses names with a
longer name.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] block: fix 'kmem_cache of name 'bio-108' already exists'
  2025-03-03 15:39 ` Christoph Hellwig
@ 2025-03-04  1:30   ` Ming Lei
  0 siblings, 0 replies; 4+ messages in thread
From: Ming Lei @ 2025-03-04  1:30 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: Jens Axboe, linux-block, Guangwu Zhang

On Mon, Mar 03, 2025 at 07:39:34AM -0800, Christoph Hellwig wrote:
> On Fri, Feb 28, 2025 at 09:26:56PM +0800, Ming Lei wrote:
> > Device mapper bioset often has big bio_slab size, which can be more than
> > 1000, then 8byte can't hold the slab name any more, cause the kmem_cache
> > allocation warning of 'kmem_cache of name 'bio-108' already exists'.
> > 
> > Fix the warning by extending bio_slab->name to 12 bytes, but fix output
> > of /proc/slabinfo
> > 
> > Reported-by: Guangwu Zhang <guazhang@redhat.com>
> > Signed-off-by: Ming Lei <ming.lei@redhat.com>
> > ---
> >  block/bio.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/block/bio.c b/block/bio.c
> > index f0c416e5931d..6ac5983ba51e 100644
> > --- a/block/bio.c
> > +++ b/block/bio.c
> > @@ -77,7 +77,7 @@ struct bio_slab {
> >  	struct kmem_cache *slab;
> >  	unsigned int slab_ref;
> >  	unsigned int slab_size;
> > -	char name[8];
> > +	char name[12];
> 
> Can you please turn this into a pointer and use kasprintf to fill
> it?  That way we fix the string overflow problem for real and don't
> need to doctor around it the next time someone uses names with a
> longer name.

There isn't the overflow problem, please see create_bio_slab(), which
calls snprintf() to fill the ->name[].

Also extra 4byte can support bio size of ~10^7, which is big enough as
block layer API.


Thanks,
Ming


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-03-04  1:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-28 13:26 [PATCH] block: fix 'kmem_cache of name 'bio-108' already exists' Ming Lei
2025-02-28 14:09 ` Jens Axboe
2025-03-03 15:39 ` Christoph Hellwig
2025-03-04  1:30   ` Ming Lei

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).