Re: [PATCH -next] memregion: Add arch_flush_memregion() interface

2022-09-13 Thread Davidlohr Bueso

On Fri, 09 Sep 2022, Jonathan Cameron wrote:


On Thu, 8 Sep 2022 16:22:26 -0700
Dan Williams  wrote:


Andrew Morton wrote:
> On Thu, 8 Sep 2022 15:51:50 -0700 Dan Williams  
wrote:
>
> > Jonathan Cameron wrote:
> > > On Wed, 7 Sep 2022 18:07:31 -0700
> > > Dan Williams  wrote:
> > >
> > > > Andrew Morton wrote:
> > > > > I really dislike the term "flush".  Sometimes it means writeback,
> > > > > sometimes it means invalidate.  Perhaps at other times it means
> > > > > both.
> > > > >
> > > > > Can we please be very clear in comments and changelogs about exactly
> > > > > what this "flush" does.   With bonus points for being more specific 
in the
> > > > > function naming?
> > > > >
> > > >
> > > > That's a good point, "flush" has been cargo-culted along in Linux's
> > > > cache management APIs to mean write-back-and-invalidate. In this case I
> > > > think this API is purely about invalidate. It just so happens that x86
> > > > has not historically had a global invalidate instruction readily
> > > > available which leads to the overuse of wbinvd.
> > > >
> > > > It would be nice to make clear that this API is purely about
> > > > invalidating any data cached for a physical address impacted by address
> > > > space management event (secure erase / new region provision). Write-back
> > > > is an unnecessary side-effect.
> > > >
> > > > So how about:
> > > >
> > > > s/arch_flush_memregion/cpu_cache_invalidate_memregion/?
> > >
> > > Want to indicate it 'might' write back perhaps?
> > > So could be invalidate or clean and invalidate (using arm ARM terms just 
to add
> > > to the confusion ;)
> > >
> > > Feels like there will be potential race conditions where that matters as 
we might
> > > force stale data to be written back.
> > >
> > > Perhaps a comment is enough for that. Anyone have the "famous last words" 
feeling?
> >
> > Is "invalidate" not clear that write-back is optional? Maybe not.
>
> Yes, I'd say that "invalidate" means "dirty stuff may of may not have
> been written back".  Ditto for invalidate_inode_pages2().
>
> > Also, I realized that we tried to include the address range to allow for
> > the possibility of flushing by virtual address range, but that
> > overcomplicates the use. I.e. if someone issue secure erase and the
> > region association is not established does that mean that mean that the
> > cache invalidation is not needed? It could be the case that someone
> > disables a device, does the secure erase, and then reattaches to the
> > same region. The cache invalidation is needed, but at the time of the
> > secure erase the HPA was unknown.
> >
> > All this to say that I feel the bikeshedding will need to continue until
> > morale improves.
> >
> > I notice that the DMA API uses 'sync' to indicate, "make this memory
> > consistent/coherent for the CPU or the device", so how about an API like
> >
> > memregion_sync_for_cpu(int res_desc)
> >
> > ...where the @res_desc would be IORES_DESC_CXL for all CXL and
> > IORES_DESC_PERSISTENT_MEMORY for the current nvdimm use case.
>
> "sync" is another of my pet peeves ;) In filesystem land, at least.
> Does it mean "start writeback and return" or does it mean "start
> writeback, wait for its completion then return".

Ok, no "sync" :).

/**
 * cpu_cache_invalidate_memregion - drop any CPU cached data for
 * memregions described by @res_des
 * @res_desc: one of the IORES_DESC_* types
 *
 * Perform cache maintenance after a memory event / operation that
 * changes the contents of physical memory in a cache-incoherent manner.
 * For example, memory-device secure erase, or provisioning new CXL
 * regions. This routine may or may not write back any dirty contents
 * while performing the invalidation.
 *
 * Returns 0 on success or negative error code on a failure to perform
 * the cache maintenance.
 */
int cpu_cache_invalidate_memregion(int res_desc)


lgtm


Likewise, and I don't see anyone else objecting so I'll go ahead and send
a new iteration.

Thanks,
Davidlohr



[PATCH] nvdimm: make __nvdimm_security_overwrite_query static

2022-09-13 Thread Jiapeng Chong
This symbol is not used outside of security.c, so marks it static.

drivers/nvdimm/security.c:411:6: warning: no previous prototype for function 
'__nvdimm_security_overwrite_query'.

Link: https://bugzilla.openanolis.cn/show_bug.cgi?id=2148
Reported-by: Abaci Robot 
Signed-off-by: Jiapeng Chong 
---
 drivers/nvdimm/security.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/nvdimm/security.c b/drivers/nvdimm/security.c
index b5aa55c61461..8aefb60c42ff 100644
--- a/drivers/nvdimm/security.c
+++ b/drivers/nvdimm/security.c
@@ -408,7 +408,7 @@ static int security_overwrite(struct nvdimm *nvdimm, 
unsigned int keyid)
return rc;
 }
 
-void __nvdimm_security_overwrite_query(struct nvdimm *nvdimm)
+static void __nvdimm_security_overwrite_query(struct nvdimm *nvdimm)
 {
struct nvdimm_bus *nvdimm_bus = walk_to_nvdimm_bus(&nvdimm->dev);
int rc;
-- 
2.20.1.7.g153144c




Re: [PATCH] xfs: fail dax mount if reflink is enabled on a partition

2022-09-13 Thread Yang , Xiao/杨 晓

On 2022/9/9 21:01, Brian Foster wrote:

Yes.. I don't recall all the internals of the tools and test, but IIRC
it relied on discard to perform zeroing between checkpoints or some such
and avoid spurious failures. The purpose of running on dm-thin was
merely to provide reliable discard zeroing behavior on the target device
and thus to allow the test to run reliably.


Hi Brian,

As far as I know, generic/470 was original designed to verify 
mmap(MAP_SYNC) on the dm-log-writes device enabling DAX. Due to the 
reason, we need to ensure that all underlying devices under 
dm-log-writes device support DAX. However dm-thin device never supports 
DAX so

running generic/470 with dm-thin device always returns "not run".

Please see the difference between old and new logic:

 old logic  new logic
---
log-writes device(DAX) log-writes device(DAX)
   |   |
PMEM0(DAX) + PMEM1(DAX)   Thin device(non-DAX) + PMEM1(DAX)
 |
   PMEM0(DAX)
---

We think dm-thin device is not a good solution for generic/470, is there 
any other solution to support both discard zero and DAX?


BTW, only log-writes, stripe and linear support DAX for now.

Best Regards,
Xiao Yang