From patchwork Tue Oct 10 15:54:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tejun Heo X-Patchwork-Id: 9996639 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 51B59603FF for ; Tue, 10 Oct 2017 15:55:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4376328676 for ; Tue, 10 Oct 2017 15:55:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3829F2867F; Tue, 10 Oct 2017 15:55:37 +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 B196828676 for ; Tue, 10 Oct 2017 15:55:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932493AbdJJPzL (ORCPT ); Tue, 10 Oct 2017 11:55:11 -0400 Received: from mail-qt0-f195.google.com ([209.85.216.195]:54930 "EHLO mail-qt0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932393AbdJJPzJ (ORCPT ); Tue, 10 Oct 2017 11:55:09 -0400 Received: by mail-qt0-f195.google.com with SMTP id z19so7151059qtg.11; Tue, 10 Oct 2017 08:55:09 -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=dKkPLdybMoI1g0ZVEkWnBo2h4pA7uoDls2axgDSILcnEbb+IJBrdj+SfqbmMkYvKr5 WVzZXLKFd14OvrBIngDg6LxOiipQrdNOqZAvh6zEX9vESL/Y0VOCOX41cNXvTSK3jq7p UfGXRAHoT9GC873/P3wsMYbNE7xwbHCCTN+cK2815crw2qwWtCVW+RDGKSuAhxaPNB+y AxlgT74/vrqCqMub0H7Ie6zXfjfQS6lfTPGZFpRaRdWpmvDRBnMn3S2+U3TXUicx3BTV KZJhS1sfi5c6O4wGte6N8fvnmsEC9R99ptUXggjALM0WYr67lFvyFTfgJSEoxW9Bjph8 mlsA== 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=uCvL7gcpjqw7Mxy9QWI+Xz6zNB74A44gn0uRNTUcbHAOi7/M4tuCPFR9Sd4mccb3ls CoaG0BN8dsTEDaRc9YTLuKJJFFcuOR19LZOIgHomiuC4ZxU0SVxzWhAudOIZJlZ7YzPe C3gaSA5AnCX4zzzr4woI0GR/BV+AmANbvyn+I5NYLJy5LIIoz7jbxYf0tIPVkirvQoXT vjr5JwzM+gF881KYbFifEvIIoNxNMZZmgho3v62wQUqQympGVZFTzbAOSECGnCktp9Ib 7Q1JyH4QkI2M/S7gPAytLdK1mpWSOJsYzVilNvNKvkDfdvhU2488vihZK2zH5zc0saQu ptwg== X-Gm-Message-State: AMCzsaVq5/Yl8zl1PlDt2qjmB7IfSNsem7apkhbqhokeiHZGqUV0Jqhx su5EVTSSqHq0Cj8LJJ3EYwI= X-Google-Smtp-Source: AOwi7QDPOjaI3bxsf3l5bfx+nhLFQMLvRopDF/XGmyo4+m5cZnDM09y/igVH+F7RG9AO09piP+cF7Q== X-Received: by 10.237.37.16 with SMTP id v16mr20709916qtc.53.1507650908593; Tue, 10 Oct 2017 08:55:08 -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 g132sm6466935qke.11.2017.10.10.08.55.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Oct 2017 08:55:08 -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 5/5] btrfs: ensure that metadata and flush are issued from the root cgroup Date: Tue, 10 Oct 2017 08:54:41 -0700 Message-Id: <20171010155441.753966-6-tj@kernel.org> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20171010155441.753966-1-tj@kernel.org> References: <20171010155441.753966-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 |