[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190307220659.5qmye2pxmto7nlei@macbook-pro-91.dhcp.thefacebook.com>
Date: Thu, 7 Mar 2019 17:07:01 -0500
From: Josef Bacik <josef@...icpanda.com>
To: Andrea Righi <andrea.righi@...onical.com>
Cc: Josef Bacik <josef@...icpanda.com>, Tejun Heo <tj@...nel.org>,
Li Zefan <lizefan@...wei.com>,
Paolo Valente <paolo.valente@...aro.org>,
Johannes Weiner <hannes@...xchg.org>,
Jens Axboe <axboe@...nel.dk>, Vivek Goyal <vgoyal@...hat.com>,
Dennis Zhou <dennis@...nel.org>, cgroups@...r.kernel.org,
linux-block@...r.kernel.org, linux-mm@...ck.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 3/3] blkcg: implement sync() isolation
On Thu, Mar 07, 2019 at 07:08:34PM +0100, Andrea Righi wrote:
> Keep track of the inodes that have been dirtied by each blkcg cgroup and
> make sure that a blkcg issuing a sync() can trigger the writeback + wait
> of only those pages that belong to the cgroup itself.
>
> This behavior is applied only when io.sync_isolation is enabled in the
> cgroup, otherwise the old behavior is applied: sync() triggers the
> writeback of any dirty page.
>
> Signed-off-by: Andrea Righi <andrea.righi@...onical.com>
> ---
> block/blk-cgroup.c | 47 ++++++++++++++++++++++++++++++++++
> fs/fs-writeback.c | 52 +++++++++++++++++++++++++++++++++++---
> fs/inode.c | 1 +
> include/linux/blk-cgroup.h | 22 ++++++++++++++++
> include/linux/fs.h | 4 +++
> mm/page-writeback.c | 1 +
> 6 files changed, 124 insertions(+), 3 deletions(-)
>
> diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
> index 4305e78d1bb2..7d3b26ba4575 100644
> --- a/block/blk-cgroup.c
> +++ b/block/blk-cgroup.c
> @@ -1480,6 +1480,53 @@ void blkcg_stop_wb_wait_on_bdi(struct backing_dev_info *bdi)
> spin_unlock(&blkcg_wb_sleeper_lock);
> rcu_read_unlock();
> }
> +
> +/**
> + * blkcg_set_mapping_dirty - set owner of a dirty mapping
> + * @mapping: target address space
> + *
> + * Set the current blkcg as the owner of the address space @mapping (the first
> + * blkcg that dirties @mapping becomes the owner).
> + */
> +void blkcg_set_mapping_dirty(struct address_space *mapping)
> +{
> + struct blkcg *curr_blkcg, *blkcg;
> +
> + if (mapping_tagged(mapping, PAGECACHE_TAG_WRITEBACK) ||
> + mapping_tagged(mapping, PAGECACHE_TAG_DIRTY))
> + return;
> +
> + rcu_read_lock();
> + curr_blkcg = blkcg_from_current();
> + blkcg = blkcg_from_mapping(mapping);
> + if (curr_blkcg != blkcg) {
> + if (blkcg)
> + css_put(&blkcg->css);
> + css_get(&curr_blkcg->css);
> + rcu_assign_pointer(mapping->i_blkcg, curr_blkcg);
> + }
> + rcu_read_unlock();
> +}
> +
> +/**
> + * blkcg_set_mapping_clean - clear the owner of a dirty mapping
> + * @mapping: target address space
> + *
> + * Unset the owner of @mapping when it becomes clean.
> + */
> +
> +void blkcg_set_mapping_clean(struct address_space *mapping)
> +{
> + struct blkcg *blkcg;
> +
> + rcu_read_lock();
> + blkcg = rcu_dereference(mapping->i_blkcg);
> + if (blkcg) {
> + css_put(&blkcg->css);
> + RCU_INIT_POINTER(mapping->i_blkcg, NULL);
> + }
> + rcu_read_unlock();
> +}
> #endif
>
Why do we need this? We already have the inode_attach_wb(), which has the
blkcg_css embedded in it for whoever dirtied the inode first. Can we not just
use that? Thanks,
Josef
Powered by blists - more mailing lists