From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0D5DEC433E8 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 CE1FD2224D for ; Fri, 7 Aug 2020 13:13:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CE1FD2224D 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) Received: by kanga.kvack.org (Postfix, from userid 40) id 533388D003B; Fri, 7 Aug 2020 09:13:55 -0400 (EDT) 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-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-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 Content-Type: text/plain X-yoursite-MailScanner-ID: 807F34CE34DD.AD5BB X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: ruansy.fnst@cn.fujitsu.com X-Rspamd-Queue-Id: C8DA51803F9AB X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 Content-Transfer-Encoding: quoted-printable 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=20 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. =3D=3D 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) =3D=3D 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(-) --=20 2.27.0