Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 2907
b: refs/heads/master
c: fa72b90
h: refs/heads/master
i:
  2905: 7117e02
  2903: 1e50078
v: v3
  • Loading branch information
Tejun Heo authored and Linus Torvalds committed Jun 23, 2005
1 parent 9db6ceb commit 359165c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 27 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 2bf0fdad51c6710bf15d0bf4b9b30b8498fe4ddd
refs/heads/master: fa72b903f75e4f0f0b2c2feed093005167da4023
35 changes: 10 additions & 25 deletions trunk/drivers/block/ll_rw_blk.c
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ struct request *blk_queue_find_tag(request_queue_t *q, int tag)
{
struct blk_queue_tag *bqt = q->queue_tags;

if (unlikely(bqt == NULL || tag >= bqt->real_max_depth))
if (unlikely(bqt == NULL || tag >= bqt->max_depth))
return NULL;

return bqt->tag_index[tag];
Expand Down Expand Up @@ -775,9 +775,9 @@ EXPORT_SYMBOL(blk_queue_free_tags);
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;
int nr_ulongs;

if (depth > q->nr_requests * 2) {
depth = q->nr_requests * 2;
Expand All @@ -789,24 +789,17 @@ init_tag_map(request_queue_t *q, struct blk_queue_tag *tags, int depth)
if (!tag_index)
goto fail;

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

memset(tag_index, 0, depth * sizeof(struct request *));
memset(tag_map, 0, bits * sizeof(unsigned long));
memset(tag_map, 0, nr_ulongs * 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, tag_map);

return 0;
fail:
kfree(tag_index);
Expand Down Expand Up @@ -871,32 +864,24 @@ int blk_queue_resize_tags(request_queue_t *q, int new_depth)
struct blk_queue_tag *bqt = q->queue_tags;
struct request **tag_index;
unsigned long *tag_map;
int bits, max_depth;
int max_depth, nr_ulongs;

if (!bqt)
return -ENXIO;

/*
* don't bother sizing down
*/
if (new_depth <= bqt->real_max_depth) {
bqt->max_depth = new_depth;
return 0;
}

/*
* save the old state info, so we can copy it back
*/
tag_index = bqt->tag_index;
tag_map = bqt->tag_map;
max_depth = bqt->real_max_depth;
max_depth = bqt->max_depth;

if (init_tag_map(q, bqt, new_depth))
return -ENOMEM;

memcpy(bqt->tag_index, tag_index, max_depth * sizeof(struct request *));
bits = max_depth / BLK_TAGS_PER_LONG;
memcpy(bqt->tag_map, tag_map, bits * sizeof(unsigned long));
nr_ulongs = ALIGN(max_depth, BLK_TAGS_PER_LONG) / BLK_TAGS_PER_LONG;
memcpy(bqt->tag_map, tag_map, nr_ulongs * sizeof(unsigned long));

kfree(tag_index);
kfree(tag_map);
Expand Down Expand Up @@ -926,7 +911,7 @@ void blk_queue_end_tag(request_queue_t *q, struct request *rq)

BUG_ON(tag == -1);

if (unlikely(tag >= bqt->real_max_depth))
if (unlikely(tag >= bqt->max_depth))
return;

if (unlikely(!__test_and_clear_bit(tag, bqt->tag_map))) {
Expand Down
1 change: 0 additions & 1 deletion trunk/include/linux/blkdev.h
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,6 @@ struct blk_queue_tag {
struct list_head busy_list; /* fifo list of busy tags */
int busy; /* current depth */
int max_depth; /* what we will send to device */
int real_max_depth; /* what the array can hold */
atomic_t refcnt; /* map can be shared */
};

Expand Down

0 comments on commit 359165c

Please sign in to comment.