The commit is pushed to "branch-rh7-3.10.0-327.10.1.vz7.12.x-ovz" and will 
appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-327.10.1.vz7.12.2
------>
commit 44ea95b2855dcb9b8275430f075dbcd7cb87f0d1
Author: Maxim Patlasov <[email protected]>
Date:   Wed Mar 16 13:23:58 2016 +0400

    vfs: fix fallocate(FALLOC_FL_CONVERT_AND_EXTEND)
    
    Patchset description:
    
    The patch reworks the feature and renames it to FALLOC_FL_CONVERT_UNWRITTEN.
    
    Intended use:
    
    0) pos := i_size_read(inode); len := 1MB; prealloc := 100MB
    
    1) fallocate(file, 0, pos, prealloc)
    2) fiemap(inode, &fieinfo, pos, 1)
    3) dio pwrite(block_device, data, len, fi_extent.fe_physical)
    4) fallocate(file, FALLOC_FL_CONVERT_UNWRITTEN, pos, len)
    
    ===
    This patch description:
    
    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]>
    Acked-by: Dmitry Monakhov <[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

Reply via email to