From patchwork Thu Oct 12 17:06:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tejun Heo X-Patchwork-Id: 10002421 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1703E60216 for ; Thu, 12 Oct 2017 17:06:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0127622B39 for ; Thu, 12 Oct 2017 17:06:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E9FDD28E55; Thu, 12 Oct 2017 17:06:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A06C722B39 for ; Thu, 12 Oct 2017 17:06:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752759AbdJLRGf (ORCPT ); Thu, 12 Oct 2017 13:06:35 -0400 Received: from mail-qt0-f178.google.com ([209.85.216.178]:52636 "EHLO mail-qt0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751901AbdJLRGe (ORCPT ); Thu, 12 Oct 2017 13:06:34 -0400 Received: by mail-qt0-f178.google.com with SMTP id o52so14857839qtc.9; Thu, 12 Oct 2017 10:06:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=DSZ7UVlO/o/24VkiL0C+bH/ckQ/aDkyrAv/10R4EjXI=; b=g5zsIgwryoiJzfTOuAklgabDnBpCN/SPA/t4mb2JtRkAK9dmyQnvvsMwlH+yOmPz1k Nffh2yJgi4/hdu6fpjV05yrS28CbPIbRk+KWArsVbOP76Ie9j0u2wkBjU/xBHiKLkz6e iOmllzVKf5JtySrEn6eTnSJCkwwnYYILD+BvlS+yq4oeJPb1I+RNkXHrd2drYq8CzrNl UbOFG8KLShSDYmAi7x+J/KKJalvhNo5YZ4mToYCPqjW9OI4g0D04GOCF+A102OgB+fJZ Y19idKPUWHx0+k/rmM++ToehXQhFm18hfSgr0r7s/uBzaIN8IO973PM9NyK7oqtJ1Q3X npKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=DSZ7UVlO/o/24VkiL0C+bH/ckQ/aDkyrAv/10R4EjXI=; b=sEfsh0zgqCmC9zXBcTxxlquogEdeDVyJO17b5sZpHD7wEzWpKZ/9zy2r3wqqunQ82g NcCzYtSkHr6mHm5tEnMhkO5J4KYH64BKOF5JZgcQTRBY7plWxvg2QaDX48nVK8iaUgKk w4mku0fA9DCetF5mpVEGkEnI7vRrWZnTHvYx4KufZncwxHJZ8fY3oOJjU7z6ncxECJH1 UhBL7cEMbHetqodqzCqh3W1mfSIzh1TIVjlf/6waF76zK8wfwOmE67fKfN6UXBnHPj2r wey8Oekt4+LNAcPmr1LFvNULMU/OzxD2TdKBDp911kXR0CJHmJgb9RtaU/XrgUE2WAuS ehsQ== X-Gm-Message-State: AMCzsaUK/btZoK0BsyS5gc37CgoPPrDZ50G8b34OkPK0ofGx3//63Exq BLFnbn/YYoYY2+LaVSRxez4= X-Google-Smtp-Source: AOwi7QCOH3zruH7ULNDqRnEbmOc0SIYtct4bJgMRikRVZIDVBDEL0tDaPVgJJf+RLma5iZEJpjfmGg== X-Received: by 10.200.6.13 with SMTP id d13mr4653896qth.217.1507827993555; Thu, 12 Oct 2017 10:06:33 -0700 (PDT) Received: from localhost (dhcp-ec-8-6b-ed-7a-cf.cpe.echoes.net. [72.28.5.223]) by smtp.gmail.com with ESMTPSA id t49sm1074365qta.54.2017.10.12.10.06.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Oct 2017 10:06:33 -0700 (PDT) Date: Thu, 12 Oct 2017 10:06:28 -0700 From: Tejun Heo 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 Message-ID: <20171012170628.GS3301751@devbig577.frc2.facebook.com> References: <20171010155441.753966-1-tj@kernel.org> <20171010155441.753966-6-tj@kernel.org> <20171010164325.GN3301751@devbig577.frc2.facebook.com> <20171011170723.GX3521@twin.jikos.cz> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20171011170723.GX3521@twin.jikos.cz> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Reviewed-by: Liu Bo Cc: David Sterba Cc: Chris Mason Cc: Josef Bacik Acked-by: David Sterba --- fs/btrfs/check-integrity.c | 2 +- fs/btrfs/disk-io.c | 4 ++++ fs/btrfs/ioctl.c | 4 ++++ 3 files changed, 9 insertions(+), 1 deletion(-) -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html --- 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,