Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp821285pxb; Thu, 25 Feb 2021 16:33:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJyXA9V738z0r42E5LIgVd56Y1p6TTQzM4HiUoSP/oKZJ3Ggd4qtwjtm/Zg7RCNMFUbAdVEP X-Received: by 2002:a17:906:df51:: with SMTP id if17mr322745ejc.370.1614299583106; Thu, 25 Feb 2021 16:33:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614299583; cv=none; d=google.com; s=arc-20160816; b=qDxzwZ4bEbclDSMim5BP4adflat23xVOCMnt94h1ucTkHgArEQ4ADpq+MzwcYtVvqD iXeaKb6ncSfusdLRkwer2+FU2qE382m/pQAo2uWxMIAD6os9qMWXSeqZxEPiBDZ/6hmh Bzs76OY24HKfMrDO8/n6+xTlR4XTjFPh9sbqWDBc1FJG8oOIV7QmrpwQnWhScHEgKBx8 FxWyQu/xA7dZVzmkgiSuQciGOsAcwri0BU4FD9AgdRDzvnPZ/ZQGHWiMW/XKfvbvFEh+ 7M1d7wGkuuuR/kA5helJI60mWivBOCDs/+s0NMreuXT62nloFhUgSyq12kEwTOyJuNw2 wE2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=vnF9fcyxGMD9iR0sRZwTfzJD9ThY33ewdQiOTYXH8X4=; b=jXHi8ar2+zBNA5/z8XNgiUC1DhphA3N4ClwOtke5ZGBwS0Kur1p5uKpjOpQgdSDN0C Gmw5Fgs6yyUOvqZI7YIT1UcAVxNLSgVt1tazar/v+WMKCTltgQg5UDqthriWW2bI2uBJ wAz1ksNrUTpAeZ4Ps9XNfwWC7snW0ia16aB+XIgWxrq3X8pP00aW5BTd9Ix41BUR0+bS lGLlxtd6eH7nU7H4yz51jzJxd8/pfRfMAUv6MxemXk3KB2fEWilkuZ74NzP9UI1HDvE3 2VoXxhc4wjmnxAB2kzv24fQvfjrpgvPTb5sf8eYCUZfPQjjlt80/J2HyPUazHFZMlcWU qeZA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h24si4223567edv.333.2021.02.25.16.32.39; Thu, 25 Feb 2021 16:33:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233365AbhBZA2k (ORCPT + 99 others); Thu, 25 Feb 2021 19:28:40 -0500 Received: from mail.cn.fujitsu.com ([183.91.158.132]:12518 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S232601AbhBZA20 (ORCPT ); Thu, 25 Feb 2021 19:28:26 -0500 X-IronPort-AV: E=Sophos;i="5.81,207,1610380800"; d="scan'208";a="104882848" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 26 Feb 2021 08:21:36 +0800 Received: from G08CNEXMBPEKD04.g08.fujitsu.local (unknown [10.167.33.201]) by cn.fujitsu.com (Postfix) with ESMTP id 5D38D4CE76EF; Fri, 26 Feb 2021 08:21:32 +0800 (CST) Received: from G08CNEXCHPEKD04.g08.fujitsu.local (10.167.33.200) by G08CNEXMBPEKD04.g08.fujitsu.local (10.167.33.201) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 26 Feb 2021 08:21:33 +0800 Received: from irides.mr.mr.mr (10.167.225.141) by G08CNEXCHPEKD04.g08.fujitsu.local (10.167.33.209) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Fri, 26 Feb 2021 08:21:32 +0800 From: Shiyang Ruan To: , , , CC: , , , , , , , , , Subject: [PATCH v2 10/10] fs/xfs: Add dedupe support for fsdax Date: Fri, 26 Feb 2021 08:20:30 +0800 Message-ID: <20210226002030.653855-11-ruansy.fnst@fujitsu.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210226002030.653855-1-ruansy.fnst@fujitsu.com> References: <20210226002030.653855-1-ruansy.fnst@fujitsu.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-yoursite-MailScanner-ID: 5D38D4CE76EF.A5A74 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: ruansy.fnst@fujitsu.com X-Spam-Status: No Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add xfs_break_two_dax_layouts() to break layout for tow dax files. Then call compare range function only when files are both DAX or not. Signed-off-by: Shiyang Ruan --- fs/xfs/xfs_file.c | 20 ++++++++++++++++++++ fs/xfs/xfs_inode.c | 8 +++++++- fs/xfs/xfs_inode.h | 1 + fs/xfs/xfs_reflink.c | 5 +++-- 4 files changed, 31 insertions(+), 3 deletions(-) diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index 1987d15eab61..82467d08e3ce 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -784,6 +784,26 @@ xfs_break_dax_layouts( 0, 0, xfs_wait_dax_page(inode)); } +int +xfs_break_two_dax_layouts( + struct inode *src, + struct inode *dest) +{ + int error; + bool retry = false; + +retry: + error = xfs_break_dax_layouts(src, &retry); + if (error || retry) + goto retry; + + error = xfs_break_dax_layouts(dest, &retry); + if (error || retry) + goto retry; + + return error; +} + int xfs_break_layouts( struct inode *inode, diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index b7352bc4c815..c11b11e59a83 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -3651,8 +3651,10 @@ xfs_ilock2_io_mmap( struct xfs_inode *ip2) { int ret; + struct inode *inode1 = VFS_I(ip1); + struct inode *inode2 = VFS_I(ip2); - ret = xfs_iolock_two_inodes_and_break_layout(VFS_I(ip1), VFS_I(ip2)); + ret = xfs_iolock_two_inodes_and_break_layout(inode1, inode2); if (ret) return ret; if (ip1 == ip2) @@ -3660,6 +3662,10 @@ xfs_ilock2_io_mmap( else xfs_lock_two_inodes(ip1, XFS_MMAPLOCK_EXCL, ip2, XFS_MMAPLOCK_EXCL); + + if (IS_DAX(inode1) && IS_DAX(inode2)) + ret = xfs_break_two_dax_layouts(inode1, inode2); + return 0; } diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h index eca333f5f715..9ed7a2895602 100644 --- a/fs/xfs/xfs_inode.h +++ b/fs/xfs/xfs_inode.h @@ -431,6 +431,7 @@ enum xfs_prealloc_flags { int xfs_update_prealloc_flags(struct xfs_inode *ip, enum xfs_prealloc_flags flags); +int xfs_break_two_dax_layouts(struct inode *inode1, struct inode *inode2); int xfs_break_layouts(struct inode *inode, uint *iolock, enum layout_break_reason reason); diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c index dfe4e1912ff9..9a6374550560 100644 --- a/fs/xfs/xfs_reflink.c +++ b/fs/xfs/xfs_reflink.c @@ -29,6 +29,7 @@ #include "xfs_iomap.h" #include "xfs_sb.h" #include "xfs_ag_resv.h" +#include /* * Copy on Write of Shared Blocks @@ -1306,8 +1307,8 @@ xfs_reflink_remap_prep( if (XFS_IS_REALTIME_INODE(src) || XFS_IS_REALTIME_INODE(dest)) goto out_unlock; - /* Don't share DAX file data for now. */ - if (IS_DAX(inode_in) || IS_DAX(inode_out)) + /* Don't share DAX file data with non-DAX file. */ + if (IS_DAX(inode_in) != IS_DAX(inode_out)) goto out_unlock; if (IS_DAX(inode_in)) -- 2.30.1