diff options
author | Darrick J. Wong <darrick.wong@oracle.com> | 2019-07-01 17:25:36 +0200 |
---|---|---|
committer | Darrick J. Wong <darrick.wong@oracle.com> | 2019-07-01 17:25:36 +0200 |
commit | ca29be753445450799958e7d2e5d797d1153389e (patch) | |
tree | bc4450ee81982ec4429ff7d4bbeaa799789e9f79 /fs/inode.c | |
parent | vfs: teach vfs_ioc_fssetxattr_check to check project id info (diff) | |
download | linux-ca29be753445450799958e7d2e5d797d1153389e.tar.xz linux-ca29be753445450799958e7d2e5d797d1153389e.zip |
vfs: teach vfs_ioc_fssetxattr_check to check extent size hints
Move the extent size hint checks that aren't xfs-specific to the vfs.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'fs/inode.c')
-rw-r--r-- | fs/inode.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/fs/inode.c b/fs/inode.c index 30b720cffd9c..0cbce5a0a23c 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -2227,6 +2227,24 @@ int vfs_ioc_fssetxattr_check(struct inode *inode, const struct fsxattr *old_fa, return -EINVAL; } + /* Check extent size hints. */ + if ((fa->fsx_xflags & FS_XFLAG_EXTSIZE) && !S_ISREG(inode->i_mode)) + return -EINVAL; + + if ((fa->fsx_xflags & FS_XFLAG_EXTSZINHERIT) && + !S_ISDIR(inode->i_mode)) + return -EINVAL; + + if ((fa->fsx_xflags & FS_XFLAG_COWEXTSIZE) && + !S_ISREG(inode->i_mode) && !S_ISDIR(inode->i_mode)) + return -EINVAL; + + /* Extent size hints of zero turn off the flags. */ + if (fa->fsx_extsize == 0) + fa->fsx_xflags &= ~(FS_XFLAG_EXTSIZE | FS_XFLAG_EXTSZINHERIT); + if (fa->fsx_cowextsize == 0) + fa->fsx_xflags &= ~FS_XFLAG_COWEXTSIZE; + return 0; } EXPORT_SYMBOL(vfs_ioc_fssetxattr_check); |