Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp791pxf; Tue, 16 Mar 2021 20:01:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyuE3fIo1YW1zPDXMN9gki7N3BK4HLoi3mwS+B9hlyCyN7eLaIXAlI0oBteYtkVPl6uRltH X-Received: by 2002:aa7:d813:: with SMTP id v19mr26970696edq.213.1615950100205; Tue, 16 Mar 2021 20:01:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615950100; cv=none; d=google.com; s=arc-20160816; b=PGGAiesCp52E+foDKBKglQHu0BY5X8l8snG8p4Q/33ZrLz0Jld/B8jfJNMArT0KPkS igv7F4nv0/DPv1E9z43hy0ZsheGFX4fCOc2yZ6A7aW+S8/EpxYbe18RQIhclKlBaauM7 /ejpIEsMSPPJoaWnHIwzsNhZtE6Ko9hWOrJ6wKsg2nZboSyVqRDXTfj/0QRcsNrAQZJP qD0+nE6TYHecZ1fRwc88qKEk9SaxBDL7+Pz4A7WBPjR2BKbW0OxT1JufMmISKoDGa9WK ceqtFu52ZjOa3xSNKObaqDMgOSgRV6PJa7GFwGV9Yo5WsElNdAplFDUCba6qH5RXi0yV aqvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :content-language:accept-language:references:message-id:date :thread-index:thread-topic:subject:cc:to:from; bh=tTpbR+2uRwWqseebDaw5/zN/x6YwEfWjLiiGsYrDvH4=; b=Ekq0gsDZhz2U7FHkupzjkF1UNIUK6YE6dgmK/e0XCeijbFggaS3gUpxLb2umoDB7Y1 k/25S1H7ziQVXtJzHwqBuaxO1j7MGt8zc94hymjN/LWHfsZG4cbBsyFuzHomCy1QUpGp h6V7CrbtDeKh37zWozWxrCCz8Aqt0kqr6I9Bf5+QGpqk9+xx4iAXt7Oj0FII4mYRS6+6 PFF0azgEbtoTMs59XW3G1VGDx34qwFRuyJsd7/yFWJHdfCZVT7FmR4qa4BDL0r0tI0k5 yQ7DQaZK6JT1VC3G4+Cj9LI7sXH62/ERRQxE1Jpad7hNLmFpjXTkdejh2T0NB0LovTlH BFiw== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x6si15011218ejb.380.2021.03.16.20.01.16; Tue, 16 Mar 2021 20:01:40 -0700 (PDT) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229590AbhCQDAF convert rfc822-to-8bit (ORCPT + 99 others); Tue, 16 Mar 2021 23:00:05 -0400 Received: from szxga01-in.huawei.com ([45.249.212.187]:3041 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229487AbhCQC77 (ORCPT ); Tue, 16 Mar 2021 22:59:59 -0400 Received: from DGGEML404-HUB.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4F0ZYw6BYpzWMHZ; Wed, 17 Mar 2021 10:56:52 +0800 (CST) Received: from DGGEML509-MBS.china.huawei.com ([169.254.4.125]) by DGGEML404-HUB.china.huawei.com ([fe80::b177:a243:7a69:5ab8%31]) with mapi id 14.03.0513.000; Wed, 17 Mar 2021 10:59:44 +0800 From: "chenjun (AM)" To: Dan Williams , Matthew Wilcox CC: "linux-kernel@vger.kernel.org" , "linux-fsdevel@vger.kernel.org" , Jan Kara , "Xiangrui (Euler)" , "lizhe (Y)" , yangerkun , "zhangyi (F)" Subject: Re: [question] Panic in dax_writeback_one Thread-Topic: [question] Panic in dax_writeback_one Thread-Index: AdcWSusQwspXlegvQqCtsylm2CuWCw== Date: Wed, 17 Mar 2021 02:59:43 +0000 Message-ID: References: <20210311121923.GU3479805@casper.infradead.org> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.174.178.53] Content-Type: text/plain; charset="iso-2022-jp" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 在 2021/3/12 1:25, Dan Williams 写道: > On Thu, Mar 11, 2021 at 4:20 AM Matthew Wilcox wrote: >> >> On Thu, Mar 11, 2021 at 07:48:25AM +0000, chenjun (AM) wrote: >>> static int dax_writeback_one(struct xa_state *xas, struct dax_device >>> *dax_dev, struct address_space *mapping, void *entry) >>> ----dax_flush(dax_dev, page_address(pfn_to_page(pfn)), count * PAGE_SIZE); >>> The pfn is returned by the driver. In my case, the pfn does not have >>> struct page. so pfn_to_page(pfn) return a wrong address. >> >> I wasn't involved, but I think the right solution here is simply to >> replace page_address(pfn_to_page(pfn)) with pfn_to_virt(pfn). I don't >> know why Dan decided to do this in the more complicated way. > > pfn_to_virt() only works for the direct-map. If pages are not mapped I > don't see how pfn_to_virt() is expected to work. > > The real question Chenjun is why are you writing a new simulator of > memory as a block-device vs reusing the pmem driver or brd? > Hi Dan In my case, I do not want to take memory to create the struct page of the memory my driver used. And, I think this is also a problem for DCSSBLK. So I want to go back the older way if CONFIG_FS_DAX_LIMITED diff --git a/fs/dax.c b/fs/dax.c index b3d27fd..6395e84 100644 --- a/fs/dax.c +++ b/fs/dax.c @@ -867,6 +867,9 @@ static int dax_writeback_one(struct xa_state *xas, struct dax_device *dax_dev, { unsigned long pfn, index, count; long ret = 0; + void *kaddr; + pfn_t new_pfn_t; + pgoff_t pgoff; /* * A page got tagged dirty in DAX mapping? Something is seriously @@ -926,7 +929,25 @@ static int dax_writeback_one(struct xa_state *xas, struct dax_device *dax_dev, index = xas->xa_index & ~(count - 1); dax_entry_mkclean(mapping, index, pfn); - dax_flush(dax_dev, page_address(pfn_to_page(pfn)), count * PAGE_SIZE); + + if (!IS_ENABLED(CONFIG_FS_DAX_LIMITED) || pfn_valid(pfn)) + kaddr = page_address(pfn_to_page(pfn)); + else { + ret = bdev_dax_pgoff(mapping->host->i_sb->s_bdev, pfn << PFN_SECTION_SHIFT, count << PAGE_SHIFT, &pgoff); + if (ret) + goto put_unlocked; + + ret = dax_direct_access(dax_dev, pgoff, count, &kaddr, &new_pfn_t); + if (ret < 0) + goto put_unlocked; + + if (WARN_ON_ONCE(ret < count) || WARN_ON_ONCE(pfn_t_to_pfn(new_pfn_t) != pfn)) { + ret = -EIO; + goto put_unlocked; + } + } + + dax_flush(dax_dev, kaddr, count * PAGE_SIZE); /* * After we have flushed the cache, we can clear the dirty tag. There * cannot be new dirty data in the pfn after the flush has completed as -- -- Regards Chen Jun