Skip to contentSkip to conversation

jfs: drop vmtruncate

PATCH In review Marco Stornelli 1 participant 1 message Oct 6, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 12/22 jfs: drop vmtruncate

Removed vmtruncate.

---
 fs/jfs/file.c  |    6 ++++--
 fs/jfs/inode.c |   13 +++++++++----
 2 files changed, 13 insertions(+), 6 deletions(-)
fs/jfs/file.c +4 -2
index 9d3afd1..dd7442c 100644
@@ -119,9 +119,12 @@ int jfs_setattr(struct dentry *dentry, struct iattr *iattr)
 	    iattr->ia_size != i_size_read(inode)) {
 		inode_dio_wait(inode);
 
-		rc = vmtruncate(inode, iattr->ia_size);
+		rc = inode_newsize_ok(inode, iattr->ia_size);
 		if (rc)
 			return rc;
+
+		truncate_setsize(inode, iattr->ia_size);
+		jfs_truncate(inode);
 	}
 
 	setattr_copy(inode, iattr);
@@ -133,7 +136,6 @@ int jfs_setattr(struct dentry *dentry, struct iattr *iattr)
 }
 
 const struct inode_operations jfs_file_inode_operations = {
-	.truncate	= jfs_truncate,
 	.setxattr	= jfs_setxattr,
 	.getxattr	= jfs_getxattr,
 	.listxattr	= jfs_listxattr,
fs/jfs/inode.c +9 -4
index 4692bf3..895be2e 100644
@@ -310,8 +310,11 @@ static int jfs_write_begin(struct file *file, struct address_space *mapping,
 				jfs_get_block);
 	if (unlikely(ret)) {
 		loff_t isize = mapping->host->i_size;
-		if (pos + len > isize)
-			vmtruncate(mapping->host, isize);
+		if ((pos + len > isize) &&
+			inode_newsize_ok(mapping->host, isize) == 0) {
+			truncate_setsize(mapping->host, isize);
+			jfs_truncate(mapping->host);
+		}
 	}
 
 	return ret;
@@ -340,8 +343,10 @@ static ssize_t jfs_direct_IO(int rw, struct kiocb *iocb,
 		loff_t isize = i_size_read(inode);
 		loff_t end = offset + iov_length(iov, nr_segs);
 
-		if (end > isize)
-			vmtruncate(inode, isize);
+		if ((end > isize) && inode_newsize_ok(inode, isize) == 0) {
+			truncate_setsize(inode, isize);
+			jfs_truncate(inode);
+		}
 	}
 
 	return ret;
Signature · 1 line
1.7.3.4