[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200212041845.25879-12-willy@infradead.org>
Date: Tue, 11 Feb 2020 20:18:31 -0800
From: Matthew Wilcox <willy@...radead.org>
To: linux-fsdevel@...r.kernel.org, linux-mm@...ck.org
Cc: "Matthew Wilcox (Oracle)" <willy@...radead.org>,
linux-kernel@...r.kernel.org
Subject: [PATCH v2 11/25] fs: Make page_mkwrite_check_truncate thp-aware
From: "Matthew Wilcox (Oracle)" <willy@...radead.org>
If the page is compound, check the appropriate indices and return the
appropriate sizes.
Signed-off-by: Matthew Wilcox (Oracle) <willy@...radead.org>
---
include/linux/pagemap.h | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index aa925295347c..2ec33aabdbf6 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -732,17 +732,18 @@ static inline int page_mkwrite_check_truncate(struct page *page,
struct inode *inode)
{
loff_t size = i_size_read(inode);
- pgoff_t index = size >> PAGE_SHIFT;
- int offset = offset_in_page(size);
+ pgoff_t first_index = size >> PAGE_SHIFT;
+ pgoff_t last_index = first_index + hpage_nr_pages(page) - 1;
+ unsigned long offset = offset_in_this_page(page, size);
if (page->mapping != inode->i_mapping)
return -EFAULT;
/* page is wholly inside EOF */
- if (page->index < index)
- return PAGE_SIZE;
+ if (page->index < first_index)
+ return thp_size(page);
/* page is wholly past EOF */
- if (page->index > index || !offset)
+ if (page->index > last_index || !offset)
return -EFAULT;
/* page is partially inside EOF */
return offset;
--
2.25.0
Powered by blists - more mailing lists