From patchwork Tue Jul 21 08:37:40 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Dongsheng X-Patchwork-Id: 6833451 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 889ECC05AC for ; Tue, 21 Jul 2015 08:47:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 91D12204AB for ; Tue, 21 Jul 2015 08:47:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8F87C203A9 for ; Tue, 21 Jul 2015 08:47:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753934AbbGUIr2 (ORCPT ); Tue, 21 Jul 2015 04:47:28 -0400 Received: from cn.fujitsu.com ([59.151.112.132]:57008 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1752746AbbGUInm (ORCPT ); Tue, 21 Jul 2015 04:43:42 -0400 X-IronPort-AV: E=Sophos;i="5.13,665,1427731200"; d="scan'208";a="98671202" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 21 Jul 2015 16:47:18 +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 t6L8fmfa005015; Tue, 21 Jul 2015 16:41:48 +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; Tue, 21 Jul 2015 16:43:35 +0800 From: Dongsheng Yang To: , , CC: , , Dongsheng Yang Subject: [PATCH 09/25] ubifs: extend budget for blocks Date: Tue, 21 Jul 2015 16:37:40 +0800 Message-ID: <1437467876-22106-10-git-send-email-yangds.fnst@cn.fujitsu.com> X-Mailer: git-send-email 1.8.4.2 In-Reply-To: <1437467876-22106-1-git-send-email-yangds.fnst@cn.fujitsu.com> References: <1437467876-22106-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.1 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 3e4a01b..27e1739 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 6ef2415..ae6723e 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;