summaryrefslogtreecommitdiffstats
path: root/fs/ocfs2
diff options
context:
space:
mode:
authorDarrick J. Wong <darrick.wong@oracle.com>2016-11-09 14:13:10 -0800
committerDarrick J. Wong <darrick.wong@oracle.com>2016-12-10 12:39:45 -0800
commit06a70305812c3973c66824f26223656283c59b27 (patch)
treebdab69960e2153f131fe138992e525e5abf6360c /fs/ocfs2
parent86544fbd853c49a9eccb3d0f4e7eb9317f3fccf9 (diff)
downloadop-kernel-dev-06a70305812c3973c66824f26223656283c59b27.zip
op-kernel-dev-06a70305812c3973c66824f26223656283c59b27.tar.gz
ocfs2: prohibit refcounted swapfiles
The swapfile mechanism calls bmap once to find all the swap file mappings, which means that we cannot properly support CoW remapping. Therefore, error out if the swap code tries to call bmap on a refcounted file. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Diffstat (limited to 'fs/ocfs2')
-rw-r--r--fs/ocfs2/aops.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c
index c5c5b97..4d037db 100644
--- a/fs/ocfs2/aops.c
+++ b/fs/ocfs2/aops.c
@@ -464,6 +464,15 @@ static sector_t ocfs2_bmap(struct address_space *mapping, sector_t block)
trace_ocfs2_bmap((unsigned long long)OCFS2_I(inode)->ip_blkno,
(unsigned long long)block);
+ /*
+ * The swap code (ab-)uses ->bmap to get a block mapping and then
+ * bypasseѕ the file system for actual I/O. We really can't allow
+ * that on refcounted inodes, so we have to skip out here. And yes,
+ * 0 is the magic code for a bmap error..
+ */
+ if (ocfs2_is_refcount_inode(inode))
+ return 0;
+
/* We don't need to lock journal system files, since they aren't
* accessed concurrently from multiple nodes.
*/
OpenPOWER on IntegriCloud