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

Merge remote-tracking branch 'jens/for-4.1/core' into dm/for-next

+52 -25
+16 -3
block/blk-core.c
··· 557 557 } 558 558 EXPORT_SYMBOL(blk_cleanup_queue); 559 559 560 + /* Allocate memory local to the request queue */ 561 + static void *alloc_request_struct(gfp_t gfp_mask, void *data) 562 + { 563 + int nid = (int)(long)data; 564 + return kmem_cache_alloc_node(request_cachep, gfp_mask, nid); 565 + } 566 + 567 + static void free_request_struct(void *element, void *unused) 568 + { 569 + kmem_cache_free(request_cachep, element); 570 + } 571 + 560 572 int blk_init_rl(struct request_list *rl, struct request_queue *q, 561 573 gfp_t gfp_mask) 562 574 { ··· 581 569 init_waitqueue_head(&rl->wait[BLK_RW_SYNC]); 582 570 init_waitqueue_head(&rl->wait[BLK_RW_ASYNC]); 583 571 584 - rl->rq_pool = mempool_create_node(BLKDEV_MIN_RQ, mempool_alloc_slab, 585 - mempool_free_slab, request_cachep, 586 - gfp_mask, q->node); 572 + rl->rq_pool = mempool_create_node(BLKDEV_MIN_RQ, alloc_request_struct, 573 + free_request_struct, 574 + (void *)(long)q->node, gfp_mask, 575 + q->node); 587 576 if (!rl->rq_pool) 588 577 return -ENOMEM; 589 578
+1
block/blk-mq-sysfs.c
··· 436 436 437 437 return 0; 438 438 } 439 + EXPORT_SYMBOL_GPL(blk_mq_register_disk); 439 440 440 441 void blk_mq_sysfs_unregister(struct request_queue *q) 441 442 {
+32 -22
block/blk-mq.c
··· 33 33 static LIST_HEAD(all_q_list); 34 34 35 35 static void __blk_mq_run_hw_queue(struct blk_mq_hw_ctx *hctx); 36 - static void blk_mq_run_queues(struct request_queue *q); 37 36 38 37 /* 39 38 * Check if any of the ctx's have pending work in this hardware queue ··· 77 78 clear_bit(CTX_TO_BIT(hctx, ctx), &bm->word); 78 79 } 79 80 80 - static int blk_mq_queue_enter(struct request_queue *q) 81 + static int blk_mq_queue_enter(struct request_queue *q, gfp_t gfp) 81 82 { 82 83 while (true) { 83 84 int ret; 84 85 85 86 if (percpu_ref_tryget_live(&q->mq_usage_counter)) 86 87 return 0; 88 + 89 + if (!(gfp & __GFP_WAIT)) 90 + return -EBUSY; 87 91 88 92 ret = wait_event_interruptible(q->mq_freeze_wq, 89 93 !q->mq_freeze_depth || blk_queue_dying(q)); ··· 120 118 121 119 if (freeze) { 122 120 percpu_ref_kill(&q->mq_usage_counter); 123 - blk_mq_run_queues(q); 121 + blk_mq_run_hw_queues(q, false); 124 122 } 125 123 } 126 124 EXPORT_SYMBOL_GPL(blk_mq_freeze_queue_start); ··· 259 257 struct blk_mq_alloc_data alloc_data; 260 258 int ret; 261 259 262 - ret = blk_mq_queue_enter(q); 260 + ret = blk_mq_queue_enter(q, gfp); 263 261 if (ret) 264 262 return ERR_PTR(ret); 265 263 ··· 906 904 &hctx->run_work, 0); 907 905 } 908 906 909 - static void blk_mq_run_queues(struct request_queue *q) 907 + void blk_mq_run_hw_queues(struct request_queue *q, bool async) 910 908 { 911 909 struct blk_mq_hw_ctx *hctx; 912 910 int i; ··· 917 915 test_bit(BLK_MQ_S_STOPPED, &hctx->state)) 918 916 continue; 919 917 920 - blk_mq_run_hw_queue(hctx, false); 918 + blk_mq_run_hw_queue(hctx, async); 921 919 } 922 920 } 921 + EXPORT_SYMBOL(blk_mq_run_hw_queues); 923 922 924 923 void blk_mq_stop_hw_queue(struct blk_mq_hw_ctx *hctx) 925 924 { ··· 1189 1186 int rw = bio_data_dir(bio); 1190 1187 struct blk_mq_alloc_data alloc_data; 1191 1188 1192 - if (unlikely(blk_mq_queue_enter(q))) { 1189 + if (unlikely(blk_mq_queue_enter(q, GFP_KERNEL))) { 1193 1190 bio_endio(bio, -EIO); 1194 1191 return NULL; 1195 1192 } ··· 1894 1891 1895 1892 struct request_queue *blk_mq_init_queue(struct blk_mq_tag_set *set) 1896 1893 { 1894 + struct request_queue *uninit_q, *q; 1895 + 1896 + uninit_q = blk_alloc_queue_node(GFP_KERNEL, set->numa_node); 1897 + if (!uninit_q) 1898 + return ERR_PTR(-ENOMEM); 1899 + 1900 + q = blk_mq_init_allocated_queue(set, uninit_q); 1901 + if (IS_ERR(q)) 1902 + blk_cleanup_queue(uninit_q); 1903 + 1904 + return q; 1905 + } 1906 + EXPORT_SYMBOL(blk_mq_init_queue); 1907 + 1908 + struct request_queue *blk_mq_init_allocated_queue(struct blk_mq_tag_set *set, 1909 + struct request_queue *q) 1910 + { 1897 1911 struct blk_mq_hw_ctx **hctxs; 1898 1912 struct blk_mq_ctx __percpu *ctx; 1899 - struct request_queue *q; 1900 1913 unsigned int *map; 1901 1914 int i; 1902 1915 ··· 1947 1928 hctxs[i]->queue_num = i; 1948 1929 } 1949 1930 1950 - q = blk_alloc_queue_node(GFP_KERNEL, set->numa_node); 1951 - if (!q) 1952 - goto err_hctxs; 1953 - 1954 1931 /* 1955 1932 * Init percpu_ref in atomic mode so that it's faster to shutdown. 1956 1933 * See blk_register_queue() for details. 1957 1934 */ 1958 1935 if (percpu_ref_init(&q->mq_usage_counter, blk_mq_usage_counter_release, 1959 1936 PERCPU_REF_INIT_ATOMIC, GFP_KERNEL)) 1960 - goto err_mq_usage; 1937 + goto err_hctxs; 1961 1938 1962 1939 setup_timer(&q->timeout, blk_mq_rq_timer, (unsigned long) q); 1963 - blk_queue_rq_timeout(q, 30000); 1940 + blk_queue_rq_timeout(q, set->timeout ? set->timeout : 30000); 1964 1941 1965 1942 q->nr_queues = nr_cpu_ids; 1966 1943 q->nr_hw_queues = set->nr_hw_queues; ··· 1982 1967 else 1983 1968 blk_queue_make_request(q, blk_sq_make_request); 1984 1969 1985 - if (set->timeout) 1986 - blk_queue_rq_timeout(q, set->timeout); 1987 - 1988 1970 /* 1989 1971 * Do this after blk_queue_make_request() overrides it... 1990 1972 */ ··· 1993 1981 blk_mq_init_cpu_queues(q, set->nr_hw_queues); 1994 1982 1995 1983 if (blk_mq_init_hw_queues(q, set)) 1996 - goto err_mq_usage; 1984 + goto err_hctxs; 1997 1985 1998 1986 mutex_lock(&all_q_mutex); 1999 1987 list_add_tail(&q->all_q_node, &all_q_list); ··· 2005 1993 2006 1994 return q; 2007 1995 2008 - err_mq_usage: 2009 - blk_cleanup_queue(q); 2010 1996 err_hctxs: 2011 1997 kfree(map); 2012 1998 for (i = 0; i < set->nr_hw_queues; i++) { ··· 2019 2009 free_percpu(ctx); 2020 2010 return ERR_PTR(-ENOMEM); 2021 2011 } 2022 - EXPORT_SYMBOL(blk_mq_init_queue); 2012 + EXPORT_SYMBOL(blk_mq_init_allocated_queue); 2023 2013 2024 2014 void blk_mq_free_queue(struct request_queue *q) 2025 2015 { ··· 2171 2161 if (set->queue_depth < set->reserved_tags + BLK_MQ_TAG_MIN) 2172 2162 return -EINVAL; 2173 2163 2174 - if (!set->nr_hw_queues || !set->ops->queue_rq || !set->ops->map_queue) 2164 + if (!set->ops->queue_rq || !set->ops->map_queue) 2175 2165 return -EINVAL; 2176 2166 2177 2167 if (set->queue_depth > BLK_MQ_MAX_DEPTH) {
+3
include/linux/blk-mq.h
··· 164 164 << BLK_MQ_F_ALLOC_POLICY_START_BIT) 165 165 166 166 struct request_queue *blk_mq_init_queue(struct blk_mq_tag_set *); 167 + struct request_queue *blk_mq_init_allocated_queue(struct blk_mq_tag_set *set, 168 + struct request_queue *q); 167 169 void blk_mq_finish_init(struct request_queue *q); 168 170 int blk_mq_register_disk(struct gendisk *); 169 171 void blk_mq_unregister_disk(struct gendisk *); ··· 220 218 void blk_mq_stop_hw_queues(struct request_queue *q); 221 219 void blk_mq_start_hw_queues(struct request_queue *q); 222 220 void blk_mq_start_stopped_hw_queues(struct request_queue *q, bool async); 221 + void blk_mq_run_hw_queues(struct request_queue *q, bool async); 223 222 void blk_mq_delay_queue(struct blk_mq_hw_ctx *hctx, unsigned long msecs); 224 223 void blk_mq_tag_busy_iter(struct blk_mq_hw_ctx *hctx, busy_iter_fn *fn, 225 224 void *priv);