diff mbox series

[2/2] block: code cleanup for bio_find_or_create_slab()

Message ID 20190308101540.24337-2-cgxu519@gmx.com (mailing list archive)
State New, archived
Headers show
Series [1/2] block: increase bio_slab_nr only for necessary case | expand

Commit Message

Chengguang Xu March 8, 2019, 10:15 a.m. UTC
It's just a simple code cleanup, not functional change.

Signed-off-by: Chengguang Xu <cgxu519@gmx.com>
---
 block/bio.c | 26 ++++++++++++--------------
 1 file changed, 12 insertions(+), 14 deletions(-)
diff mbox series

Patch

diff --git a/block/bio.c b/block/bio.c
index 8081906f5d01..fefd49a561ab 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -90,29 +90,27 @@  static struct kmem_cache *bio_find_or_create_slab(unsigned int extra_size)
 		else if (bslab->slab_size == sz) {
 			slab = bslab->slab;
 			bslab->slab_ref++;
-			break;
+			goto out_unlock;
 		}
 		i++;
 	}
 
-	if (slab)
-		goto out_unlock;
-
-	if (bio_slab_nr == bio_slab_max && entry == -1) {
-		new_bio_slab_max = bio_slab_max << 1;
-		new_bio_slabs = krealloc(bio_slabs,
+	if (entry == -1) {
+		if (bio_slab_nr == bio_slab_max) {
+			new_bio_slab_max = bio_slab_max << 1;
+			new_bio_slabs = krealloc(bio_slabs,
 					 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)
+			if (!new_bio_slabs)
+				goto out_unlock;
+			bio_slab_max = new_bio_slab_max;
+			bio_slabs = new_bio_slabs;
+		}
+
 		entry = bio_slab_nr;
+	}
 
 	bslab = &bio_slabs[entry];
-
 	snprintf(bslab->name, sizeof(bslab->name), "bio-%d", entry);
 	slab = kmem_cache_create(bslab->name, sz, ARCH_KMALLOC_MINALIGN,
 				 SLAB_HWCACHE_ALIGN, NULL);