* [PATCH v2] vfs: fix: don't increase bio_slab_max if krealloc() fails
@ 2012-10-22 19:53 ` Anna Leuschner
0 siblings, 0 replies; 4+ messages in thread
From: Anna Leuschner @ 2012-10-22 19:53 UTC (permalink / raw)
To: kernel-janitors; +Cc: Jens Axboe, linux-kernel, Anna Leuschner
Without the patch, bio_slab_max, representing bio_slabs capacity, is increased before krealloc() of bio_slabs. If krealloc() fails, bio_slab_max is too high. Fix that by only updating bio_slab_max if krealloc() is successful.
Signed-off-by: Anna Leuschner <anna.m.leuschner@gmail.com>
---
v2 changes:
- describe what is fixed
fs/bio.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/fs/bio.c b/fs/bio.c
index 9298c65..b96fc6c 100644
--- a/fs/bio.c
+++ b/fs/bio.c
@@ -75,6 +75,7 @@ static struct kmem_cache *bio_find_or_create_slab(unsigned int extra_size)
unsigned int sz = sizeof(struct bio) + extra_size;
struct kmem_cache *slab = NULL;
struct bio_slab *bslab, *new_bio_slabs;
+ unsigned int new_bio_slab_max;
unsigned int i, entry = -1;
mutex_lock(&bio_slab_lock);
@@ -97,12 +98,13 @@ static struct kmem_cache *bio_find_or_create_slab(unsigned int extra_size)
goto out_unlock;
if (bio_slab_nr = bio_slab_max && entry = -1) {
- bio_slab_max <<= 1;
+ new_bio_slab_max = bio_slab_max << 1;
new_bio_slabs = krealloc(bio_slabs,
- bio_slab_max * sizeof(struct bio_slab),
+ new_bio_slab_max * sizeof(struct bio_slab),
GFP_KERNEL);
if (!new_bio_slabs)
goto out_unlock;
+ bio_slab_max = new_bio_slab_max;
bio_slabs = new_bio_slabs;
}
if (entry = -1)
--
1.7.10.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v2] vfs: fix: don't increase bio_slab_max if krealloc() fails
@ 2012-10-22 19:53 ` Anna Leuschner
0 siblings, 0 replies; 4+ messages in thread
From: Anna Leuschner @ 2012-10-22 19:53 UTC (permalink / raw)
To: kernel-janitors; +Cc: Jens Axboe, linux-kernel, Anna Leuschner
Without the patch, bio_slab_max, representing bio_slabs capacity, is increased before krealloc() of bio_slabs. If krealloc() fails, bio_slab_max is too high. Fix that by only updating bio_slab_max if krealloc() is successful.
Signed-off-by: Anna Leuschner <anna.m.leuschner@gmail.com>
---
v2 changes:
- describe what is fixed
fs/bio.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/fs/bio.c b/fs/bio.c
index 9298c65..b96fc6c 100644
--- a/fs/bio.c
+++ b/fs/bio.c
@@ -75,6 +75,7 @@ static struct kmem_cache *bio_find_or_create_slab(unsigned int extra_size)
unsigned int sz = sizeof(struct bio) + extra_size;
struct kmem_cache *slab = NULL;
struct bio_slab *bslab, *new_bio_slabs;
+ unsigned int new_bio_slab_max;
unsigned int i, entry = -1;
mutex_lock(&bio_slab_lock);
@@ -97,12 +98,13 @@ static struct kmem_cache *bio_find_or_create_slab(unsigned int extra_size)
goto out_unlock;
if (bio_slab_nr == bio_slab_max && entry == -1) {
- bio_slab_max <<= 1;
+ new_bio_slab_max = bio_slab_max << 1;
new_bio_slabs = krealloc(bio_slabs,
- bio_slab_max * sizeof(struct bio_slab),
+ new_bio_slab_max * sizeof(struct bio_slab),
GFP_KERNEL);
if (!new_bio_slabs)
goto out_unlock;
+ bio_slab_max = new_bio_slab_max;
bio_slabs = new_bio_slabs;
}
if (entry == -1)
--
1.7.10.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2] vfs: fix: don't increase bio_slab_max if krealloc() fails
2012-10-22 19:53 ` Anna Leuschner
@ 2012-10-22 19:59 ` Jens Axboe
-1 siblings, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2012-10-22 19:59 UTC (permalink / raw)
To: Anna Leuschner; +Cc: kernel-janitors, linux-kernel
On 2012-10-22 21:53, Anna Leuschner wrote:
> Without the patch, bio_slab_max, representing bio_slabs capacity, is
> increased before krealloc() of bio_slabs. If krealloc() fails,
> bio_slab_max is too high. Fix that by only updating bio_slab_max if
> krealloc() is successful.
That's a lot better, thanks!
--
Jens Axboe
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] vfs: fix: don't increase bio_slab_max if krealloc() fails
@ 2012-10-22 19:59 ` Jens Axboe
0 siblings, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2012-10-22 19:59 UTC (permalink / raw)
To: Anna Leuschner; +Cc: kernel-janitors, linux-kernel
On 2012-10-22 21:53, Anna Leuschner wrote:
> Without the patch, bio_slab_max, representing bio_slabs capacity, is
> increased before krealloc() of bio_slabs. If krealloc() fails,
> bio_slab_max is too high. Fix that by only updating bio_slab_max if
> krealloc() is successful.
That's a lot better, thanks!
--
Jens Axboe
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-10-22 19:59 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-22 19:53 [PATCH v2] vfs: fix: don't increase bio_slab_max if krealloc() fails Anna Leuschner
2012-10-22 19:53 ` Anna Leuschner
2012-10-22 19:59 ` Jens Axboe
2012-10-22 19:59 ` Jens Axboe
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.