From patchwork Tue Sep 15 09:02:26 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Dongsheng X-Patchwork-Id: 7181541 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 4049BBF036 for ; Tue, 15 Sep 2015 09:09:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 728AC20741 for ; Tue, 15 Sep 2015 09:09:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 902872053E for ; Tue, 15 Sep 2015 09:09:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754349AbbIOJJh (ORCPT ); Tue, 15 Sep 2015 05:09:37 -0400 Received: from cn.fujitsu.com ([59.151.112.132]:7632 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1754306AbbIOJJc (ORCPT ); Tue, 15 Sep 2015 05:09:32 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100730400" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 15 Sep 2015 17:12:21 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t8F99EY1008099; Tue, 15 Sep 2015 17:09:14 +0800 Received: from yds-PC.g08.fujitsu.local (10.167.226.66) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Tue, 15 Sep 2015 17:09:29 +0800 From: Dongsheng Yang To: , , , CC: , , Dongsheng Yang Subject: [PATCH v3 31/39] ubifs: free quota space in do_truncation Date: Tue, 15 Sep 2015 17:02:26 +0800 Message-ID: <1442307754-13233-32-git-send-email-yangds.fnst@cn.fujitsu.com> X-Mailer: git-send-email 1.8.4.2 In-Reply-To: <1442307754-13233-1-git-send-email-yangds.fnst@cn.fujitsu.com> References: <1442307754-13233-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=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_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, we have to tell quota subsystem to update the quota information of the space changing. Signed-off-by: Dongsheng Yang --- fs/ubifs/file.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c index 64ca91c..59b2098 100644 --- a/fs/ubifs/file.c +++ b/fs/ubifs/file.c @@ -1136,6 +1136,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); @@ -1215,6 +1216,10 @@ 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; + if (S_ISREG(inode->i_mode)) + dquot_free_space_nodirty(inode, quota_size); out_budg: if (budgeted)