]> git.karo-electronics.de Git - linux-beck.git/commitdiff
ocfs2: prohibit refcounted swapfiles
authorDarrick J. Wong <darrick.wong@oracle.com>
Wed, 9 Nov 2016 22:13:10 +0000 (14:13 -0800)
committerDarrick J. Wong <darrick.wong@oracle.com>
Sat, 10 Dec 2016 20:39:45 +0000 (12:39 -0800)
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>
fs/ocfs2/aops.c

index c5c5b9748ea3b886d03bdcef6830f39d1b9ca14f..4d037db84be5afe76b58709ea516dbeb251eb44c 100644 (file)
@@ -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.
         */