mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-21 14:11:20 +00:00
vfs: add a FALLOC_FL_UNSHARE mode to fallocate to unshare a range of blocks
Add a new fallocate mode flag that explicitly unshares blocks on filesystems that support such features. The new flag can only be used with an allocate-mode fallocate call. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
This commit is contained in:
parent
0a6eab8bd4
commit
71be6b4942
3 changed files with 25 additions and 1 deletions
|
@ -256,6 +256,11 @@ int vfs_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
|
||||||
(mode & ~FALLOC_FL_INSERT_RANGE))
|
(mode & ~FALLOC_FL_INSERT_RANGE))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
|
/* Unshare range should only be used with allocate mode. */
|
||||||
|
if ((mode & FALLOC_FL_UNSHARE_RANGE) &&
|
||||||
|
(mode & ~(FALLOC_FL_UNSHARE_RANGE | FALLOC_FL_KEEP_SIZE)))
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
if (!(file->f_mode & FMODE_WRITE))
|
if (!(file->f_mode & FMODE_WRITE))
|
||||||
return -EBADF;
|
return -EBADF;
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@ struct space_resv {
|
||||||
FALLOC_FL_PUNCH_HOLE | \
|
FALLOC_FL_PUNCH_HOLE | \
|
||||||
FALLOC_FL_COLLAPSE_RANGE | \
|
FALLOC_FL_COLLAPSE_RANGE | \
|
||||||
FALLOC_FL_ZERO_RANGE | \
|
FALLOC_FL_ZERO_RANGE | \
|
||||||
FALLOC_FL_INSERT_RANGE)
|
FALLOC_FL_INSERT_RANGE | \
|
||||||
|
FALLOC_FL_UNSHARE_RANGE)
|
||||||
|
|
||||||
#endif /* _FALLOC_H_ */
|
#endif /* _FALLOC_H_ */
|
||||||
|
|
|
@ -58,4 +58,22 @@
|
||||||
*/
|
*/
|
||||||
#define FALLOC_FL_INSERT_RANGE 0x20
|
#define FALLOC_FL_INSERT_RANGE 0x20
|
||||||
|
|
||||||
|
/*
|
||||||
|
* FALLOC_FL_UNSHARE_RANGE is used to unshare shared blocks within the
|
||||||
|
* file size without overwriting any existing data. The purpose of this
|
||||||
|
* call is to preemptively reallocate any blocks that are subject to
|
||||||
|
* copy-on-write.
|
||||||
|
*
|
||||||
|
* Different filesystems may implement different limitations on the
|
||||||
|
* granularity of the operation. Most will limit operations to filesystem
|
||||||
|
* block size boundaries, but this boundary may be larger or smaller
|
||||||
|
* depending on the filesystem and/or the configuration of the filesystem
|
||||||
|
* or file.
|
||||||
|
*
|
||||||
|
* This flag can only be used with allocate-mode fallocate, which is
|
||||||
|
* to say that it cannot be used with the punch, zero, collapse, or
|
||||||
|
* insert range modes.
|
||||||
|
*/
|
||||||
|
#define FALLOC_FL_UNSHARE_RANGE 0x40
|
||||||
|
|
||||||
#endif /* _UAPI_FALLOC_H_ */
|
#endif /* _UAPI_FALLOC_H_ */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue