Skip to content

Commit 61d819e

Browse files
committed
xfs: don't allow bmap on rt files
bmap returns a dumb LBA address but not the block device that goes with that LBA. Swapfiles don't care about this and will blindly assume that the data volume is the correct blockdev, which is totally bogus for files on the rt subvolume. This results in the swap code doing IOs to arbitrary locations on the data device(!) if the passed in mapping is a realtime file, so just turn off bmap for rt files. Signed-off-by: Darrick J. Wong <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]>
1 parent 5da8f2f commit 61d819e

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

fs/xfs/xfs_aops.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1316,9 +1316,12 @@ xfs_vm_bmap(
13161316
* The swap code (ab-)uses ->bmap to get a block mapping and then
13171317
* bypasseѕ the file system for actual I/O. We really can't allow
13181318
* that on reflinks inodes, so we have to skip out here. And yes,
1319-
* 0 is the magic code for a bmap error..
1319+
* 0 is the magic code for a bmap error.
1320+
*
1321+
* Since we don't pass back blockdev info, we can't return bmap
1322+
* information for rt files either.
13201323
*/
1321-
if (xfs_is_reflink_inode(ip))
1324+
if (xfs_is_reflink_inode(ip) || XFS_IS_REALTIME_INODE(ip))
13221325
return 0;
13231326

13241327
filemap_write_and_wait(mapping);

0 commit comments

Comments
 (0)