fs: move fiemap range validation into the file systems instances

Replace fiemap_check_flags with a fiemap_prep helper that also takes the
inode and mapped range, and performs the sanity check and truncation
previously done in fiemap_check_range.  This way the validation is inside
the file system itself and thus properly works for the stacked overlayfs
case as well.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Link: https://lore.kernel.org/r/20200523073016.2944131-7-hch@lst.de
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
This commit is contained in:
Christoph Hellwig
2020-05-23 09:30:13 +02:00
committed by Theodore Ts'o
parent 2732881894
commit cddf8a2c4a
10 changed files with 47 additions and 54 deletions

View File

@@ -4938,8 +4938,9 @@ int ext4_get_es_cache(struct inode *inode, struct fiemap_extent_info *fieinfo,
fieinfo->fi_flags &= ~FIEMAP_FLAG_CACHE;
}
if (fiemap_check_flags(fieinfo, FIEMAP_FLAG_SYNC))
return -EBADR;
error = fiemap_prep(inode, fieinfo, start, &len, FIEMAP_FLAG_SYNC);
if (error)
return error;
error = ext4_fiemap_check_ranges(inode, start, &len);
if (error)