lkml.org 
[lkml]   [2004]   [Aug]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subject[PATCH 3/3] blk_queue_tags_resize_failure
From
Date

Fixes blk_queue_resize_tags to properly handle allocation failures. Currently,
if a memory allocation failure occurs during blk_queue_resize_tags, the tag map
ends up getting freed, which should not happen. The old tag map should be preserved
and only the resize should fail.

Signed-off-by: Jens Axboe <axboe@suse.de>
Signed-off-by: Brian King <brking@us.ibm.com>
---

linux-2.6.8-rc3-mm2-bjking1/drivers/block/ll_rw_blk.c | 20 ++++++++++--------
1 files changed, 12 insertions(+), 8 deletions(-)

diff -puN drivers/block/ll_rw_blk.c~blk_queue_tags_resize_failure drivers/block/ll_rw_blk.c
--- linux-2.6.8-rc3-mm2/drivers/block/ll_rw_blk.c~blk_queue_tags_resize_failure 2004-08-09 14:51:42.000000000 -0500
+++ linux-2.6.8-rc3-mm2-bjking1/drivers/block/ll_rw_blk.c 2004-08-09 14:51:42.000000000 -0500
@@ -571,6 +571,8 @@ static int
init_tag_map(request_queue_t *q, struct blk_queue_tag *tags, int depth)
{
int bits, i;
+ struct request **tag_index;
+ unsigned long *tag_map;

if (depth > q->nr_requests * 2) {
depth = q->nr_requests * 2;
@@ -578,29 +580,31 @@ init_tag_map(request_queue_t *q, struct
__FUNCTION__, depth);
}

- tags->tag_index = kmalloc(depth * sizeof(struct request *), GFP_ATOMIC);
- if (!tags->tag_index)
+ tag_index = kmalloc(depth * sizeof(struct request *), GFP_ATOMIC);
+ if (!tag_index)
goto fail;

bits = (depth / BLK_TAGS_PER_LONG) + 1;
- tags->tag_map = kmalloc(bits * sizeof(unsigned long), GFP_ATOMIC);
- if (!tags->tag_map)
+ tag_map = kmalloc(bits * sizeof(unsigned long), GFP_ATOMIC);
+ if (!tag_map)
goto fail;

- memset(tags->tag_index, 0, depth * sizeof(struct request *));
- memset(tags->tag_map, 0, bits * sizeof(unsigned long));
+ memset(tag_index, 0, depth * sizeof(struct request *));
+ memset(tag_map, 0, bits * sizeof(unsigned long));
tags->max_depth = depth;
tags->real_max_depth = bits * BITS_PER_LONG;
+ tags->tag_index = tag_index;
+ tags->tag_map = tag_map;

/*
* set the upper bits if the depth isn't a multiple of the word size
*/
for (i = depth; i < bits * BLK_TAGS_PER_LONG; i++)
- __set_bit(i, tags->tag_map);
+ __set_bit(i, tag_map);

return 0;
fail:
- kfree(tags->tag_index);
+ kfree(tag_index);
return -ENOMEM;
}

_
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
\
 
 \ /
  Last update: 2005-03-22 14:05    [W:0.018 / U:8.480 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site