blk-cgroup.c (858a0d7eb5300b5f620d98ab3c4b96c9d5f19131) | blk-cgroup.c (dc3b17cc8bf21307c7e076e7c778d5db756f7871) |
---|---|
1/* 2 * Common Block IO controller cgroup interface 3 * 4 * Based on ideas and code from CFQ, CFS and BFQ: 5 * Copyright (C) 2003 Jens Axboe <axboe@kernel.dk> 6 * 7 * Copyright (C) 2008 Fabio Checconi <fabio@gandalf.sssup.it> 8 * Paolo Valente <paolo.valente@unimore.it> --- 170 unchanged lines hidden (view full) --- 179 lockdep_assert_held(q->queue_lock); 180 181 /* blkg holds a reference to blkcg */ 182 if (!css_tryget_online(&blkcg->css)) { 183 ret = -ENODEV; 184 goto err_free_blkg; 185 } 186 | 1/* 2 * Common Block IO controller cgroup interface 3 * 4 * Based on ideas and code from CFQ, CFS and BFQ: 5 * Copyright (C) 2003 Jens Axboe <axboe@kernel.dk> 6 * 7 * Copyright (C) 2008 Fabio Checconi <fabio@gandalf.sssup.it> 8 * Paolo Valente <paolo.valente@unimore.it> --- 170 unchanged lines hidden (view full) --- 179 lockdep_assert_held(q->queue_lock); 180 181 /* blkg holds a reference to blkcg */ 182 if (!css_tryget_online(&blkcg->css)) { 183 ret = -ENODEV; 184 goto err_free_blkg; 185 } 186 |
187 wb_congested = wb_congested_get_create(&q->backing_dev_info, | 187 wb_congested = wb_congested_get_create(q->backing_dev_info, |
188 blkcg->css.id, 189 GFP_NOWAIT | __GFP_NOWARN); 190 if (!wb_congested) { 191 ret = -ENOMEM; 192 goto err_put_css; 193 } 194 195 /* allocate */ --- 268 unchanged lines hidden (view full) --- 464 spin_unlock_irq(&blkcg->lock); 465 mutex_unlock(&blkcg_pol_mutex); 466 return 0; 467} 468 469const char *blkg_dev_name(struct blkcg_gq *blkg) 470{ 471 /* some drivers (floppy) instantiate a queue w/o disk registered */ | 188 blkcg->css.id, 189 GFP_NOWAIT | __GFP_NOWARN); 190 if (!wb_congested) { 191 ret = -ENOMEM; 192 goto err_put_css; 193 } 194 195 /* allocate */ --- 268 unchanged lines hidden (view full) --- 464 spin_unlock_irq(&blkcg->lock); 465 mutex_unlock(&blkcg_pol_mutex); 466 return 0; 467} 468 469const char *blkg_dev_name(struct blkcg_gq *blkg) 470{ 471 /* some drivers (floppy) instantiate a queue w/o disk registered */ |
472 if (blkg->q->backing_dev_info.dev) 473 return dev_name(blkg->q->backing_dev_info.dev); | 472 if (blkg->q->backing_dev_info->dev) 473 return dev_name(blkg->q->backing_dev_info->dev); |
474 return NULL; 475} 476EXPORT_SYMBOL_GPL(blkg_dev_name); 477 478/** 479 * blkcg_print_blkgs - helper for printing per-blkg data 480 * @sf: seq_file to print to 481 * @blkcg: blkcg of interest --- 736 unchanged lines hidden (view full) --- 1218{ 1219 struct blkg_policy_data *pd_prealloc = NULL; 1220 struct blkcg_gq *blkg; 1221 int ret; 1222 1223 if (blkcg_policy_enabled(q, pol)) 1224 return 0; 1225 | 474 return NULL; 475} 476EXPORT_SYMBOL_GPL(blkg_dev_name); 477 478/** 479 * blkcg_print_blkgs - helper for printing per-blkg data 480 * @sf: seq_file to print to 481 * @blkcg: blkcg of interest --- 736 unchanged lines hidden (view full) --- 1218{ 1219 struct blkg_policy_data *pd_prealloc = NULL; 1220 struct blkcg_gq *blkg; 1221 int ret; 1222 1223 if (blkcg_policy_enabled(q, pol)) 1224 return 0; 1225 |
1226 blk_queue_bypass_start(q); | 1226 if (q->mq_ops) 1227 blk_mq_freeze_queue(q); 1228 else 1229 blk_queue_bypass_start(q); |
1227pd_prealloc: 1228 if (!pd_prealloc) { 1229 pd_prealloc = pol->pd_alloc_fn(GFP_KERNEL, q->node); 1230 if (!pd_prealloc) { 1231 ret = -ENOMEM; 1232 goto out_bypass_end; 1233 } 1234 } --- 21 unchanged lines hidden (view full) --- 1256 pol->pd_init_fn(pd); 1257 } 1258 1259 __set_bit(pol->plid, q->blkcg_pols); 1260 ret = 0; 1261 1262 spin_unlock_irq(q->queue_lock); 1263out_bypass_end: | 1230pd_prealloc: 1231 if (!pd_prealloc) { 1232 pd_prealloc = pol->pd_alloc_fn(GFP_KERNEL, q->node); 1233 if (!pd_prealloc) { 1234 ret = -ENOMEM; 1235 goto out_bypass_end; 1236 } 1237 } --- 21 unchanged lines hidden (view full) --- 1259 pol->pd_init_fn(pd); 1260 } 1261 1262 __set_bit(pol->plid, q->blkcg_pols); 1263 ret = 0; 1264 1265 spin_unlock_irq(q->queue_lock); 1266out_bypass_end: |
1264 blk_queue_bypass_end(q); | 1267 if (q->mq_ops) 1268 blk_mq_unfreeze_queue(q); 1269 else 1270 blk_queue_bypass_end(q); |
1265 if (pd_prealloc) 1266 pol->pd_free_fn(pd_prealloc); 1267 return ret; 1268} 1269EXPORT_SYMBOL_GPL(blkcg_activate_policy); 1270 1271/** 1272 * blkcg_deactivate_policy - deactivate a blkcg policy on a request_queue --- 6 unchanged lines hidden (view full) --- 1279void blkcg_deactivate_policy(struct request_queue *q, 1280 const struct blkcg_policy *pol) 1281{ 1282 struct blkcg_gq *blkg; 1283 1284 if (!blkcg_policy_enabled(q, pol)) 1285 return; 1286 | 1271 if (pd_prealloc) 1272 pol->pd_free_fn(pd_prealloc); 1273 return ret; 1274} 1275EXPORT_SYMBOL_GPL(blkcg_activate_policy); 1276 1277/** 1278 * blkcg_deactivate_policy - deactivate a blkcg policy on a request_queue --- 6 unchanged lines hidden (view full) --- 1285void blkcg_deactivate_policy(struct request_queue *q, 1286 const struct blkcg_policy *pol) 1287{ 1288 struct blkcg_gq *blkg; 1289 1290 if (!blkcg_policy_enabled(q, pol)) 1291 return; 1292 |
1287 blk_queue_bypass_start(q); | 1293 if (q->mq_ops) 1294 blk_mq_freeze_queue(q); 1295 else 1296 blk_queue_bypass_start(q); 1297 |
1288 spin_lock_irq(q->queue_lock); 1289 1290 __clear_bit(pol->plid, q->blkcg_pols); 1291 1292 list_for_each_entry(blkg, &q->blkg_list, q_node) { 1293 /* grab blkcg lock too while removing @pd from @blkg */ 1294 spin_lock(&blkg->blkcg->lock); 1295 1296 if (blkg->pd[pol->plid]) { 1297 if (pol->pd_offline_fn) 1298 pol->pd_offline_fn(blkg->pd[pol->plid]); 1299 pol->pd_free_fn(blkg->pd[pol->plid]); 1300 blkg->pd[pol->plid] = NULL; 1301 } 1302 1303 spin_unlock(&blkg->blkcg->lock); 1304 } 1305 1306 spin_unlock_irq(q->queue_lock); | 1298 spin_lock_irq(q->queue_lock); 1299 1300 __clear_bit(pol->plid, q->blkcg_pols); 1301 1302 list_for_each_entry(blkg, &q->blkg_list, q_node) { 1303 /* grab blkcg lock too while removing @pd from @blkg */ 1304 spin_lock(&blkg->blkcg->lock); 1305 1306 if (blkg->pd[pol->plid]) { 1307 if (pol->pd_offline_fn) 1308 pol->pd_offline_fn(blkg->pd[pol->plid]); 1309 pol->pd_free_fn(blkg->pd[pol->plid]); 1310 blkg->pd[pol->plid] = NULL; 1311 } 1312 1313 spin_unlock(&blkg->blkcg->lock); 1314 } 1315 1316 spin_unlock_irq(q->queue_lock); |
1307 blk_queue_bypass_end(q); | 1317 1318 if (q->mq_ops) 1319 blk_mq_unfreeze_queue(q); 1320 else 1321 blk_queue_bypass_end(q); |
1308} 1309EXPORT_SYMBOL_GPL(blkcg_deactivate_policy); 1310 1311/** 1312 * blkcg_policy_register - register a blkcg policy 1313 * @pol: blkcg policy to register 1314 * 1315 * Register @pol with blkcg core. Might sleep and @pol may be modified on --- 106 unchanged lines hidden --- | 1322} 1323EXPORT_SYMBOL_GPL(blkcg_deactivate_policy); 1324 1325/** 1326 * blkcg_policy_register - register a blkcg policy 1327 * @pol: blkcg policy to register 1328 * 1329 * Register @pol with blkcg core. Might sleep and @pol may be modified on --- 106 unchanged lines hidden --- |