summaryrefslogtreecommitdiffstats
path: root/fs/inode.c
diff options
context:
space:
mode:
authorDarrick J. Wong <darrick.wong@oracle.com>2019-07-01 11:25:36 -0400
committerDarrick J. Wong <darrick.wong@oracle.com>2019-07-01 11:25:36 -0400
commitca29be753445450799958e7d2e5d797d1153389e (patch)
treebc4450ee81982ec4429ff7d4bbeaa799789e9f79 /fs/inode.c
parentf991492ed11055934f1b35615cb1b435325939bf (diff)
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.c18
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,
2227 return -EINVAL; 2227 return -EINVAL;
2228 } 2228 }
2229 2229
2230 /* Check extent size hints. */
2231 if ((fa->fsx_xflags & FS_XFLAG_EXTSIZE) && !S_ISREG(inode->i_mode))
2232 return -EINVAL;
2233
2234 if ((fa->fsx_xflags & FS_XFLAG_EXTSZINHERIT) &&
2235 !S_ISDIR(inode->i_mode))
2236 return -EINVAL;
2237
2238 if ((fa->fsx_xflags & FS_XFLAG_COWEXTSIZE) &&
2239 !S_ISREG(inode->i_mode) && !S_ISDIR(inode->i_mode))
2240 return -EINVAL;
2241
2242 /* Extent size hints of zero turn off the flags. */
2243 if (fa->fsx_extsize == 0)
2244 fa->fsx_xflags &= ~(FS_XFLAG_EXTSIZE | FS_XFLAG_EXTSZINHERIT);
2245 if (fa->fsx_cowextsize == 0)
2246 fa->fsx_xflags &= ~FS_XFLAG_COWEXTSIZE;
2247
2230 return 0; 2248 return 0;
2231} 2249}
2232EXPORT_SYMBOL(vfs_ioc_fssetxattr_check); 2250EXPORT_SYMBOL(vfs_ioc_fssetxattr_check);