mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-12-26 19:19:32 +03:00
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 <behlendorf1@llnl.gov> Signed-off-by: Prasad Joshi <pjoshi@stec-inc.com> Closes #255
This commit is contained in:
parent
b312979252
commit
218b8eafbd
@ -72,6 +72,7 @@
|
|||||||
#include <sys/kidmap.h>
|
#include <sys/kidmap.h>
|
||||||
#include <sys/cred.h>
|
#include <sys/cred.h>
|
||||||
#include <sys/attr.h>
|
#include <sys/attr.h>
|
||||||
|
#include <sys/zpl.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Programming rules.
|
* Programming rules.
|
||||||
@ -2433,6 +2434,8 @@ top:
|
|||||||
if (err)
|
if (err)
|
||||||
goto out3;
|
goto out3;
|
||||||
|
|
||||||
|
truncate_setsize(ip, vap->va_size);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* XXX - Note, we are not providing any open
|
* XXX - Note, we are not providing any open
|
||||||
* mode flags here (like FNDELAY), so we may
|
* mode flags here (like FNDELAY), so we may
|
||||||
@ -2443,11 +2446,6 @@ top:
|
|||||||
err = zfs_freesp(zp, vap->va_size, 0, 0, FALSE);
|
err = zfs_freesp(zp, vap->va_size, 0, 0, FALSE);
|
||||||
if (err)
|
if (err)
|
||||||
goto out3;
|
goto out3;
|
||||||
|
|
||||||
/* Careful negative Linux return code here */
|
|
||||||
err = -vmtruncate(ip, vap->va_size);
|
|
||||||
if (err)
|
|
||||||
goto out3;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mask & (ATTR_ATIME|ATTR_MTIME) ||
|
if (mask & (ATTR_ATIME|ATTR_MTIME) ||
|
||||||
|
Loading…
Reference in New Issue
Block a user