Received: by 2002:a05:6520:3645:b029:c0:f950:43e0 with SMTP id l5csp168432lki; Tue, 16 Mar 2021 21:58:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy58QK4zikKBle/q75AN4iEGgeoidYRLnOmNGO3K/SsQWOJM9TjN1Gs0e6SRAX0gy8czUG2 X-Received: by 2002:aa7:c804:: with SMTP id a4mr39260831edt.251.1615957122896; Tue, 16 Mar 2021 21:58:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615957122; cv=none; d=google.com; s=arc-20160816; b=KkIbvtHVeC8NDNHTqwz8ZaUWVVZYIsUAO8aF4i8MqbVWlFF6m09KHbvJMM9OHpUSz8 trG20Ha4GE1FbypaE2L8gxNugakCwI/KC6O4RLgvkPJarSwAK0BHs4yjacjMgkw0/Z4D gP8g9ENxE+fpRXxm3xGDhuaMkRRXN+l9EP9WKt8loBwfiKZ3LpdNhrqKuBwVD1uGHgV6 q1tJbYp2PsVUMVCOSFi4AYQ2qPbHGHykbWZglEd3mTct8ecEPhGKhRs3Wc6Ln6tgBm5v w2lmwDWCDwPdtPKbC7xX4ryTmy7mdX1EfAgzUi67Aa15RBB2HpqKGH9+oW44jE8Dws9C lOyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=R9Su8BT2yWWWTsxwDOrtHcEfB6yWhXQeHaQOaR7lJs0=; b=Ur2neXun/YU5e0cKpzrAJyY8tvsO/Skdvfnpsvgv1rldRt+HEZkSrOb1pZ7mJ5Kzr4 drIOfq1FySyLtgCr+Va3PtytV1QzhX9fsSR9vx58PGhUJqnBzyvcArE1+ybauiZP2qSm KuMx4mdNbLPHPSVx6NuCGlcmGPPHEMU/oyCIamUsjEFMSCMMjFe/zVyTDVAK9IU9JIQy 7eKRGO97YlAdOmQHCi7qwo1BLdsmUMzoaBURNDxzf41gExh1wRCm3v+CUGyFLT6vjVZJ 7k7jKi7qGq3XJkT42i9uak5aCsN9W3nuuNGkQAkSi4ew+zHTKc3zqOFDS3mwfZJmN/z7 nU0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=O6sx9FFH; 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l12si15355352eds.123.2021.03.16.21.58.20; Tue, 16 Mar 2021 21:58:42 -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; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=O6sx9FFH; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229492AbhCQE4F (ORCPT + 99 others); Wed, 17 Mar 2021 00:56:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229487AbhCQEzf (ORCPT ); Wed, 17 Mar 2021 00:55:35 -0400 Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB578C06174A for ; Tue, 16 Mar 2021 21:55:34 -0700 (PDT) Received: by mail-ej1-x62c.google.com with SMTP id r17so442498ejy.13 for ; Tue, 16 Mar 2021 21:55:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=R9Su8BT2yWWWTsxwDOrtHcEfB6yWhXQeHaQOaR7lJs0=; b=O6sx9FFHvjxesWJe/kyNeeBwWtW52JhZ86uNybfLp1n5nVpFA0IdiS1FOjx1HpoaD3 v98nvCJdMQQRsZF4Ahu2nvix+wWfSe6qAHxAlqqAICsBrPdWX3GX5tW9Jy52xYO03bG2 tq7uMOyEKMG4n2m4kmyRyxz9EpkWw4r97rCHXVZFOL8YDM+2i24h4NIe9+6TTy1Ry1tu QiRCdpVKVXGNYNe/nBpvBvBRoBPu2da836m6NDtDeN4NNFm6Y84CYIBl6C6eVwoPXJ5A 9d8jt1DnkFlIM91CFSuKs6O1m+RJp0IKPkWx3F1g46JqMwRFiBaSlwlFy8gmhIBpdAUc 4ybg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=R9Su8BT2yWWWTsxwDOrtHcEfB6yWhXQeHaQOaR7lJs0=; b=p6cwtcAp0R7Pr9eeEGKNYXhcicNZRcC9JPZw4+5Gal6qoYfDClKIOSFMwH2NUkE5Su WW3NoFpXsgB1mOUUDEnjv9GxWgf+DBzTHkOrPq+C+Hr6sfjfqDGee7cTTgXdAZ3brUdW 8lPSt0ey2Jjtb7EipiUXhPX9CR+swE8VUyp3gEjxPLwEdp8LIXpNa1QDnA0HP1udHS+J e8wuzJYHiRvtQkN0ps4tHy6N0OEBQsZ9CXeVN4L9EdQRKsdaWNI2otXRhJi+PJlx+uY8 LeMBrjdtWZsxu7iErP1sGDPKuPJjFumK5S5IWwrS5SFp5V06XdIwLtcPX7zItw+I2iHn EsbA== X-Gm-Message-State: AOAM530uVWNd+Ct0ZbY0SxMGPope+XhWC5vrL0KphRVZuPl6VxFcxJF3 5CQJqYRTOZkiOI+Kwk4cdJpi4bsghk6CskZMerQxKykaL6daFg== X-Received: by 2002:a17:906:1386:: with SMTP id f6mr32943546ejc.45.1615956933554; Tue, 16 Mar 2021 21:55:33 -0700 (PDT) MIME-Version: 1.0 References: <20210311121923.GU3479805@casper.infradead.org> In-Reply-To: From: Dan Williams Date: Tue, 16 Mar 2021 21:55:27 -0700 Message-ID: Subject: Re: [question] Panic in dax_writeback_one To: "chenjun (AM)" Cc: Matthew Wilcox , "linux-kernel@vger.kernel.org" , "linux-fsdevel@vger.kernel.org" , Jan Kara , "Xiangrui (Euler)" , "lizhe (Y)" , yangerkun , "zhangyi (F)" , Joao Martins Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 16, 2021 at 8:00 PM chenjun (AM) wrote: > > =E5=9C=A8 2021/3/12 1:25, Dan Williams =E5=86=99=E9=81=93: > > On Thu, Mar 11, 2021 at 4:20 AM Matthew Wilcox wr= ote: > >> > >> 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_S= IZE); > >>> 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. There are efforts happening to drastically reduce that overhead. You might want to check out Joao's work [1]. I think that direction holds more promise than trying to extend FS_DAX_LIMITED. [1]: http://lore.kernel.org/r/20201208172901.17384-1-joao.m.martins@oracle.= com > And, I think this is also a problem for DCSSBLK. If I understand correctly DAX replaced XIP for S390. There have not been reports about this problem, and I can only guess because XIP (eXecute-In-Place) is a read-only use case where dax_writeback_one() is never triggered, or S390 just isn't using DCSSBLK anymore. The last time I touched FS_DAX_LIMITED the DCSSBLK maintainers offered to just delete this driver to get it out of the way. > > 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 =3D 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 =3D xas->xa_index & ~(count - 1); > > dax_entry_mkclean(mapping, index, pfn); > - dax_flush(dax_dev, page_address(pfn_to_page(pfn)), count * PAGE_S= IZE); > + > + if (!IS_ENABLED(CONFIG_FS_DAX_LIMITED) || pfn_valid(pfn)) > + kaddr =3D page_address(pfn_to_page(pfn)); > + else { > + ret =3D bdev_dax_pgoff(mapping->host->i_sb->s_bdev, pfn <= < > PFN_SECTION_SHIFT, count << PAGE_SHIFT, &pgoff); This is broken: mapping->host->i_sb->s_bdev ...there is no guarantee that the superblock associated with the mapping is hosted on the same block device associated with the passed in dax_device. See dax_rtdev in xfs_open_devices().