Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

vfs: cache request_queue in struct block_device

This makes it possible to get from the inode to the request_queue with one
less cache miss. Used in followon optimization.

The livetime of the pointer is the same as the gendisk.

This assumes that the queue will always stay the same in the gendisk while
it's visible to block_devices. I think that's safe correct?

Signed-off-by: Andi Kleen <ak@linux.intel.com>
Acked-by: Jeff Moyer <jmoyer@redhat.com>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Andi Kleen and committed by
Linus Torvalds
87192a2a ae55e1aa

+5
+3
fs/block_dev.c
··· 1139 1139 mutex_lock_nested(&bdev->bd_mutex, for_part); 1140 1140 if (!bdev->bd_openers) { 1141 1141 bdev->bd_disk = disk; 1142 + bdev->bd_queue = disk->queue; 1142 1143 bdev->bd_contains = bdev; 1143 1144 if (!partno) { 1144 1145 struct backing_dev_info *bdi; ··· 1160 1159 disk_put_part(bdev->bd_part); 1161 1160 bdev->bd_part = NULL; 1162 1161 bdev->bd_disk = NULL; 1162 + bdev->bd_queue = NULL; 1163 1163 mutex_unlock(&bdev->bd_mutex); 1164 1164 disk_unblock_events(disk); 1165 1165 put_disk(disk); ··· 1234 1232 disk_put_part(bdev->bd_part); 1235 1233 bdev->bd_disk = NULL; 1236 1234 bdev->bd_part = NULL; 1235 + bdev->bd_queue = NULL; 1237 1236 bdev_inode_switch_bdi(bdev->bd_inode, &default_backing_dev_info); 1238 1237 if (bdev != bdev->bd_contains) 1239 1238 __blkdev_put(bdev->bd_contains, mode, 1);
+2
include/linux/fs.h
··· 660 660 * must be enforced here for CRIS, to let the least significant bit 661 661 * of struct page's "mapping" pointer be used for PAGE_MAPPING_ANON. 662 662 */ 663 + struct request_queue; 663 664 664 665 struct block_device { 665 666 dev_t bd_dev; /* not a kdev_t - it's a search key */ ··· 683 682 unsigned bd_part_count; 684 683 int bd_invalidated; 685 684 struct gendisk * bd_disk; 685 + struct request_queue * bd_queue; 686 686 struct list_head bd_list; 687 687 /* 688 688 * Private data. You must have bd_claim'ed the block_device