From patchwork Thu Feb 2 17:33:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 9552799 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 7A42F60405 for ; Thu, 2 Feb 2017 17:41:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 708FC2656B for ; Thu, 2 Feb 2017 17:41:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 655C028422; Thu, 2 Feb 2017 17:41:36 +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 C83132656B for ; Thu, 2 Feb 2017 17:41:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752279AbdBBRl1 (ORCPT ); Thu, 2 Feb 2017 12:41:27 -0500 Received: from mx2.suse.de ([195.135.220.15]:45918 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752498AbdBBRl0 (ORCPT ); Thu, 2 Feb 2017 12:41:26 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 6447AAB5D; Thu, 2 Feb 2017 17:41:04 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 4A3E31E06BA; Thu, 2 Feb 2017 18:35:54 +0100 (CET) From: Jan Kara To: Cc: Christoph Hellwig , linux-block@vger.kernel.org, Jan Kara Subject: [PATCH 01/24] block: Provide bdi_alloc() Date: Thu, 2 Feb 2017 18:33:59 +0100 Message-Id: <20170202173422.3240-2-jack@suse.cz> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20170202173422.3240-1-jack@suse.cz> References: <20170202173422.3240-1-jack@suse.cz> 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 Provide bdi_alloc() forsimple allocation of a BDI that can be used by filesystems that don't need anything fancy. We use this function when converting filesystems from embedded struct backing_dev_info into a dynamically allocated one. Signed-off-by: Jan Kara --- include/linux/backing-dev.h | 1 + mm/backing-dev.c | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/include/linux/backing-dev.h b/include/linux/backing-dev.h index c52a48cb9a66..81c07ade4305 100644 --- a/include/linux/backing-dev.h +++ b/include/linux/backing-dev.h @@ -37,6 +37,7 @@ void bdi_unregister(struct backing_dev_info *bdi); int __must_check bdi_setup_and_register(struct backing_dev_info *, char *); void bdi_destroy(struct backing_dev_info *bdi); struct backing_dev_info *bdi_alloc_node(gfp_t gfp_mask, int node_id); +struct backing_dev_info *bdi_alloc(gfp_t gfp_mask); void wb_start_writeback(struct bdi_writeback *wb, long nr_pages, bool range_cyclic, enum wb_reason reason); diff --git a/mm/backing-dev.c b/mm/backing-dev.c index 28ce6cf7b2ff..7a5ba4163656 100644 --- a/mm/backing-dev.c +++ b/mm/backing-dev.c @@ -809,6 +809,21 @@ struct backing_dev_info *bdi_alloc_node(gfp_t gfp_mask, int node_id) return bdi; } +struct backing_dev_info *bdi_alloc(gfp_t gfp_mask) +{ + struct backing_dev_info *bdi; + + bdi = kmalloc(sizeof(struct backing_dev_info), gfp_mask | __GFP_ZERO); + if (!bdi) + return NULL; + if (bdi_init(bdi)) { + kfree(bdi); + return NULL; + } + return bdi; +} +EXPORT_SYMBOL(bdi_alloc); + int bdi_register(struct backing_dev_info *bdi, struct device *parent, const char *fmt, ...) {