From patchwork Tue Jul 21 08:37:52 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Dongsheng X-Patchwork-Id: 6833331 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 3A09BC05AC for ; Tue, 21 Jul 2015 08:44:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5D5C920678 for ; Tue, 21 Jul 2015 08:44:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 79AAD20693 for ; Tue, 21 Jul 2015 08:44:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753663AbbGUIoD (ORCPT ); Tue, 21 Jul 2015 04:44:03 -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 S1754182AbbGUIny (ORCPT ); Tue, 21 Jul 2015 04:43:54 -0400 X-IronPort-AV: E=Sophos;i="5.13,665,1427731200"; d="scan'208";a="98671226" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 21 Jul 2015 16:47:31 +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 t6L8g04V005063; Tue, 21 Jul 2015 16:42:00 +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:48 +0800 From: Dongsheng Yang To: , , CC: , , Dongsheng Yang Subject: [PATCH 21/25] ubifs: free quota space in do_truncation and unlink Date: Tue, 21 Jul 2015 16:37:52 +0800 Message-ID: <1437467876-22106-22-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 In truncation and unlink, we have to tell quota subsystem to update the quota information of the space changing. Signed-off-by: Dongsheng Yang --- fs/ubifs/dir.c | 4 ++++ fs/ubifs/file.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c index 01cbc8b..b83ebb6 100644 --- a/fs/ubifs/dir.c +++ b/fs/ubifs/dir.c @@ -574,6 +574,7 @@ static int ubifs_unlink(struct inode *dir, struct dentry *dentry) int err, budgeted = 1; struct ubifs_budget_req req = { .mod_dent = 1, .dirtied_ino = 2 }; unsigned int saved_nlink = inode->i_nlink; + loff_t quota_size = inode->i_size; /* * Budget request settings: deletion direntry, deletion inode (+1 for @@ -607,8 +608,11 @@ static int ubifs_unlink(struct inode *dir, struct dentry *dentry) err = ubifs_jnl_update(c, dir, &dentry->d_name, inode, 1, 0); if (err) goto out_cancel; + unlock_2_inodes(dir, inode); + dquot_free_space_nodirty(inode, quota_size); + if (budgeted) ubifs_release_budget(c, &req); else { diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c index 0c03a88..b907f197 100644 --- a/fs/ubifs/file.c +++ b/fs/ubifs/file.c @@ -1130,6 +1130,7 @@ static int do_truncation(struct ubifs_info *c, struct inode *inode, int err; struct ubifs_budget_req req; loff_t old_size = inode->i_size, new_size = attr->ia_size; + loff_t quota_size = (old_size - new_size); int offset = new_size & (UBIFS_BLOCK_SIZE - 1), budgeted = 1; struct ubifs_inode *ui = ubifs_inode(inode); @@ -1209,6 +1210,9 @@ static int do_truncation(struct ubifs_info *c, struct inode *inode, do_attr_changes(inode, attr); err = ubifs_jnl_truncate(c, inode, old_size, new_size); mutex_unlock(&ui->ui_mutex); + if (quota_size < 0) + quota_size = 0; + dquot_free_space_nodirty(inode, quota_size); out_budg: if (budgeted)