[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CE1E7D7EFA066443B6454A6A5063B50220D12A8A@dggeml509-mbs.china.huawei.com>
Date: Wed, 17 Mar 2021 02:59:43 +0000
From: "chenjun (AM)" <chenjun102@...wei.com>
To: Dan Williams <dan.j.williams@...el.com>,
Matthew Wilcox <willy@...radead.org>
CC: "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"linux-fsdevel@...r.kernel.org" <linux-fsdevel@...r.kernel.org>,
Jan Kara <jack@...e.cz>,
"Xiangrui (Euler)" <rui.xiang@...wei.com>,
"lizhe (Y)" <lizhe67@...wei.com>, yangerkun <yangerkun@...wei.com>,
"zhangyi (F)" <yi.zhang@...wei.com>
Subject: Re: [question] Panic in dax_writeback_one
在 2021/3/12 1:25, Dan Williams 写道:
> On Thu, Mar 11, 2021 at 4:20 AM Matthew Wilcox <willy@...radead.org> 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
Powered by blists - more mailing lists