From 218b8eafbdcb9bc19fc5a252fdd411fde11bca48 Mon Sep 17 00:00:00 2001 From: Prasad Joshi Date: Sat, 25 Jun 2011 15:06:37 +0100 Subject: Use truncate_setsize in zfs_setattr According to Linux kernel commit 2c27c65e, using truncate_setsize in setattr simplifies the code. Therefore, the patch replaces the call to vmtruncate() with truncate_setsize(). zfs_setattr uses zfs_freesp to free the disk space belonging to the file. As truncate_setsize may release the page cache and flushing the dirty data to disk, it must be called before the zfs_freesp. Suggested-by: Brian Behlendorf Signed-off-by: Prasad Joshi Closes #255 --- module/zfs/zfs_vnops.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'module') diff --git a/module/zfs/zfs_vnops.c b/module/zfs/zfs_vnops.c index 5b47cba7f..86bef25fb 100644 --- a/module/zfs/zfs_vnops.c +++ b/module/zfs/zfs_vnops.c @@ -72,6 +72,7 @@ #include #include #include +#include /* * Programming rules. @@ -2433,6 +2434,8 @@ top: if (err) goto out3; + truncate_setsize(ip, vap->va_size); + /* * XXX - Note, we are not providing any open * mode flags here (like FNDELAY), so we may @@ -2443,11 +2446,6 @@ top: err = zfs_freesp(zp, vap->va_size, 0, 0, FALSE); if (err) goto out3; - - /* Careful negative Linux return code here */ - err = -vmtruncate(ip, vap->va_size); - if (err) - goto out3; } if (mask & (ATTR_ATIME|ATTR_MTIME) || -- cgit v1.2.3