Modern vfs_fallocate() checks flags for sanity. To avoid EOPNOTSUPP error, we have to list FALLOC_FL_CONVERT_AND_EXTEND among other valid flags. Also, to keep checks uniform, the patch also enforces exclusiveness of the flag.
https://jira.sw.ru/browse/PSBM-22381 Signed-off-by: Maxim Patlasov <[email protected]> --- fs/open.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/fs/open.c b/fs/open.c index 75b9d8e..22b9699 100644 --- a/fs/open.c +++ b/fs/open.c @@ -232,7 +232,8 @@ int vfs_fallocate(struct file *file, int mode, loff_t offset, loff_t len) /* Return error if mode is not supported */ if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE | - FALLOC_FL_COLLAPSE_RANGE | FALLOC_FL_ZERO_RANGE)) + FALLOC_FL_COLLAPSE_RANGE | FALLOC_FL_ZERO_RANGE | + FALLOC_FL_CONVERT_AND_EXTEND)) return -EOPNOTSUPP; /* Punch hole and zero range are mutually exclusive */ @@ -250,6 +251,11 @@ int vfs_fallocate(struct file *file, int mode, loff_t offset, loff_t len) (mode & ~FALLOC_FL_COLLAPSE_RANGE)) return -EINVAL; + /* Convert-and-extend should only be used exclusively. */ + if ((mode & FALLOC_FL_CONVERT_AND_EXTEND) && + (mode & ~FALLOC_FL_CONVERT_AND_EXTEND)) + return -EINVAL; + if (!(file->f_mode & FMODE_WRITE)) return -EBADF; _______________________________________________ Devel mailing list [email protected] https://lists.openvz.org/mailman/listinfo/devel
