From patchwork Mon Oct 9 21:29:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tejun Heo X-Patchwork-Id: 9994365 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 8E54060230 for ; Mon, 9 Oct 2017 21:29:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 80ECB2882A for ; Mon, 9 Oct 2017 21:29:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7457D2882F; Mon, 9 Oct 2017 21:29:44 +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 EBCB72882A for ; Mon, 9 Oct 2017 21:29:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755440AbdJIV3a (ORCPT ); Mon, 9 Oct 2017 17:29:30 -0400 Received: from mail-qk0-f194.google.com ([209.85.220.194]:33378 "EHLO mail-qk0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755265AbdJIV32 (ORCPT ); Mon, 9 Oct 2017 17:29:28 -0400 Received: by mail-qk0-f194.google.com with SMTP id z12so14039642qkb.0; Mon, 09 Oct 2017 14:29:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=GkBB3Ce6E4cJdRoiVd71JWDGqvc/6TwtL+a0raSyTe4=; b=KX//3t22mwShMObChHwE2WKly0u3BeKNtXCmVbasIIuXhdvhYRjIM1YP6GpM7OKW3m A1BOVi0h57EUM7iP7nKzJDWEj7pzw4kY8r7aDTdRYstcEWW2MTztzKliXOY7ma0LOeOt 4UHtlzwNvstSVMFb7QwW2plFgHvlLmy19G1GYgE4iTAEXVPrtFUDHtLMHnERFXiXnwez Cv1csXv8hDlCS/26NiC6s7E4lB6upgq7t6onyGRDRV6Ob7wO93siKL9nRLcOC0E9KW5+ PjquhnfQALRfeMcCkd8EQCYmPXF0NIfIvuF2aeTymLRjZU7xFuZHtMS2mN1FgA3WUNJ6 o2iQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=GkBB3Ce6E4cJdRoiVd71JWDGqvc/6TwtL+a0raSyTe4=; b=nLjHwpmTxiZkv+s8S6CVBpkkhbJ3UHobfZZSPLX2Z0MKIf1lQsusPEAElo4PdDDJeH 9ge18KpZC4ZznnhR1SRAfUc4Lw8SgDcpXZ8Hu3xab6DwnGXkwYsY98inv8sYNvw2rV5A DOYfDmS7e9B/uqzsq/pI+B3IJJWH1vKxv29ohMr7Ebe2+vbha2IvQwPvasFEhHo8qjoh h+lw3f7fdsycU/JYGZxbXSBTTHJlF201H3or1oCV+0gXJ8EVwem8dSRt08aY1j1Ldru6 Oa430P/AJRq5Qbeq0h93XvTBootdC5CGWM7aKVj3tg1He7lnZEDtIbINxz6Sp25thcOX nPsw== X-Gm-Message-State: AMCzsaUcylJANfohrx/LSZtBe6LQyS1VkjzGnWOQ7sParPTpD5ANAp5m Se+QSOcPShnaW16SfyFcL10= X-Google-Smtp-Source: AOwi7QBw9VeyKMlbauG+UepJRxZEOP6fJvrI9aBCUcnwYV6yimEHPTj3Y7n2z/A8hkncgo5ndjj2Sg== X-Received: by 10.55.4.135 with SMTP id 129mr11759271qke.137.1507584567509; Mon, 09 Oct 2017 14:29:27 -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 s44sm5555011qtc.92.2017.10.09.14.29.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Oct 2017 14:29:27 -0700 (PDT) From: Tejun Heo To: jack@suse.cz, axboe@kernel.dk, clm@fb.com, jbacik@fb.com Cc: kernel-team@fb.com, linux-kernel@vger.kernel.org, linux-btrfs@vger.kernel.org, Tejun Heo Subject: [PATCH 3/3] btrfs: ensure that metadata and flush are issued from the root cgroup Date: Mon, 9 Oct 2017 14:29:11 -0700 Message-Id: <20171009212911.473208-4-tj@kernel.org> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20171009212911.473208-1-tj@kernel.org> References: <20171009212911.473208-1-tj@kernel.org> 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. This patch updates btrfs_update_iflags() to not set S_CGROUPWB on btree_inodes. This isn't strictly necessary as those inodes don't call the function during init; however, this serves as documentation and prevents possible future mistakes. If this isn't desirable, please feel free to drop the section. Signed-off-by: Tejun Heo Cc: Chris Mason Cc: Josef Bacik --- fs/btrfs/check-integrity.c | 2 +- fs/btrfs/disk-io.c | 4 ++++ fs/btrfs/ioctl.c | 4 +++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/check-integrity.c b/fs/btrfs/check-integrity.c index 7d5a9b5..058dea6 100644 --- a/fs/btrfs/check-integrity.c +++ b/fs/btrfs/check-integrity.c @@ -2741,7 +2741,7 @@ int btrfsic_submit_bh(int op, int op_flags, struct buffer_head *bh) 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, blkcg_root_css); mutex_lock(&btrfsic_mutex); /* since btrfsic_submit_bh() might also be called before diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index dfdab84..fe8bbe1 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -1025,6 +1025,8 @@ static blk_status_t btree_submit_bio_hook(void *private_data, struct bio *bio, 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_device *device) 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; diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 117cc63..8a7db6c 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -150,7 +150,9 @@ void btrfs_update_iflags(struct inode *inode) new_fl |= S_NOATIME; if (ip->flags & BTRFS_INODE_DIRSYNC) new_fl |= S_DIRSYNC; - new_fl |= S_CGROUPWB; + /* btree_inodes are always in the root cgroup */ + if (btrfs_ino(ip) != BTRFS_BTREE_INODE_OBJECTID) + new_fl |= S_CGROUPWB; set_mask_bits(&inode->i_flags, S_SYNC | S_APPEND | S_IMMUTABLE | S_NOATIME | S_DIRSYNC |