From patchwork Tue Oct 10 15:54:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tejun Heo X-Patchwork-Id: 9996645 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 7532260216 for ; Tue, 10 Oct 2017 15:55:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 66C0F28676 for ; Tue, 10 Oct 2017 15:55:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5B7E42867F; Tue, 10 Oct 2017 15:55:51 +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=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 DE3AB28676 for ; Tue, 10 Oct 2017 15:55:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932471AbdJJPzI (ORCPT ); Tue, 10 Oct 2017 11:55:08 -0400 Received: from mail-qt0-f196.google.com ([209.85.216.196]:56817 "EHLO mail-qt0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932393AbdJJPzG (ORCPT ); Tue, 10 Oct 2017 11:55:06 -0400 Received: by mail-qt0-f196.google.com with SMTP id 34so35562900qtb.13; Tue, 10 Oct 2017 08:55:06 -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=thdIzlQy6iusKwtkMsm/dnJHQwexNWnMFTCkHzy4jJ8=; b=DCy14s8WNsC8ncbl0aWeyjkxQgBaWKHAve6PnmGpTrjqpw4J8VECGMJOl1dOn08y+R oandWmmj5YA213Yorq2nefpS89tBvzDn35rKZ/YwhJHvbs3UuOEjftkBfi5HwRAcRD4p gDFYLOo4ss0YuAPo3VYTNm2jZMchGYIzRdBCDvFaGMQLGF93voXnFxRTdrQcMg2Zx4DO o/0+ep3iv2dXR2gwFMVqV5dP5aFxdorqiwC+cFb4UaKuV8H56eGV+VfO+336vle+vC4+ +d07GmrzMTx8IZQTbV/bRi0lxMGt/PQlP7MfvNEs+gJmbd5QzGYynK2Rt5/53n8LMcnA hIrA== 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=thdIzlQy6iusKwtkMsm/dnJHQwexNWnMFTCkHzy4jJ8=; b=XP6650h/Cf3OfLgFZjMTE/r5TEsz+PxvOUhQLepGRvysVkxTDnYz/stcE/d2OWoDbu HWYZNh45RvAiOTJMgG3Hy1HuJ/qch12x917evihzIq0rSLjOcxm+IAMdh3DhD0HXJ+xv ouEmyVrM5y17s+UR6LqJz+Rk+kFAdSFm1B7jCllX22I7g3P85F9HmE2vxBHPTyI3nsDN a+x1talRV3hGxCzukAJHl9BFBAM34hib+zO71bu+WrbpYO/SsslzLe/np+c99z9recH3 gvDlCbKXsaWsJo4oGX88LH5YuiyPGyigxNYHiJRITKAT+MWkEGKzCJ2ziGqbzVsrZIRX Bmgg== X-Gm-Message-State: AMCzsaWLLz3GCBmDnqVSp7f7VD4ZIUGiZCV8joqe6LfVLIhgNke6VpVo T5VBitIWFzY3omb5in0Mq5L7ktsh X-Google-Smtp-Source: AOwi7QChnuFlA8ctsLtNILkuOCSMXU45YpCiljBZ6c+j/IOJM0fA5gv/0fFfKkJWjWf3tXxwP1h9AA== X-Received: by 10.200.3.159 with SMTP id t31mr15469485qtg.102.1507650905790; Tue, 10 Oct 2017 08:55:05 -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 z26sm6788625qtz.52.2017.10.10.08.55.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Oct 2017 08:55:05 -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 4/5] cgroup, buffer_head: implement submit_bh_blkcg_css() Date: Tue, 10 Oct 2017 08:54:40 -0700 Message-Id: <20171010155441.753966-5-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 Implement submit_bh_blkcg_css() which will be used to override cgroup membership on specific buffer_heads. v2: Reimplemented using create_bh_bio() as suggested by Jan. Signed-off-by: Tejun Heo Cc: Jan Kara Cc: Jens Axboe Reviewed-by: Jan Kara --- fs/buffer.c | 12 ++++++++++++ include/linux/buffer_head.h | 3 +++ 2 files changed, 15 insertions(+) diff --git a/fs/buffer.c b/fs/buffer.c index b4b2169..ed0e473 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -3147,6 +3147,18 @@ static int submit_bh_wbc(int op, int op_flags, struct buffer_head *bh, return 0; } +int submit_bh_blkcg_css(int op, int op_flags, struct buffer_head *bh, + struct cgroup_subsys_state *blkcg_css) +{ + struct bio *bio; + + bio = create_bh_bio(op, op_flags, bh, 0); + bio_associate_blkcg(bio, blkcg_css); + submit_bio(bio); + return 0; +} +EXPORT_SYMBOL(submit_bh_blkcg_css); + int submit_bh(int op, int op_flags, struct buffer_head *bh) { struct bio *bio; diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h index c8dae55..dca5b3b 100644 --- a/include/linux/buffer_head.h +++ b/include/linux/buffer_head.h @@ -13,6 +13,7 @@ #include #include #include +#include #ifdef CONFIG_BLOCK @@ -197,6 +198,8 @@ void ll_rw_block(int, int, int, struct buffer_head * bh[]); int sync_dirty_buffer(struct buffer_head *bh); int __sync_dirty_buffer(struct buffer_head *bh, int op_flags); void write_dirty_buffer(struct buffer_head *bh, int op_flags); +int submit_bh_blkcg_css(int op, int op_flags, struct buffer_head *bh, + struct cgroup_subsys_state *blkcg_css); int submit_bh(int, int, struct buffer_head *); void write_boundary_block(struct block_device *bdev, sector_t bblock, unsigned blocksize);