From patchwork Wed Oct 4 17:41:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shaohua Li X-Patchwork-Id: 9985233 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 3BBEB6028E for ; Wed, 4 Oct 2017 17:41:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2D17728746 for ; Wed, 4 Oct 2017 17:41:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2214D28BC0; Wed, 4 Oct 2017 17:41:57 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham 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 EE75B28746 for ; Wed, 4 Oct 2017 17:41:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751072AbdJDRlz (ORCPT ); Wed, 4 Oct 2017 13:41:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:48260 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750787AbdJDRly (ORCPT ); Wed, 4 Oct 2017 13:41:54 -0400 Received: from shli-virt.localdomain (unknown [199.201.64.3]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D4E4821905; Wed, 4 Oct 2017 17:41:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D4E4821905 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=fail smtp.mailfrom=shli@fb.com From: Shaohua Li To: linux-block@vger.kernel.org Cc: vgoyal@redhat.com, tj@kernel.org, axboe@kernel.dk, Kernel-team@fb.com, Shaohua Li Subject: [RFC 1/2] block: record blkcss in request Date: Wed, 4 Oct 2017 10:41:19 -0700 Message-Id: <95356f4da3de009464a06c314bf79db672be6adf.1507138530.git.shli@fb.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Shaohua Li Currently we record block css info in bio but not in request. Normally we can get a request's css from its bio, but in some situations, we can't access request's bio, for example, after blk_update_request. Add the css to request, so we can access css through the life cycle of a request. Signed-off-by: Shaohua Li --- block/blk-core.c | 12 ++++++++++++ include/linux/blkdev.h | 1 + 2 files changed, 13 insertions(+) diff --git a/block/blk-core.c b/block/blk-core.c index adb064a..07f8f7e 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -1551,6 +1551,11 @@ void __blk_put_request(struct request_queue *q, struct request *req) return; } +#ifdef CONFIG_BLK_CGROUP + if (req->css) + css_put(req->css); +#endif + lockdep_assert_held(q->queue_lock); blk_pm_put_request(req); @@ -3094,6 +3099,13 @@ void blk_rq_bio_prep(struct request_queue *q, struct request *rq, rq->rq_flags |= RQF_QUIET; if (bio->bi_disk) rq->rq_disk = bio->bi_disk; +#ifdef CONFIG_BLK_CGROUP + rq->css = NULL; + if (bio->bi_css) { + rq->css = bio->bi_css; + css_get(rq->css); + } +#endif } #if ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 02fa42d..cdd3aeb 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -208,6 +208,7 @@ struct request { struct request_list *rl; /* rl this rq is alloced from */ unsigned long long start_time_ns; unsigned long long io_start_time_ns; /* when passed to hardware */ + struct cgroup_subsys_state *css; #endif /* Number of scatter-gather DMA addr+len pairs after * physical address coalescing is performed.