All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH, RFC] xfs: re-enable FIBMAP on reflink; disable for swap
@ 2018-08-30 16:10 Eric Sandeen
  2018-08-30 16:25 ` Christoph Hellwig
  0 siblings, 1 reply; 22+ messages in thread
From: Eric Sandeen @ 2018-08-30 16:10 UTC (permalink / raw)
  To: linux-xfs; +Cc: Christoph Hellwig

We disabled FIBMAP/bmap calls for reflinked files because swap will then
writes directly to the blocks, bypassing COW mechanisms, and breaking
copy on write.  As noted in commit db1327b, this restriction also breaks
bootloaders that want to use the FIBMAP ioctl.

Rather than disabling the entire mapping interface for everyone just
because swapon may abuse the info, teach xfs_iomap_swapfile_activate()
to reject activation for reflinked files, and re-enable the FIBMAP
interface.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---

yes, other FIBMAP users could also abuse this information, but
disallowing mapping because somebody might do something dumb with
it seems very heavy handed... thoughts? 

diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c
index 8eb3ba3d4d00..b75a7f37bdd9 100644
--- a/fs/xfs/xfs_aops.c
+++ b/fs/xfs/xfs_aops.c
@@ -1382,15 +1382,10 @@ xfs_vm_bmap(
 	trace_xfs_vm_bmap(ip);
 
 	/*
-	 * The swap code (ab-)uses ->bmap to get a block mapping and then
-	 * bypasses the file system for actual I/O.  We really can't allow
-	 * that on reflinks inodes, so we have to skip out here.  And yes,
-	 * 0 is the magic code for a bmap error.
-	 *
 	 * Since we don't pass back blockdev info, we can't return bmap
-	 * information for rt files either.
+	 * information for rt files.
 	 */
-	if (xfs_is_reflink_inode(ip) || XFS_IS_REALTIME_INODE(ip))
+	if (XFS_IS_REALTIME_INODE(ip))
 		return 0;
 	return iomap_bmap(mapping, block, &xfs_iomap_ops);
 }
@@ -1477,7 +1472,13 @@ xfs_iomap_swapfile_activate(
 	struct file			*swap_file,
 	sector_t			*span)
 {
-	sis->bdev = xfs_find_bdev_for_inode(file_inode(swap_file));
+	struct inode			*inode = file_inode(swap_file);
+
+	/* Cannot allow swap to write directly to reflinked files/blocks */
+	if (xfs_is_reflink_inode(XFS_I(inode)))
+		return -EOPNOTSUPP;
+
+	sis->bdev = xfs_find_bdev_for_inode(inode);
 	return iomap_swapfile_activate(sis, swap_file, span, &xfs_iomap_ops);
 }
 

^ permalink raw reply related	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2018-09-03 14:41 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-30 16:10 [PATCH, RFC] xfs: re-enable FIBMAP on reflink; disable for swap Eric Sandeen
2018-08-30 16:25 ` Christoph Hellwig
2018-08-30 16:31   ` Eric Sandeen
2018-08-30 16:36     ` Christoph Hellwig
2018-08-30 16:35       ` Eric Sandeen
2018-08-30 18:02         ` Brian Foster
2018-08-30 18:28           ` Darrick J. Wong
2018-08-30 18:51             ` Eric Sandeen
2018-08-30 19:39               ` Brian Foster
2018-08-30 19:47                 ` Eric Sandeen
2018-08-30 19:58                   ` Brian Foster
2018-08-31  0:11               ` Dave Chinner
2018-08-31  1:34                 ` Eric Sandeen
2018-08-31  3:05                   ` Dave Chinner
2018-08-31 13:08                     ` Eric Sandeen
2018-09-01  8:32                       ` Christoph Hellwig
2018-08-31  6:28             ` Christoph Hellwig
2018-08-31 12:36               ` Brian Foster
2018-09-01  8:31                 ` Christoph Hellwig
2018-09-02 14:08                 ` Carlos Maiolino
2018-09-02 17:52                   ` Eric Sandeen
2018-09-03 10:21                     ` Carlos Maiolino

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.