From: Tejun Heo blk_queue_start_tag() hand-coded searching for the first zero bit in the tag map. Replace it with find_first_zero_bit(). With this patch, blk_queue_star_tag() doesn't need to fill remains of tag map with 1, thus allowing it to work properly with the next remove_real_max_depth patch. Signed-off-by: Tejun Heo Acked-by: Jens Axboe Signed-off-by: Andrew Morton --- drivers/block/ll_rw_blk.c | 13 ++++--------- 1 files changed, 4 insertions(+), 9 deletions(-) diff -puN drivers/block/ll_rw_blk.c~blk-use-find_first_zero_bit-in-blk_queue_start_tag drivers/block/ll_rw_blk.c --- 25/drivers/block/ll_rw_blk.c~blk-use-find_first_zero_bit-in-blk_queue_start_tag 2005-05-03 20:53:49.000000000 -0700 +++ 25-akpm/drivers/block/ll_rw_blk.c 2005-05-03 20:53:49.000000000 -0700 @@ -969,8 +969,7 @@ EXPORT_SYMBOL(blk_queue_end_tag); int blk_queue_start_tag(request_queue_t *q, struct request *rq) { struct blk_queue_tag *bqt = q->queue_tags; - unsigned long *map = bqt->tag_map; - int tag = 0; + int tag; if (unlikely((rq->flags & REQ_QUEUED))) { printk(KERN_ERR @@ -979,14 +978,10 @@ int blk_queue_start_tag(request_queue_t BUG(); } - for (map = bqt->tag_map; *map == -1UL; map++) { - tag += BLK_TAGS_PER_LONG; - - if (tag >= bqt->max_depth) - return 1; - } + tag = find_first_zero_bit(bqt->tag_map, bqt->max_depth); + if (tag >= bqt->max_depth) + return 1; - tag += ffz(*map); __set_bit(tag, bqt->tag_map); rq->flags |= REQ_QUEUED; _