aboutsummaryrefslogtreecommitdiffstats
path: root/fs/bio.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-05-30 11:52:42 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-05-30 11:52:42 -0400
commit0d167518e045cc8bb63f0a8a0a85ad4fa4e0044f (patch)
tree101a9b5d425d79f663e4f25f1e90b7a8cc6604f1 /fs/bio.c
parent2f83766d4b18774c856329a8fca4c9338dfeda39 (diff)
parentff26eaadf4d914e397872b99885d45756104e9ae (diff)
Merge branch 'for-3.5/core' of git://git.kernel.dk/linux-block
Merge block/IO core bits from Jens Axboe: "This is a bit bigger on the core side than usual, but that is purely because we decided to hold off on parts of Tejun's submission on 3.4 to give it a bit more time to simmer. As a consequence, it's seen a long cycle in for-next. It contains: - Bug fix from Dan, wrong locking type. - Relax splice gifting restriction from Eric. - A ton of updates from Tejun, primarily for blkcg. This improves the code a lot, making the API nicer and cleaner, and also includes fixes for how we handle and tie policies and re-activate on switches. The changes also include generic bug fixes. - A simple fix from Vivek, along with a fix for doing proper delayed allocation of the blkcg stats." Fix up annoying conflict just due to different merge resolution in Documentation/feature-removal-schedule.txt * 'for-3.5/core' of git://git.kernel.dk/linux-block: (92 commits) blkcg: tg_stats_alloc_lock is an irq lock vmsplice: relax alignement requirements for SPLICE_F_GIFT blkcg: use radix tree to index blkgs from blkcg blkcg: fix blkcg->css ref leak in __blkg_lookup_create() block: fix elvpriv allocation failure handling block: collapse blk_alloc_request() into get_request() blkcg: collapse blkcg_policy_ops into blkcg_policy blkcg: embed struct blkg_policy_data in policy specific data blkcg: mass rename of blkcg API blkcg: style cleanups for blk-cgroup.h blkcg: remove blkio_group->path[] blkcg: blkg_rwstat_read() was missing inline blkcg: shoot down blkgs if all policies are deactivated blkcg: drop stuff unused after per-queue policy activation update blkcg: implement per-queue policy activation blkcg: add request_queue->root_blkg blkcg: make request_queue bypassing on allocation blkcg: make sure blkg_lookup() returns %NULL if @q is bypassing blkcg: make blkg_conf_prep() take @pol and return with queue lock held blkcg: remove static policy ID enums ...
Diffstat (limited to 'fs/bio.c')
-rw-r--r--fs/bio.c61
1 files changed, 61 insertions, 0 deletions
diff --git a/fs/bio.c b/fs/bio.c
index 84da88539046..73922abba832 100644
--- a/fs/bio.c
+++ b/fs/bio.c
@@ -19,12 +19,14 @@
19#include <linux/swap.h> 19#include <linux/swap.h>
20#include <linux/bio.h> 20#include <linux/bio.h>
21#include <linux/blkdev.h> 21#include <linux/blkdev.h>
22#include <linux/iocontext.h>
22#include <linux/slab.h> 23#include <linux/slab.h>
23#include <linux/init.h> 24#include <linux/init.h>
24#include <linux/kernel.h> 25#include <linux/kernel.h>
25#include <linux/export.h> 26#include <linux/export.h>
26#include <linux/mempool.h> 27#include <linux/mempool.h>
27#include <linux/workqueue.h> 28#include <linux/workqueue.h>
29#include <linux/cgroup.h>
28#include <scsi/sg.h> /* for struct sg_iovec */ 30#include <scsi/sg.h> /* for struct sg_iovec */
29 31
30#include <trace/events/block.h> 32#include <trace/events/block.h>
@@ -418,6 +420,7 @@ void bio_put(struct bio *bio)
418 * last put frees it 420 * last put frees it
419 */ 421 */
420 if (atomic_dec_and_test(&bio->bi_cnt)) { 422 if (atomic_dec_and_test(&bio->bi_cnt)) {
423 bio_disassociate_task(bio);
421 bio->bi_next = NULL; 424 bio->bi_next = NULL;
422 bio->bi_destructor(bio); 425 bio->bi_destructor(bio);
423 } 426 }
@@ -1646,6 +1649,64 @@ bad:
1646} 1649}
1647EXPORT_SYMBOL(bioset_create); 1650EXPORT_SYMBOL(bioset_create);
1648 1651
1652#ifdef CONFIG_BLK_CGROUP
1653/**
1654 * bio_associate_current - associate a bio with %current
1655 * @bio: target bio
1656 *
1657 * Associate @bio with %current if it hasn't been associated yet. Block
1658 * layer will treat @bio as if it were issued by %current no matter which
1659 * task actually issues it.
1660 *
1661 * This function takes an extra reference of @task's io_context and blkcg
1662 * which will be put when @bio is released. The caller must own @bio,
1663 * ensure %current->io_context exists, and is responsible for synchronizing
1664 * calls to this function.
1665 */
1666int bio_associate_current(struct bio *bio)
1667{
1668 struct io_context *ioc;
1669 struct cgroup_subsys_state *css;
1670
1671 if (bio->bi_ioc)
1672 return -EBUSY;
1673
1674 ioc = current->io_context;
1675 if (!ioc)
1676 return -ENOENT;
1677
1678 /* acquire active ref on @ioc and associate */
1679 get_io_context_active(ioc);
1680 bio->bi_ioc = ioc;
1681
1682 /* associate blkcg if exists */
1683 rcu_read_lock();
1684 css = task_subsys_state(current, blkio_subsys_id);
1685 if (css && css_tryget(css))
1686 bio->bi_css = css;
1687 rcu_read_unlock();
1688
1689 return 0;
1690}
1691
1692/**
1693 * bio_disassociate_task - undo bio_associate_current()
1694 * @bio: target bio
1695 */
1696void bio_disassociate_task(struct bio *bio)
1697{
1698 if (bio->bi_ioc) {
1699 put_io_context(bio->bi_ioc);
1700 bio->bi_ioc = NULL;
1701 }
1702 if (bio->bi_css) {
1703 css_put(bio->bi_css);
1704 bio->bi_css = NULL;
1705 }
1706}
1707
1708#endif /* CONFIG_BLK_CGROUP */
1709
1649static void __init biovec_init_slabs(void) 1710static void __init biovec_init_slabs(void)
1650{ 1711{
1651 int i; 1712 int i;