Now that iput_final() arranges for dax_break_layouts(), all
truncate_inode_pages() paths in the kernel ensure that no DAX pages
hosted by that inode are in use. Add warnings to assert the new entry
state transitions.

Cc: Matthew Wilcox <[email protected]>
Cc: Jan Kara <[email protected]>
Cc: "Darrick J. Wong" <[email protected]>
Cc: Jason Gunthorpe <[email protected]>
Cc: Christoph Hellwig <[email protected]>
Cc: John Hubbard <[email protected]>
Cc: Dave Chinner <[email protected]>
Signed-off-by: Dan Williams <[email protected]>
---
 fs/dax.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/fs/dax.c b/fs/dax.c
index e3deb60a792f..1d4f0072e58d 100644
--- a/fs/dax.c
+++ b/fs/dax.c
@@ -401,13 +401,15 @@ static void dax_disassociate_entry(void *entry, struct 
address_space *mapping,
        for_each_mapped_pfn(entry, pfn) {
                struct page *page = pfn_to_page(pfn);
 
-               WARN_ON_ONCE(trunc && !dax_page_idle(page));
                if (dax_mapping_is_cow(page->mapping)) {
                        /* keep the CoW flag if this page is still shared */
                        if (page->index-- > 0)
                                continue;
-               } else
+               } else {
+                       WARN_ON_ONCE(trunc && !dax_is_zapped(entry));
+                       WARN_ON_ONCE(trunc && !dax_page_idle(page));
                        WARN_ON_ONCE(page->mapping && page->mapping != mapping);
+               }
                page->mapping = NULL;
                page->index = 0;
        }


Reply via email to