Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp4428518imm; Tue, 11 Sep 2018 11:44:25 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYRmQsUUCm/GSS14rnNC7LldHGo7B7F++pefBfaUlEbDugokH2WTA2mn7+82G03B/9gYkoW X-Received: by 2002:a17:902:127:: with SMTP id 36-v6mr29253478plb.178.1536691465707; Tue, 11 Sep 2018 11:44:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536691465; cv=none; d=google.com; s=arc-20160816; b=Du9ec0YvT8IZRtX8FiaRPT+QzXZ8N6eQkbfka3a6PQH2ZWI3uz7PTp6NVO5c3FHh5+ qSCipoPL3X6lS/hfKNo6jQqb1Ln8qmx751L1ki94z+SMOC7yHd7oBpGcdcMkjhLmpgT/ Vy1iggaWyZTVZaS6mpQtHOS6u3vSR2etAyKgd8mLo0wRiIoPR3igVbgiS3xyUm4H79wq t5oOIICM3uTw1QhMnmBcnYJXlB3SMbNwVgakcN8yws4YYypJb7W5MFujtxUByrIF1DWk mCxIVoc3+H27CYE04dnup7oZG8Pn2QM6HgK5xdmC7p1B8BYxFwWci69G6vtps1H/iwCu tIAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=FkDgmX6YNgFCNFUn3Et8v5b6B07m4GOk66oKL1F2CRg=; b=xdDMNyD+SV9hJjAwghhTJU7e3V8S/NigOCslr9GBLfbKDriMDDgFG+lcAVU+HcD/S2 G91UQYHOf76dFCKpw8xAiRBhVIGbB/9fg0h5MWV8beJ+PPSKmatSNS0fSoc+4GejywpB O4gLyf5ghk0QDm1JZ+RE4fqJJXlcibOUrVHHJy6OBcadPxhr6Ki7/f7K4He7A69O8r2S igWLP++7P/qU9U3di6yfX6HFxHUuvzHc2LxzkzaJsNZe+JcQ7AumJXnz8DRlg/0/hLn8 ciacQIWIN9qsppZzTywSLLpEVWtfjtGyn9rPeAtaJf7KEWrojWExlBkQ22BYIOyzjeuC vQUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=mGygZNE6; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q8-v6si19413756pfh.353.2018.09.11.11.44.10; Tue, 11 Sep 2018 11:44:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=mGygZNE6; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728324AbeIKXm3 (ORCPT + 99 others); Tue, 11 Sep 2018 19:42:29 -0400 Received: from mail-yb1-f193.google.com ([209.85.219.193]:33176 "EHLO mail-yb1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726622AbeIKXm1 (ORCPT ); Tue, 11 Sep 2018 19:42:27 -0400 Received: by mail-yb1-f193.google.com with SMTP id m123-v6so9741880ybm.0; Tue, 11 Sep 2018 11:41:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=FkDgmX6YNgFCNFUn3Et8v5b6B07m4GOk66oKL1F2CRg=; b=mGygZNE6R8vykkRJpASf0GghNDi/HMMohnHWuxa5UMirclwqDK6yWQFiht/cECSYxa Q5RGNy0B6E4DoS01BWEZoT7RVb3FVqaq+u4qS6MiWnOt2/utnbtTYotziTsNJAlx4f2/ 4yBS8HuTEAuTkdUzi7ZW1aTgR7Q/QYxq0eDbUdSqd6PMN/l3fliYR534AyjF1iSBbRPp l9A6TJxM0c4Vym3fWG9vFcOTce5dI9EKiGi0qgeX6L+UZIUc+nEUgwPNiFbgx0r2ZAJF LmlvIM92ZsElKIxZFBirxLyvzJ9LPu/z6u8YfEGm6XSPd++52sv1rxvAJKru7bCRx0jz jflg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=FkDgmX6YNgFCNFUn3Et8v5b6B07m4GOk66oKL1F2CRg=; b=MM1zXbPV+mPXDA/w64KJE3iHPT3k0n3JDmKkGQHn+FB2lyOWI28LXxY4CEcr6NyPmj +5QvnFj/9vDSAtfRBxZuEQ1nwb9YBszE6Z8T8YPwrMsA1s29NkX9BrpwqwYOWGT8IqO5 Sc1RtTC4yvehfzD1NZcsInwr9zM0s02Q5ij4cdfRSk01Ipgx9BU/SWDl476qeJy/1O6n BMGGzY08Xhzxi+EujniSTKDRaJVn5gwVIqc+xWm8BYWNaFTqKUadY7LK6HLg+DSX4CtD EPylIpKvMTQZhSdD1znmvHTHUMQKHRG8BVXA+ldzAAsMve7FyAAHkk4mQvg6v7NdQHx0 IWhw== X-Gm-Message-State: APzg51DN7zma1UwJYU5hw/TZw2d2D39scKb3YQMqRE7GSQZajGyw/Dgs z2gmaviM+kAqvP0y4ycWiPThE7igpTY= X-Received: by 2002:a25:220a:: with SMTP id i10-v6mr12983355ybi.489.1536691311120; Tue, 11 Sep 2018 11:41:51 -0700 (PDT) Received: from dennisz-mbp.thefacebook.com ([199.201.65.129]) by smtp.gmail.com with ESMTPSA id i123-v6sm7902875ywe.14.2018.09.11.11.41.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Sep 2018 11:41:50 -0700 (PDT) From: Dennis Zhou To: Jens Axboe , Tejun Heo , Johannes Weiner , Josef Bacik Cc: kernel-team@fb.com, linux-block@vger.kernel.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, "Dennis Zhou (Facebook)" Subject: [PATCH 07/12] blkcg: associate writeback bios with a blkg Date: Tue, 11 Sep 2018 14:41:32 -0400 Message-Id: <20180911184137.35897-8-dennisszhou@gmail.com> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20180911184137.35897-1-dennisszhou@gmail.com> References: <20180911184137.35897-1-dennisszhou@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "Dennis Zhou (Facebook)" One of the goals of this series is to remove a separate reference to the css of the bio. This can and should be accessed via bio_blkcg. In this patch, the wbc_init_bio call is changed such that it must be called after a queue has been associated with the bio. Signed-off-by: Dennis Zhou Reviewed-by: Josef Bacik Acked-by: Tejun Heo --- Documentation/admin-guide/cgroup-v2.rst | 8 +++++--- fs/buffer.c | 10 +++++----- fs/ext4/page-io.c | 2 +- include/linux/writeback.h | 5 +++-- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/Documentation/admin-guide/cgroup-v2.rst b/Documentation/admin-guide/cgroup-v2.rst index 184193bcb262..caf36105a1c7 100644 --- a/Documentation/admin-guide/cgroup-v2.rst +++ b/Documentation/admin-guide/cgroup-v2.rst @@ -1857,8 +1857,10 @@ following two functions. wbc_init_bio(@wbc, @bio) Should be called for each bio carrying writeback data and - associates the bio with the inode's owner cgroup. Can be - called anytime between bio allocation and submission. + associates the bio with the inode's owner cgroup and the + corresponding request queue. This must be called after + a queue (device) has been associated with the bio and + before submission. wbc_account_io(@wbc, @page, @bytes) Should be called for each data segment being written out. @@ -1877,7 +1879,7 @@ the configuration, the bio may be executed at a lower priority and if the writeback session is holding shared resources, e.g. a journal entry, may lead to priority inversion. There is no one easy solution for the problem. Filesystems can try to work around specific problem -cases by skipping wbc_init_bio() or using bio_associate_blkcg() +cases by skipping wbc_init_bio() or using bio_associate_create_blkg() directly. diff --git a/fs/buffer.c b/fs/buffer.c index 6f1ae3ac9789..109f55196866 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -3060,11 +3060,6 @@ static int submit_bh_wbc(int op, int op_flags, struct buffer_head *bh, */ bio = bio_alloc(GFP_NOIO, 1); - if (wbc) { - wbc_init_bio(wbc, bio); - wbc_account_io(wbc, bh->b_page, bh->b_size); - } - bio->bi_iter.bi_sector = bh->b_blocknr * (bh->b_size >> 9); bio_set_dev(bio, bh->b_bdev); bio->bi_write_hint = write_hint; @@ -3084,6 +3079,11 @@ static int submit_bh_wbc(int op, int op_flags, struct buffer_head *bh, op_flags |= REQ_PRIO; bio_set_op_attrs(bio, op, op_flags); + if (wbc) { + wbc_init_bio(wbc, bio); + wbc_account_io(wbc, bh->b_page, bh->b_size); + } + submit_bio(bio); return 0; } diff --git a/fs/ext4/page-io.c b/fs/ext4/page-io.c index db7590178dfc..2aa62d58d8dd 100644 --- a/fs/ext4/page-io.c +++ b/fs/ext4/page-io.c @@ -374,13 +374,13 @@ static int io_submit_init_bio(struct ext4_io_submit *io, bio = bio_alloc(GFP_NOIO, BIO_MAX_PAGES); if (!bio) return -ENOMEM; - wbc_init_bio(io->io_wbc, bio); bio->bi_iter.bi_sector = bh->b_blocknr * (bh->b_size >> 9); bio_set_dev(bio, bh->b_bdev); bio->bi_end_io = ext4_end_bio; bio->bi_private = ext4_get_io_end(io->io_end); io->io_bio = bio; io->io_next_block = bh->b_blocknr; + wbc_init_bio(io->io_wbc, bio); return 0; } diff --git a/include/linux/writeback.h b/include/linux/writeback.h index fdfd04e348f6..738a0c24874f 100644 --- a/include/linux/writeback.h +++ b/include/linux/writeback.h @@ -246,7 +246,8 @@ static inline void wbc_attach_fdatawrite_inode(struct writeback_control *wbc, * * @bio is a part of the writeback in progress controlled by @wbc. Perform * writeback specific initialization. This is used to apply the cgroup - * writeback context. + * writeback context. Must be called after the bio has been associated with + * a device. */ static inline void wbc_init_bio(struct writeback_control *wbc, struct bio *bio) { @@ -257,7 +258,7 @@ static inline void wbc_init_bio(struct writeback_control *wbc, struct bio *bio) * regular writeback instead of writing things out itself. */ if (wbc->wb) - bio_associate_blkcg(bio, wbc->wb->blkcg_css); + bio_associate_blkg_from_css(bio, wbc->wb->blkcg_css); } #else /* CONFIG_CGROUP_WRITEBACK */ -- 2.17.1