From: brking@us.ibm.com
To: axboe@suse.de
Cc: linux-kernel@vger.kernel.org, brking@us.ibm.com
Subject: [PATCH 2/2] blk_queue_tags_resize_failure
Date: Mon, 09 Aug 2004 10:50:12 -0500 [thread overview]
Message-ID: <200408091550.i79FoDat359564@westrelay02.boulder.ibm.com> (raw)
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: Brian King <brking@us.ibm.com>
---
linux-2.6.8-rc3-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/drivers/block/ll_rw_blk.c~blk_queue_tags_resize_failure 2004-08-09 10:26:38.000000000 -0500
+++ linux-2.6.8-rc3-bjking1/drivers/block/ll_rw_blk.c 2004-08-09 10:29:30.000000000 -0500
@@ -532,6 +532,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;
@@ -539,29 +541,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;
}
_
next reply other threads:[~2004-08-09 15:54 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-08-09 15:50 brking [this message]
2004-08-09 18:12 ` Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200408091550.i79FoDat359564@westrelay02.boulder.ibm.com \
--to=brking@us.ibm.com \
--cc=axboe@suse.de \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®