xfs
[Top] [All Lists]

Re: [PATCH] xfs: fail ->bmap for reflink inodes

To: Christoph Hellwig <hch@xxxxxx>, darrick.wong@xxxxxxxxxx
Subject: Re: [PATCH] xfs: fail ->bmap for reflink inodes
From: Avi Kivity <avi@xxxxxxxxxxxx>
Date: Fri, 27 May 2016 20:32:18 +0300
Cc: linux-mm@xxxxxxxxx, xfs@xxxxxxxxxxx
Delivered-to: xfs@xxxxxxxxxxx
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=scylladb-com.20150623.gappssmtp.com; s=20150623; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=QuOeBlG1MmejtwE76NpKQGQcvqB4RxdnMouSiU0WeZA=; b=j99GRC6AZapsIqIUj4c1P9RhaL0G6scrpGY3+kAIKan8xRyGVpCA81kUxSivOHAmHu dP3CV+32DvMKLB246Swmn/La0kDfJ1zY938B0tlp8Ru6EVQrIKHSDKBdJ+goOfevsObe YdWee1eE4Y+NXeqeyLBD5Sr9sDObxW7gxiD9G/NzqE8vcal5As3ou2a6GJMGxZYK2RSI X92rWEqbEa0f/UWvuDimkUsONaWxeIbkgwWOREUHgaHBHWbObNXIgedgPtJmT1k1O1pS tJt1I9dZFjfgGADYmScXAMri5g+rzFgc7IqHQeIIOBfDb4LQQH/RWppmTpcOYM6NgoTd FQNQ==
In-reply-to: <1464267724-31423-2-git-send-email-hch@xxxxxx>
References: <1464267724-31423-1-git-send-email-hch@xxxxxx> <1464267724-31423-2-git-send-email-hch@xxxxxx>
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.1.0
On 05/26/2016 04:02 PM, Christoph Hellwig wrote:
Signed-off-by: Christoph Hellwig <hch@xxxxxx>
---
  fs/xfs/xfs_aops.c | 11 +++++++++++
  1 file changed, 11 insertions(+)

diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c
index a955552..d053a9e 100644
--- a/fs/xfs/xfs_aops.c
+++ b/fs/xfs/xfs_aops.c
@@ -1829,6 +1829,17 @@ xfs_vm_bmap(
trace_xfs_vm_bmap(XFS_I(inode));
        xfs_ilock(ip, XFS_IOLOCK_SHARED);
+
+       /*
+        * 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 reflinks inodes, so we have to skip out here.  And yes,
+        * 0 is the magic code for a bmap error..
+        */
+       if (xfs_is_reflink_inode(ip)) {
+               xfs_iunlock(ip, XFS_IOLOCK_SHARED);
+               return 0;
+       }
        filemap_write_and_wait(mapping);
        xfs_iunlock(ip, XFS_IOLOCK_SHARED);
        return generic_block_bmap(mapping, block, xfs_get_blocks);

Don't you also have to prevent a swapfile from being reflinked after it's bmapped? Or is that already taken care of?

<Prev in Thread] Current Thread [Next in Thread>