Skip to contentSkip to conversation

iomap: don't override sis->bdev in xfs_iomap_swapfile_activate

PATCH In review Christoph Hellwig 2 participants 3 messages Mar 1, 2020 – Mar 4, 2020 XFS filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iomap: don't override sis->bdev in xfs_iomap_swapfile_activate

The swapon code itself sets sis->bdev up early, and performs various check on the block devices. Changing it later in the fact thus will cause a mismatch of capabilities and must be avoided. The practical implication of this change is that it forbids swapping to the RT subvolume, which might have had all kinds of issues anyway.

---
 fs/xfs/xfs_aops.c | 1 -
 1 file changed, 1 deletion(-)
fs/xfs/xfs_aops.c +0 -1
index 58e937be24ce..f9929a952ef1 100644
@@ -637,7 +637,6 @@ xfs_iomap_swapfile_activate(
 	struct file			*swap_file,
 	sector_t			*span)
 {
-	sis->bdev = xfs_inode_buftarg(XFS_I(file_inode(swap_file)))->bt_bdev;
 	return iomap_swapfile_activate(sis, swap_file, span,
 			&xfs_read_iomap_ops);
 }
Signature · 1 line
2.24.1
#1 lore raw
Quoted 3 lines · Christoph Hellwig

The swapon code itself sets sis->bdev up early, and performs various check on the block devices. Changing it later in the fact thus will cause a mismatch of capabilities and must be avoided.

What kind of mismatch? Are you talking about the bdi_cap_* and blk_queue_nonrot() logic in swapon()? I wonder how much of that could be moved to after the ->swapfile_activate call.

Quoted 3 lines

The practical implication
of this change is that it forbids swapping to the RT subvolume, which might have had all kinds of issues anyway.

<shrug> I didn't find any the one time I tried it on a pair of homogeneous devices. :)

Quoted 10 lines
---
 fs/xfs/xfs_aops.c | 1 -
 1 file changed, 1 deletion(-)
fs/xfs/xfs_aops.c +0 -0
index 58e937be24ce..f9929a952ef1 100644

fs/xfs/xfs_aops.c xfs_iomap_swapfile_activate( · line 640

Quoted 4 lines
fs/xfs/xfs_aops.c +0 -1
@@ -637,7 +637,6 @@ xfs_iomap_swapfile_activate(
 	struct file			*swap_file,
 	sector_t			*span)
 {
-	sis->bdev = xfs_inode_buftarg(XFS_I(file_inode(swap_file)))->bt_bdev;

That said, btrfs copypasta'd this when they ported to iomap swapfile, so that needs fixing too.

--D

Quoted 6 lines
fs/xfs/xfs_aops.c +0 -0
 	return iomap_swapfile_activate(sis, swap_file, span,
 			&xfs_read_iomap_ops);
 }
Signature · 1 line
2.24.1
#2 lore raw
Quoted 8 lines · Darrick J. Wong
Quoted 3 lines · Christoph Hellwig

The swapon code itself sets sis->bdev up early, and performs various check on the block devices. Changing it later in the fact thus will cause a mismatch of capabilities and must be avoided.

What kind of mismatch? Are you talking about the bdi_cap_* and blk_queue_nonrot() logic in swapon()? I wonder how much of that could be moved to after the ->swapfile_activate call.

The thing I ran into is the zone check with my zoned XFS prototype code. But when you look at the nonrot checks that will cause resource leaks due to the override, and thus is the main is the main issue for now.

I suspect much of this could be cleaned up one way or another, but the layering of this code is horrible, so it would be a bigger job.

btrfs hasn't picked up the iomap changes yet, but the next resend should drop the bdev assignment as well.