From patchwork Fri Aug 7 13:13:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ruan Shiyang X-Patchwork-Id: 11705655 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E789C618 for ; Fri, 7 Aug 2020 13:13:56 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id BE71F22CF6 for ; Fri, 7 Aug 2020 13:13:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BE71F22CF6 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=cn.fujitsu.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 581D08D00A4; Fri, 7 Aug 2020 09:13:55 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 533388D003B; Fri, 7 Aug 2020 09:13:55 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 422778D00A4; Fri, 7 Aug 2020 09:13:55 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0127.hostedemail.com [216.40.44.127]) by kanga.kvack.org (Postfix) with ESMTP id 2EE578D003B for ; Fri, 7 Aug 2020 09:13:55 -0400 (EDT) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 0267482499B9 for ; Fri, 7 Aug 2020 13:13:55 +0000 (UTC) X-FDA: 77123815230.07.band44_570b14826fc0 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin07.hostedemail.com (Postfix) with ESMTP id C8DA51803F9AB for ; Fri, 7 Aug 2020 13:13:54 +0000 (UTC) X-Spam-Summary: 1,0,0,748f3913d42470c0,d41d8cd98f00b204,ruansy.fnst@cn.fujitsu.com,,RULES_HIT:41:355:379:541:973:988:989:1260:1261:1277:1311:1313:1314:1345:1437:1515:1516:1518:1535:1543:1711:1730:1747:1777:1792:2198:2199:2393:2559:2562:2693:2899:3138:3139:3140:3141:3142:3355:3865:3866:3867:3868:3870:3871:3872:3874:4250:4605:5007:6119:6120:6261:7901:7903:9010:9203:10004:10400:11026:11232:11537:11657:11658:11914:12043:12291:12296:12297:12521:12679:12683:12895:13019:13161:13229:13894:14096:14097:14721:21080:21433:21451:21611:21627:21740:21939:21990:30054:30070:30075:30079,0,RBL:183.91.158.132:@cn.fujitsu.com:.lbl8.mailshell.net-62.16.2.100 64.201.201.201;04yfu79oukirj84sni4t4z18mhg86oc44g369odhwmfffw7ibc1yabba7rbqjkb.h9uuyb6cdhtzdjmuftwrps614coirbxun5gmqc3t1jk7p9x18p6ky5rbqaqa3e8.c-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:23,LUA_SUMMARY:none X-HE-Tag: band44_570b14826fc0 X-Filterd-Recvd-Size: 5017 Received: from heian.cn.fujitsu.com (mail.cn.fujitsu.com [183.91.158.132]) by imf32.hostedemail.com (Postfix) with ESMTP for ; Fri, 7 Aug 2020 13:13:53 +0000 (UTC) X-IronPort-AV: E=Sophos;i="5.75,445,1589212800"; d="scan'208";a="97774911" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 07 Aug 2020 21:13:42 +0800 Received: from G08CNEXMBPEKD05.g08.fujitsu.local (unknown [10.167.33.204]) by cn.fujitsu.com (Postfix) with ESMTP id 807F34CE34DD; Fri, 7 Aug 2020 21:13:36 +0800 (CST) Received: from G08CNEXCHPEKD06.g08.fujitsu.local (10.167.33.205) by G08CNEXMBPEKD05.g08.fujitsu.local (10.167.33.204) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 7 Aug 2020 21:13:38 +0800 Received: from localhost.localdomain (10.167.225.141) by G08CNEXCHPEKD06.g08.fujitsu.local (10.167.33.209) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Fri, 7 Aug 2020 21:13:36 +0800 From: Shiyang Ruan To: , , CC: , , , , , , , , Subject: [RFC PATCH 0/8] fsdax: introduce FS query interface to support reflink Date: Fri, 7 Aug 2020 21:13:28 +0800 Message-ID: <20200807131336.318774-1-ruansy.fnst@cn.fujitsu.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 X-yoursite-MailScanner-ID: 807F34CE34DD.AD5BB X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: ruansy.fnst@cn.fujitsu.com X-Spam-Status: No X-Rspamd-Queue-Id: C8DA51803F9AB X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000064, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: This patchset is a try to resolve the problem of tracking shared page for fsdax. Instead of per-page tracking method, this patchset introduces a query interface: get_shared_files(), which is implemented by each FS, to obtain the owners of a shared page. It returns an owner list of this shared page. Then, the memory-failure() iterates the list to be able to notify each process using files that sharing this page. The design of the tracking method is as follow: 1. dax_assocaite_entry() associates the owner's info to this page - For non-reflink case: page->mapping,->index stores the file's mapping, offset in file. A dax page is not shared by other files. dax_associate_entry() is called only once. So, use page->mapping,->index to store the owner's info. - For reflink case: page->mapping,->index stores the block device, offset in device. A dax page is shared more than once. So, dax_assocaite_entry() will be called more than once. We introduce page->zone_device_data as reflink counter, to indicate that this page is shared and how many owners now is using this page. The page->mapping,->index is used to store the block_device of the fs and page offset of this device. 2. dax_lock_page() calls query interface to lock each dax entry - For non-reflink case: owner's info is stored in page->mapping,->index. So, It is easy to lock its dax entry. - For reflink case: owner's info is obtained by calling get_shared_files(), which is implemented by FS. The FS context could be found in block_device that stored by page->mapping. Then lock the dax entries of the owners. In memory-failure(), since the owner list has been obtained in dax_lock_page(), just iterate the list and handle the error. This patchset didn't handle the memory failure on metadata of FS because I haven't found a way to distinguish whether this page contains matadata yet. Still working on it. == I also borrowed and made some changes on Goldwyn's patchsets. These patches makes up for the lack of CoW mechanism in fsdax. The rests are dax & reflink support for xfs. (Rebased on v5.8) == Shiyang Ruan (8): fs: introduce get_shared_files() for dax&reflink fsdax, mm: track files sharing dax page for memory-failure fsdax: introduce dax_copy_edges() for COW fsdax: copy data before write fsdax: replace mmap entry in case of CoW fsdax: dedup file range to use a compare function fs/xfs: handle CoW for fsdax write() path fs/xfs: support dedupe for fsdax fs/btrfs/reflink.c | 3 +- fs/dax.c | 302 +++++++++++++++++++++++++++++++++++------ fs/ocfs2/file.c | 2 +- fs/read_write.c | 11 +- fs/xfs/xfs_bmap_util.c | 6 +- fs/xfs/xfs_file.c | 10 +- fs/xfs/xfs_iomap.c | 3 +- fs/xfs/xfs_iops.c | 11 +- fs/xfs/xfs_reflink.c | 80 ++++++----- fs/xfs/xfs_super.c | 67 +++++++++ include/linux/dax.h | 18 ++- include/linux/fs.h | 11 +- include/linux/mm.h | 8 ++ mm/memory-failure.c | 138 ++++++++++++------- 14 files changed, 529 insertions(+), 141 deletions(-)