diff mbox

[v3,31/39] ubifs: free quota space in do_truncation

Message ID 1442307754-13233-32-git-send-email-yangds.fnst@cn.fujitsu.com
State Deferred, archived
Delegated to: Richard Weinberger
Headers show

Commit Message

Dongsheng Yang Sept. 15, 2015, 9:02 a.m. UTC
In truncation, we have to tell quota subsystem
to update the quota information of the space changing.

Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
---
 fs/ubifs/file.c | 5 +++++
 1 file changed, 5 insertions(+)
diff mbox

Patch

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)