From patchwork Thu Jul 30 05:48:15 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Dongsheng X-Patchwork-Id: 6898421 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 4B77CC05AC for ; Thu, 30 Jul 2015 05:54:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7342020546 for ; Thu, 30 Jul 2015 05:54:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1495F20555 for ; Thu, 30 Jul 2015 05:54:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753595AbbG3Fya (ORCPT ); Thu, 30 Jul 2015 01:54:30 -0400 Received: from cn.fujitsu.com ([59.151.112.132]:59439 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1752206AbbG3Fy3 (ORCPT ); Thu, 30 Jul 2015 01:54:29 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="99064498" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 30 Jul 2015 13:58:02 +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 t6U5qam3028317; Thu, 30 Jul 2015 13:52:36 +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:28 +0800 From: Dongsheng Yang To: , , , CC: , , Dongsheng Yang Subject: [PATCH v2 19/35] ubifs: budget for inode in ubifs_dirty_inode if necessary Date: Thu, 30 Jul 2015 13:48:15 +0800 Message-ID: <1438235311-23788-20-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 In ubifs, we have to do a budget for inode before marking it as dirty. But sometimes, we would call dirty_inode in vfs which will not do a budget for inode. In this case, we have to do a budget in ubifs_dirty_inode() by ourselvies. Signed-off-by: Dongsheng Yang --- fs/ubifs/super.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c index 2491fff..bc57685 100644 --- a/fs/ubifs/super.c +++ b/fs/ubifs/super.c @@ -383,15 +383,38 @@ done: clear_inode(inode); } +/* + * In theory, ubifs should take the full control of dirty<->clean + * of an inode with ui->ui_mutex. But there are callers of + * ubifs_dirty_inode in vfs without holding ui->ui_mutex and + * budgeting. So when we found the ui_mutex is not locked, we have + * to lock ui->ui_mutex by itself and do a budget by itself. + */ static void ubifs_dirty_inode(struct inode *inode, int flags) { struct ubifs_inode *ui = ubifs_inode(inode); + int locked = mutex_is_locked(&ui->ui_mutex); + struct ubifs_info *c = inode->i_sb->s_fs_info; + int ret = 0; + + if (!locked) + mutex_lock(&ui->ui_mutex); - ubifs_assert(mutex_is_locked(&ui->ui_mutex)); if (!ui->dirty) { + if (!locked) { + struct ubifs_budget_req req = { .dirtied_ino = 1, + .dirtied_ino_d = ALIGN(ui->data_len, 8) }; + ret = ubifs_budget_space(c, &req); + if (ret) + goto out; + } ui->dirty = 1; dbg_gen("inode %lu", inode->i_ino); } +out: + if (!locked) + mutex_unlock(&ui->ui_mutex); + return; } static int ubifs_statfs(struct dentry *dentry, struct kstatfs *buf)