From patchwork Fri Jan 20 11:15:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hou Tao X-Patchwork-Id: 9527987 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 D696F60434 for ; Fri, 20 Jan 2017 11:19:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C92C4285B9 for ; Fri, 20 Jan 2017 11:19:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BE39D28609; Fri, 20 Jan 2017 11:19:22 +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 66F7A285B9 for ; Fri, 20 Jan 2017 11:19:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751658AbdATLTV (ORCPT ); Fri, 20 Jan 2017 06:19:21 -0500 Received: from szxga03-in.huawei.com ([119.145.14.66]:23584 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751759AbdATLTH (ORCPT ); Fri, 20 Jan 2017 06:19:07 -0500 Received: from 172.24.1.137 (EHLO szxeml422-hub.china.huawei.com) ([172.24.1.137]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id COH29040; Fri, 20 Jan 2017 19:15:44 +0800 (CST) Received: from huawei.com (10.175.124.28) by szxeml422-hub.china.huawei.com (10.82.67.152) with Microsoft SMTP Server id 14.3.235.1; Fri, 20 Jan 2017 19:15:39 +0800 From: Hou Tao To: , CC: , , , Subject: [PATCH RFC 4/4] dm thin: associate bio with current task if keep_bio_blkcg is enabled Date: Fri, 20 Jan 2017 19:15:52 +0800 Message-ID: <1484910952-29820-5-git-send-email-houtao1@huawei.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1484910952-29820-1-git-send-email-houtao1@huawei.com> References: <1484910952-29820-1-git-send-email-houtao1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.28] X-CFilter-Loop: Reflected 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 If keep_bio_blkcg is enabled, assign the io_context and the blkcg of current task to bio before processing the bio. Signed-off-by: Hou Tao --- drivers/md/dm-thin.c | 5 +++++ drivers/md/dm-thin.h | 17 +++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 drivers/md/dm-thin.h diff --git a/drivers/md/dm-thin.c b/drivers/md/dm-thin.c index 140cdae..0efbdbe 100644 --- a/drivers/md/dm-thin.c +++ b/drivers/md/dm-thin.c @@ -22,6 +22,8 @@ #include #include +#include "dm-thin.h" + #define DM_MSG_PREFIX "thin" /* @@ -2629,6 +2631,9 @@ static int thin_bio_map(struct dm_target *ti, struct bio *bio) struct dm_bio_prison_cell *virt_cell, *data_cell; struct dm_cell_key key; + if (keep_pool_bio_blkcg(tc->pool)) + thin_keep_bio_blkcg(bio); + thin_hook_bio(tc, bio); if (tc->requeue_mode) { diff --git a/drivers/md/dm-thin.h b/drivers/md/dm-thin.h new file mode 100644 index 0000000..09e920a --- /dev/null +++ b/drivers/md/dm-thin.h @@ -0,0 +1,17 @@ +#ifndef DM_THIN_H +#define DM_THIN_H + +#include + +#ifdef CONFIG_BLK_CGROUP +static inline void thin_keep_bio_blkcg(struct bio *bio) +{ + if (!bio->bi_css) + bio_associate_current(bio); +} +#else +static inline void thin_keep_bio_blkcg(struct bio *bio) {} +#endif /* CONFIG_BLK_CGROUP */ + +#endif +