From patchwork Thu Jul 30 05:48:10 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Dongsheng X-Patchwork-Id: 6898391 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 843C09F358 for ; Thu, 30 Jul 2015 05:54:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7C05A20546 for ; Thu, 30 Jul 2015 05:54:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8F48F2054D for ; Thu, 30 Jul 2015 05:54:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753527AbbG3FyZ (ORCPT ); Thu, 30 Jul 2015 01:54:25 -0400 Received: from cn.fujitsu.com ([59.151.112.132]:60081 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1752206AbbG3FyY (ORCPT ); Thu, 30 Jul 2015 01:54:24 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="99064487" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 30 Jul 2015 13:57:56 +0800 Received: from G08CNEXCHPEKD02.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t6U5qVtF028294; Thu, 30 Jul 2015 13:52:31 +0800 Received: from yds-PC.g08.fujitsu.local (10.167.226.66) by G08CNEXCHPEKD02.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Thu, 30 Jul 2015 13:54:22 +0800 From: Dongsheng Yang To: , , , CC: , , Dongsheng Yang Subject: [PATCH v2 14/35] ubifs: extend budget for blocks Date: Thu, 30 Jul 2015 13:48:10 +0800 Message-ID: <1438235311-23788-15-git-send-email-yangds.fnst@cn.fujitsu.com> X-Mailer: git-send-email 1.8.4.2 In-Reply-To: <1438235311-23788-1-git-send-email-yangds.fnst@cn.fujitsu.com> References: <1438235311-23788-1-git-send-email-yangds.fnst@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.226.66] Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently, budget subsystem in ubifs are working on budgeting page-by-page. But sometimes we want to budget a space for one block, e.g for quota file writing. So this commit extend budget subsystem to support blocks budgeting and releasing. Signed-off-by: Dongsheng Yang --- fs/ubifs/budget.c | 4 ++++ fs/ubifs/debug.c | 2 ++ fs/ubifs/super.c | 1 + fs/ubifs/ubifs.h | 5 +++++ 4 files changed, 12 insertions(+) diff --git a/fs/ubifs/budget.c b/fs/ubifs/budget.c index 11a11b3..ba4e530 100644 --- a/fs/ubifs/budget.c +++ b/fs/ubifs/budget.c @@ -397,6 +397,8 @@ static int calc_data_growth(const struct ubifs_info *c, data_growth += c->bi.page_budget; if (req->new_dent) data_growth += c->bi.dent_budget; + if (req->new_block_num) + data_growth += c->bi.block_budget * req->new_block_num; data_growth += req->new_ino_d; return data_growth; } @@ -418,6 +420,8 @@ static int calc_dd_growth(const struct ubifs_info *c, dd_growth += c->bi.inode_budget << (req->dirtied_ino - 1); if (req->mod_dent) dd_growth += c->bi.dent_budget; + if (req->dirtied_block_num) + dd_growth += c->bi.block_budget * req->dirtied_block_num; dd_growth += req->dirtied_ino_d; return dd_growth; } diff --git a/fs/ubifs/debug.c b/fs/ubifs/debug.c index 4c46a98..cafd592 100644 --- a/fs/ubifs/debug.c +++ b/fs/ubifs/debug.c @@ -556,6 +556,8 @@ void ubifs_dump_budget_req(const struct ubifs_budget_req *req) req->new_page, req->dirtied_page); pr_err("\tnew_dent %d, mod_dent %d\n", req->new_dent, req->mod_dent); + pr_err("\tnew_block %d, dirtied_block %d\n", + req->new_block_num, req->dirtied_block_num); pr_err("\tidx_growth %d\n", req->idx_growth); pr_err("\tdata_growth %d dd_growth %d\n", req->data_growth, req->dd_growth); diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c index c643261..eb04e42 100644 --- a/fs/ubifs/super.c +++ b/fs/ubifs/super.c @@ -698,6 +698,7 @@ static int init_constants_sb(struct ubifs_info *c) c->bi.page_budget = UBIFS_MAX_DATA_NODE_SZ * UBIFS_BLOCKS_PER_PAGE; c->bi.inode_budget = UBIFS_INO_NODE_SZ; c->bi.dent_budget = UBIFS_MAX_DENT_NODE_SZ; + c->bi.block_budget = UBIFS_MAX_DATA_NODE_SZ; /* * When the amount of flash space used by buds becomes diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h index 3b5e932..71b79b5 100644 --- a/fs/ubifs/ubifs.h +++ b/fs/ubifs/ubifs.h @@ -861,6 +861,8 @@ struct ubifs_compressor { * @new_ino_d: how much data newly created inode contains * @dirtied_ino: how many inodes the operation makes dirty * @dirtied_ino_d: how much data dirtied inode contains + * @new_block_num: how many new blocks + * @dirtied_block_num: how many dirtied blocks * @idx_growth: how much the index will supposedly grow * @data_growth: how much new data the operation will supposedly add * @dd_growth: how much data that makes other data dirty the operation will @@ -902,6 +904,8 @@ struct ubifs_budget_req { unsigned int dirtied_ino; unsigned int dirtied_ino_d; #endif + unsigned int new_block_num; + unsigned int dirtied_block_num; int idx_growth; int data_growth; int dd_growth; @@ -983,6 +987,7 @@ struct ubifs_budg_info { int page_budget; int inode_budget; int dent_budget; + int block_budget; }; struct ubifs_debug_info;