Skip to content

Commit fe341eb

Browse files
committed
xfs: ensure that fpunch, fcollapse, and finsert operations are aligned to rt extent size
Make sure that any fallocate operation that requires the range to be block-aligned also checks that the range is aligned to the realtime extent size. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Christoph Hellwig <hch@lst.de>
1 parent 2a6ca4b commit fe341eb

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

‎fs/xfs/xfs_bmap_util.c‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -946,6 +946,14 @@ xfs_free_file_space(
946946
startoffset_fsb = XFS_B_TO_FSB(mp, offset);
947947
endoffset_fsb = XFS_B_TO_FSBT(mp, offset + len);
948948

949+
/* We can only free complete realtime extents. */
950+
if (XFS_IS_REALTIME_INODE(ip)) {
951+
xfs_extlen_t extsz = xfs_get_extsz_hint(ip);
952+
953+
if ((startoffset_fsb | endoffset_fsb) & (extsz - 1))
954+
return -EINVAL;
955+
}
956+
949957
/*
950958
* Need to zero the stuff we're not freeing, on disk.
951959
*/
@@ -1139,6 +1147,14 @@ xfs_insert_file_space(
11391147

11401148
trace_xfs_insert_file_space(ip);
11411149

1150+
/* We can only insert complete realtime extents. */
1151+
if (XFS_IS_REALTIME_INODE(ip)) {
1152+
xfs_extlen_t extsz = xfs_get_extsz_hint(ip);
1153+
1154+
if ((stop_fsb | shift_fsb) & (extsz - 1))
1155+
return -EINVAL;
1156+
}
1157+
11421158
error = xfs_bmap_can_insert_extents(ip, stop_fsb, shift_fsb);
11431159
if (error)
11441160
return error;

0 commit comments

Comments
 (0)