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=-15.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham 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 DDE21C2BBCF for ; Fri, 18 Dec 2020 01:50:34 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2B6CC2399C for ; Fri, 18 Dec 2020 01:50:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2B6CC2399C 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 550296B005C; Thu, 17 Dec 2020 20:50:33 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 500106B005D; Thu, 17 Dec 2020 20:50:33 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 415CC6B0068; Thu, 17 Dec 2020 20:50:33 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0158.hostedemail.com [216.40.44.158]) by kanga.kvack.org (Postfix) with ESMTP id 2C3E76B005C for ; Thu, 17 Dec 2020 20:50:33 -0500 (EST) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id E4E2C181AEF31 for ; Fri, 18 Dec 2020 01:50:32 +0000 (UTC) X-FDA: 77604723504.09.actor36_250c5ce27439 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin09.hostedemail.com (Postfix) with ESMTP id CC17F180AD811 for ; Fri, 18 Dec 2020 01:50:32 +0000 (UTC) X-HE-Tag: actor36_250c5ce27439 X-Filterd-Recvd-Size: 4246 Received: from heian.cn.fujitsu.com (mail.cn.fujitsu.com [183.91.158.132]) by imf04.hostedemail.com (Postfix) with ESMTP for ; Fri, 18 Dec 2020 01:50:31 +0000 (UTC) X-IronPort-AV: E=Sophos;i="5.78,428,1599494400"; d="scan'208";a="102687225" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 18 Dec 2020 09:50:28 +0800 Received: from G08CNEXMBPEKD05.g08.fujitsu.local (unknown [10.167.33.204]) by cn.fujitsu.com (Postfix) with ESMTP id D0B364CE6014; Fri, 18 Dec 2020 09:50:25 +0800 (CST) Received: from irides.mr (10.167.225.141) by G08CNEXMBPEKD05.g08.fujitsu.local (10.167.33.204) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 18 Dec 2020 09:50:25 +0800 Subject: Re: [RFC PATCH v3 4/9] mm, fsdax: Refactor memory-failure handler for dax mapping To: Dave Chinner CC: , , , , , , , , , , , , References: <20201215121414.253660-1-ruansy.fnst@cn.fujitsu.com> <20201215121414.253660-5-ruansy.fnst@cn.fujitsu.com> <20201216212648.GN632069@dread.disaster.area> From: Ruan Shiyang Message-ID: <513e7602-80d7-8d8c-ed5d-06b8113823bf@cn.fujitsu.com> Date: Fri, 18 Dec 2020 09:48:34 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.5.1 MIME-Version: 1.0 In-Reply-To: <20201216212648.GN632069@dread.disaster.area> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Language: en-US X-Originating-IP: [10.167.225.141] X-ClientProxiedBy: G08CNEXCHPEKD06.g08.fujitsu.local (10.167.33.205) To G08CNEXMBPEKD05.g08.fujitsu.local (10.167.33.204) X-yoursite-MailScanner-ID: D0B364CE6014.AB9CB X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: ruansy.fnst@cn.fujitsu.com Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 2020/12/17 =E4=B8=8A=E5=8D=885:26, Dave Chinner wrote: > On Tue, Dec 15, 2020 at 08:14:09PM +0800, Shiyang Ruan wrote: >> The current memory_failure_dev_pagemap() can only handle single-mapped >> dax page for fsdax mode. The dax page could be mapped by multiple fil= es >> and offsets if we let reflink feature & fsdax mode work together. So, >> we refactor current implementation to support handle memory failure on >> each file and offset. >> >> Signed-off-by: Shiyang Ruan >> --- > ..... >> static const char *action_name[] =3D { >> @@ -1147,6 +1148,60 @@ static int try_to_split_thp_page(struct page *p= age, const char *msg) >> return 0; >> } >> =20 >> +int mf_dax_mapping_kill_procs(struct address_space *mapping, pgoff_t = index, int flags) >> +{ >> + const bool unmap_success =3D true; >> + unsigned long pfn, size =3D 0; >> + struct to_kill *tk; >> + LIST_HEAD(to_kill); >> + int rc =3D -EBUSY; >> + loff_t start; >> + dax_entry_t cookie; >> + >> + /* >> + * Prevent the inode from being freed while we are interrogating >> + * the address_space, typically this would be handled by >> + * lock_page(), but dax pages do not use the page lock. This >> + * also prevents changes to the mapping of this pfn until >> + * poison signaling is complete. >> + */ >> + cookie =3D dax_lock(mapping, index, &pfn); >> + if (!cookie) >> + goto unlock; >=20 > Why do we need to prevent the inode from going away here? This > function gets called by XFS after doing an xfs_iget() call to grab > the inode that owns the block. Hence the the inode (and the mapping) > are guaranteed to be referenced and can't go away. Hence for the > filesystem based callers, this whole "dax_lock()" thing can go away > > So, AFAICT, the dax_lock() stuff is only necessary when the > filesystem can't be used to resolve the owner of physical page that > went bad.... Yes, you are right. I made a mistake in the calling sequence here.=20 Thanks for pointing out. -- Thanks, Ruan Shiyang. >=20 > Cheers, >=20 > Dave. >=20