linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: dsterba@suse.cz, jack@suse.cz, axboe@kernel.dk, clm@fb.com,
	jbacik@fb.com, kernel-team@fb.com, linux-kernel@vger.kernel.org,
	linux-btrfs@vger.kernel.org
Subject: [PATCH v3 5/5] btrfs: ensure that metadata and flush are issued from the root cgroup
Date: Thu, 12 Oct 2017 10:06:28 -0700	[thread overview]
Message-ID: <20171012170628.GS3301751@devbig577.frc2.facebook.com> (raw)
In-Reply-To: <20171011170723.GX3521@twin.jikos.cz>

Issuing metdata or otherwise shared IOs from !root cgroup can lead to
priority inversion.  This patch ensures that those IOs are always
issued from the root cgroup.

v3: Dropped unnecessary btree_inode handling as suggested by David
    Sterba.

v2: Fixed missing @bh in submit_bh_blkcg_css() call.

Signed-off-by: Tejun Heo <tj@kernel.org>
Reviewed-by: Liu Bo <bo.li.liu@oracle.com>
Cc: David Sterba <dsterba@suse.cz>
Cc: Chris Mason <clm@fb.com>
Cc: Josef Bacik <jbacik@fb.com>
---
 fs/btrfs/check-integrity.c |    2 +-
 fs/btrfs/disk-io.c         |    4 ++++
 fs/btrfs/ioctl.c           |    4 ++++
 3 files changed, 9 insertions(+), 1 deletion(-)

--- a/fs/btrfs/check-integrity.c
+++ b/fs/btrfs/check-integrity.c
@@ -2741,7 +2741,7 @@ int btrfsic_submit_bh(int op, int op_fla
 	struct btrfsic_dev_state *dev_state;
 
 	if (!btrfsic_is_initialized)
-		return submit_bh(op, op_flags, bh);
+		return submit_bh_blkcg_css(op, op_flags, bh, blkcg_root_css);
 
 	mutex_lock(&btrfsic_mutex);
 	/* since btrfsic_submit_bh() might also be called before
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -1025,6 +1025,8 @@ static blk_status_t btree_submit_bio_hoo
 	int async = check_async_write(bio_flags);
 	blk_status_t ret;
 
+	bio_associate_blkcg(bio, blkcg_root_css);
+
 	if (bio_op(bio) != REQ_OP_WRITE) {
 		/*
 		 * called for a read, do the setup so that checksum validation
@@ -3512,6 +3514,8 @@ static void write_dev_flush(struct btrfs
 		return;
 
 	bio_reset(bio);
+	bio_associate_blkcg(bio, blkcg_root_css);
+
 	bio->bi_end_io = btrfs_end_empty_barrier;
 	bio_set_dev(bio, device->bdev);
 	bio->bi_opf = REQ_OP_WRITE | REQ_SYNC | REQ_PREFLUSH;
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -150,6 +150,10 @@ void btrfs_update_iflags(struct inode *i
 		new_fl |= S_NOATIME;
 	if (ip->flags & BTRFS_INODE_DIRSYNC)
 		new_fl |= S_DIRSYNC;
+	/*
+	 * The btree_inode will be always in the root cgroup. The cgroup
+	 * writeback can be enabled on regular inodes selectively.
+	 */
 	new_fl |= S_CGROUPWB;
 
 	set_mask_bits(&inode->i_flags,

  parent reply	other threads:[~2017-10-12 17:06 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-10 15:54 [PATCHSET v2] cgroup, writeback, btrfs: make sure btrfs issues metadata IOs from the root cgroup Tejun Heo
2017-10-10 15:54 ` [PATCH 1/5] blkcg: export blkcg_root_css Tejun Heo
2017-10-11  7:50   ` Jan Kara
2017-10-10 15:54 ` [PATCH 2/5] cgroup, writeback: replace SB_I_CGROUPWB with per-inode S_CGROUPWB Tejun Heo
2017-10-10 15:54 ` [PATCH 3/5] buffer_head: separate out create_bh_bio() from submit_bh_wbc() Tejun Heo
2017-10-11  7:54   ` Jan Kara
2017-10-10 15:54 ` [PATCH 4/5] cgroup, buffer_head: implement submit_bh_blkcg_css() Tejun Heo
2017-10-11  7:55   ` Jan Kara
2017-10-10 15:54 ` [PATCH 5/5] btrfs: ensure that metadata and flush are issued from the root cgroup Tejun Heo
2017-10-10 16:43   ` [PATCH v2 " Tejun Heo
2017-10-10 17:45     ` Liu Bo
2017-10-11 17:07     ` David Sterba
2017-10-12 15:38       ` Tejun Heo
2017-10-12 17:06       ` Tejun Heo [this message]
2017-10-12 18:56         ` [PATCH v3 " David Sterba
2017-11-29 16:56 ` [PATCHSET v2] cgroup, writeback, btrfs: make sure btrfs issues metadata IOs " Jan Kara
2017-11-29 17:03   ` Tejun Heo
2017-11-29 17:05     ` Tejun Heo
2017-11-29 18:38       ` Chris Mason
2017-11-30 17:23         ` David Sterba
2017-11-30 17:34           ` Chris Mason
2017-12-01 10:52         ` Jan Kara

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171012170628.GS3301751@devbig577.frc2.facebook.com \
    --to=tj@kernel.org \
    --cc=axboe@kernel.dk \
    --cc=clm@fb.com \
    --cc=dsterba@suse.cz \
    --cc=jack@suse.cz \
    --cc=jbacik@fb.com \
    --cc=kernel-team@fb.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).