Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1312345pxb; Wed, 10 Feb 2021 05:43:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJwT7NnLcfR7nO+9oCHtVxKLSBgZ74IMx5nH0mjLbmHbxQOICIqERbQor3m54MEkRVS10NdR X-Received: by 2002:a05:6402:306c:: with SMTP id bs12mr3172920edb.348.1612964582184; Wed, 10 Feb 2021 05:43:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612964582; cv=none; d=google.com; s=arc-20160816; b=A62onk3p7DlGKk6abtJ9Mp4PQmWd3mhAidDb2Bk6jb+aNJPoc5ACIijz8T3ncBeZhH /jonVxNB3ehGJ4eDFqxYUs7mQqsIQUP7ygi/F197DVEVpgGTtQSIS7Tm/JPkK+bd/WUY ADDzCXp2lUcSjBYYS0/vGfz/Ts6tOubzs1N/DO3OPiU5K8yID9Wbd/e/itMg5uh4FHhM AY/y3ck1v6JZ0c/BGVI8yrdWfw36KIfY1BG9wcoPe5gxT+1HbnDL8Y9a2u4sdtM9TiMz Vb8/t4NFdlZkd7yClAgfSIAsyEAYsxDZ5hA/jZyx0AaxpiGr5oqxycsvQhMUn+pZwHfr xNTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=9T9VA3zJeIl+2yENctk9gDcFFGUUcbTej6ja/+9D4eA=; b=PEoxpW0oGjIfnJYyuvkm5uJeHQFNRzUepZUfWeKVzfxRNX0fDeO8G594D9fMoNSYli Jo3yX16GxG1/JeSuVpoNjS7hJ3tgCVlV9C8891LpIybyQqPNNR3ugxjoU3o+rOLAJyFh DLjS74y5GXSw14THpmMJ74mNWbPiVeLB//i5slAACKitYzKynGkzItK3xlkGwHmL2N0h C/A+fORSk5yYDutkM1wCFupE+1tVqf/IQPUhLSWZIfJb755oH1GfJrvkdDjl8ZdAbdpT d4Wy3IsUUQ4iEb/4Gaa2PM4dBv3jzZvXcHApE800xzWWd1xaKiwFchc9Ogyj9eJeBAZH L2Zg== 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 r1si1410215eda.284.2021.02.10.05.42.38; Wed, 10 Feb 2021 05:43:02 -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 S230235AbhBJNls (ORCPT + 99 others); Wed, 10 Feb 2021 08:41:48 -0500 Received: from verein.lst.de ([213.95.11.211]:51214 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229710AbhBJNlp (ORCPT ); Wed, 10 Feb 2021 08:41:45 -0500 Received: by verein.lst.de (Postfix, from userid 2407) id 97BF768B02; Wed, 10 Feb 2021 14:41:00 +0100 (CET) Date: Wed, 10 Feb 2021 14:41:00 +0100 From: Christoph Hellwig To: Shiyang Ruan Cc: linux-kernel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-nvdimm@lists.01.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, dm-devel@redhat.com, darrick.wong@oracle.com, dan.j.williams@intel.com, david@fromorbit.com, hch@lst.de, agk@redhat.com, snitzer@redhat.com, rgoldwyn@suse.de, qi.fuli@fujitsu.com, y-goto@fujitsu.com Subject: Re: [PATCH v3 06/11] mm, pmem: Implement ->memory_failure() in pmem driver Message-ID: <20210210134100.GE30109@lst.de> References: <20210208105530.3072869-1-ruansy.fnst@cn.fujitsu.com> <20210208105530.3072869-7-ruansy.fnst@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210208105530.3072869-7-ruansy.fnst@cn.fujitsu.com> User-Agent: Mutt/1.5.17 (2007-11-01) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > +static int pmem_pagemap_memory_failure(struct dev_pagemap *pgmap, > + unsigned long pfn, int flags) > +{ > + struct pmem_device *pdev; > + struct gendisk *disk; > + loff_t disk_offset; > + int rc = 0; > + unsigned long size = page_size(pfn_to_page(pfn)); > + > + pdev = container_of(pgmap, struct pmem_device, pgmap); > + disk = pdev->disk; Would be nice to initialize this at the time of declaration: struct pmem_device *pdev = container_of(pgmap, struct pmem_device, pgmap); struct gendisk *disk = pdev->disk unsigned long size = page_size(pfn_to_page(pfn)); > + if (!disk) > + return -ENXIO; > + > + disk_offset = PFN_PHYS(pfn) - pdev->phys_addr - pdev->data_offset; > + if (disk->fops->corrupted_range) { > + rc = disk->fops->corrupted_range(disk, NULL, disk_offset, > + size, &flags); > + if (rc == -ENODEV) > + rc = -ENXIO; > + } else > + rc = -EOPNOTSUPP; Why do we need the disk and fops check here? A pgmap registered by pmem.c should always have a disk with pmem_fops. And more importantly this has no business going through the block layer. Instead the file system should deposit a callback when starting to use the dax_device using fs_dax_get_by_bdev / dax_get_by_host and a private data (the superblock), and we avoid all the lookup problems. > +int mf_generic_kill_procs(unsigned long long pfn, int flags) This function seems to be only used inside of memory-failure.c, so it could be marked static. Also I'd name it dax_generic_memory_failure or something like that to match the naming of the ->memory_failure pgmap operation. Also maybe just splitting this out into a helper would be a nice prep patch.