* [PATCH 00/10] Convert ecryptfs to use folios
@ 2024-10-17 15:16 Matthew Wilcox (Oracle)
2024-10-17 15:16 ` [PATCH 01/10] ecryptfs: Convert ecryptfs_writepage() to ecryptfs_writepages() Matthew Wilcox (Oracle)
` (9 more replies)
0 siblings, 10 replies; 20+ messages in thread
From: Matthew Wilcox (Oracle) @ 2024-10-17 15:16 UTC (permalink / raw)
To: Tyler Hicks
Cc: Matthew Wilcox (Oracle), ecryptfs, Christian Brauner,
linux-fsdevel
The next step in the folio project is to remove page->index. This
patchset does that for ecryptfs. As an unloved filesystem, I haven't
made any effort to support large folios; this is just "keep it working".
I have only compile tested this, but since it's a straightforward
conversion I'm not expecting any problems beyond my fat fingers.
Matthew Wilcox (Oracle) (10):
ecryptfs: Convert ecryptfs_writepage() to ecryptfs_writepages()
ecryptfs: Use a folio throughout ecryptfs_read_folio()
ecryptfs: Convert ecryptfs_copy_up_encrypted_with_header() to take a
folio
ecryptfs: Convert ecryptfs_read_lower_page_segment() to take a folio
ecryptfs: Convert ecryptfs_write() to use a folio
ecryptfs: Convert ecryptfs_write_lower_page_segment() to take a folio
ecryptfs: Convert ecryptfs_encrypt_page() to take a folio
ecryptfs: Convert ecryptfs_decrypt_page() to take a folio
ecryptfs: Convert lower_offset_for_page() to take a folio
ecryptfs: Pass the folio index to crypt_extent()
fs/ecryptfs/crypto.c | 30 ++++-----
fs/ecryptfs/ecryptfs_kernel.h | 9 ++-
fs/ecryptfs/mmap.c | 113 ++++++++++++++--------------------
fs/ecryptfs/read_write.c | 50 +++++++--------
4 files changed, 92 insertions(+), 110 deletions(-)
--
2.43.0
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH 01/10] ecryptfs: Convert ecryptfs_writepage() to ecryptfs_writepages()
2024-10-17 15:16 [PATCH 00/10] Convert ecryptfs to use folios Matthew Wilcox (Oracle)
@ 2024-10-17 15:16 ` Matthew Wilcox (Oracle)
2024-10-18 6:23 ` Pankaj Raghav (Samsung)
2024-10-17 15:16 ` [PATCH 02/10] ecryptfs: Use a folio throughout ecryptfs_read_folio() Matthew Wilcox (Oracle)
` (8 subsequent siblings)
9 siblings, 1 reply; 20+ messages in thread
From: Matthew Wilcox (Oracle) @ 2024-10-17 15:16 UTC (permalink / raw)
To: Tyler Hicks
Cc: Matthew Wilcox (Oracle), ecryptfs, Christian Brauner,
linux-fsdevel
By adding a ->migrate_folio implementation, theree is no need to keep
the ->writepage implementation. The new writepages removes the
unnecessary call to SetPageUptodate(); the folio should already be
uptodate at this point.
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
fs/ecryptfs/mmap.c | 41 ++++++++++++++++++++---------------------
1 file changed, 20 insertions(+), 21 deletions(-)
diff --git a/fs/ecryptfs/mmap.c b/fs/ecryptfs/mmap.c
index ceda5555971a..92ea39d907de 100644
--- a/fs/ecryptfs/mmap.c
+++ b/fs/ecryptfs/mmap.c
@@ -38,32 +38,30 @@ struct page *ecryptfs_get_locked_page(struct inode *inode, loff_t index)
return page;
}
-/**
- * ecryptfs_writepage
- * @page: Page that is locked before this call is made
- * @wbc: Write-back control structure
- *
- * Returns zero on success; non-zero otherwise
- *
+/*
* This is where we encrypt the data and pass the encrypted data to
* the lower filesystem. In OpenPGP-compatible mode, we operate on
* entire underlying packets.
*/
-static int ecryptfs_writepage(struct page *page, struct writeback_control *wbc)
+static int ecryptfs_writepages(struct address_space *mapping,
+ struct writeback_control *wbc)
{
- int rc;
-
- rc = ecryptfs_encrypt_page(page);
- if (rc) {
- ecryptfs_printk(KERN_WARNING, "Error encrypting "
- "page (upper index [0x%.16lx])\n", page->index);
- ClearPageUptodate(page);
- goto out;
+ struct folio *folio = NULL;
+ int error;
+
+ while ((folio = writeback_iter(mapping, wbc, folio, &error))) {
+ error = ecryptfs_encrypt_page(&folio->page);
+ if (error) {
+ ecryptfs_printk(KERN_WARNING,
+ "Error encrypting folio (index [0x%.16lx])\n",
+ folio->index);
+ folio_clear_uptodate(folio);
+ mapping_set_error(mapping, error);
+ }
+ folio_unlock(folio);
}
- SetPageUptodate(page);
-out:
- unlock_page(page);
- return rc;
+
+ return error;
}
static void strip_xattr_flag(char *page_virt,
@@ -548,9 +546,10 @@ const struct address_space_operations ecryptfs_aops = {
.dirty_folio = block_dirty_folio,
.invalidate_folio = block_invalidate_folio,
#endif
- .writepage = ecryptfs_writepage,
+ .writepages = ecryptfs_writepages,
.read_folio = ecryptfs_read_folio,
.write_begin = ecryptfs_write_begin,
.write_end = ecryptfs_write_end,
+ .migrate_folio = filemap_migrate_folio,
.bmap = ecryptfs_bmap,
};
--
2.43.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 02/10] ecryptfs: Use a folio throughout ecryptfs_read_folio()
2024-10-17 15:16 [PATCH 00/10] Convert ecryptfs to use folios Matthew Wilcox (Oracle)
2024-10-17 15:16 ` [PATCH 01/10] ecryptfs: Convert ecryptfs_writepage() to ecryptfs_writepages() Matthew Wilcox (Oracle)
@ 2024-10-17 15:16 ` Matthew Wilcox (Oracle)
2024-10-18 6:21 ` Pankaj Raghav (Samsung)
2024-10-17 15:16 ` [PATCH 03/10] ecryptfs: Convert ecryptfs_copy_up_encrypted_with_header() to take a folio Matthew Wilcox (Oracle)
` (7 subsequent siblings)
9 siblings, 1 reply; 20+ messages in thread
From: Matthew Wilcox (Oracle) @ 2024-10-17 15:16 UTC (permalink / raw)
To: Tyler Hicks
Cc: Matthew Wilcox (Oracle), ecryptfs, Christian Brauner,
linux-fsdevel
Remove the conversion to a struct page. Removes a few hidden calls to
compound_head().
Also remove the unnecessary call to ClearPageUptodate(); the uptodate
flag is already clear if this function is being called.
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
fs/ecryptfs/mmap.c | 30 ++++++++++++++----------------
1 file changed, 14 insertions(+), 16 deletions(-)
diff --git a/fs/ecryptfs/mmap.c b/fs/ecryptfs/mmap.c
index 92ea39d907de..346ed5f7ff8d 100644
--- a/fs/ecryptfs/mmap.c
+++ b/fs/ecryptfs/mmap.c
@@ -178,18 +178,18 @@ ecryptfs_copy_up_encrypted_with_header(struct page *page,
*/
static int ecryptfs_read_folio(struct file *file, struct folio *folio)
{
- struct page *page = &folio->page;
+ struct inode *inode = folio->mapping->host;
struct ecryptfs_crypt_stat *crypt_stat =
- &ecryptfs_inode_to_private(page->mapping->host)->crypt_stat;
+ &ecryptfs_inode_to_private(inode)->crypt_stat;
int rc = 0;
if (!crypt_stat || !(crypt_stat->flags & ECRYPTFS_ENCRYPTED)) {
- rc = ecryptfs_read_lower_page_segment(page, page->index, 0,
- PAGE_SIZE,
- page->mapping->host);
+ rc = ecryptfs_read_lower_page_segment(&folio->page, folio->index, 0,
+ folio_size(folio),
+ inode);
} else if (crypt_stat->flags & ECRYPTFS_VIEW_AS_ENCRYPTED) {
if (crypt_stat->flags & ECRYPTFS_METADATA_IN_XATTR) {
- rc = ecryptfs_copy_up_encrypted_with_header(page,
+ rc = ecryptfs_copy_up_encrypted_with_header(&folio->page,
crypt_stat);
if (rc) {
printk(KERN_ERR "%s: Error attempting to copy "
@@ -201,9 +201,9 @@ static int ecryptfs_read_folio(struct file *file, struct folio *folio)
}
} else {
- rc = ecryptfs_read_lower_page_segment(
- page, page->index, 0, PAGE_SIZE,
- page->mapping->host);
+ rc = ecryptfs_read_lower_page_segment(&folio->page,
+ folio->index, 0, folio_size(folio),
+ inode);
if (rc) {
printk(KERN_ERR "Error reading page; rc = "
"[%d]\n", rc);
@@ -211,7 +211,7 @@ static int ecryptfs_read_folio(struct file *file, struct folio *folio)
}
}
} else {
- rc = ecryptfs_decrypt_page(page);
+ rc = ecryptfs_decrypt_page(&folio->page);
if (rc) {
ecryptfs_printk(KERN_ERR, "Error decrypting page; "
"rc = [%d]\n", rc);
@@ -219,13 +219,11 @@ static int ecryptfs_read_folio(struct file *file, struct folio *folio)
}
}
out:
- if (rc)
- ClearPageUptodate(page);
- else
- SetPageUptodate(page);
+ if (!rc)
+ folio_mark_uptodate(folio);
ecryptfs_printk(KERN_DEBUG, "Unlocking page with index = [0x%.16lx]\n",
- page->index);
- unlock_page(page);
+ folio->index);
+ folio_unlock(folio);
return rc;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 03/10] ecryptfs: Convert ecryptfs_copy_up_encrypted_with_header() to take a folio
2024-10-17 15:16 [PATCH 00/10] Convert ecryptfs to use folios Matthew Wilcox (Oracle)
2024-10-17 15:16 ` [PATCH 01/10] ecryptfs: Convert ecryptfs_writepage() to ecryptfs_writepages() Matthew Wilcox (Oracle)
2024-10-17 15:16 ` [PATCH 02/10] ecryptfs: Use a folio throughout ecryptfs_read_folio() Matthew Wilcox (Oracle)
@ 2024-10-17 15:16 ` Matthew Wilcox (Oracle)
2024-10-18 3:43 ` kernel test robot
2024-10-18 6:33 ` Pankaj Raghav (Samsung)
2024-10-17 15:16 ` [PATCH 04/10] ecryptfs: Convert ecryptfs_read_lower_page_segment() " Matthew Wilcox (Oracle)
` (6 subsequent siblings)
9 siblings, 2 replies; 20+ messages in thread
From: Matthew Wilcox (Oracle) @ 2024-10-17 15:16 UTC (permalink / raw)
To: Tyler Hicks
Cc: Matthew Wilcox (Oracle), ecryptfs, Christian Brauner,
linux-fsdevel
Both callers have a folio, so pass it in and use it throughout.
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
fs/ecryptfs/mmap.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/fs/ecryptfs/mmap.c b/fs/ecryptfs/mmap.c
index 346ed5f7ff8d..f7525a906ef7 100644
--- a/fs/ecryptfs/mmap.c
+++ b/fs/ecryptfs/mmap.c
@@ -104,7 +104,7 @@ static void strip_xattr_flag(char *page_virt,
* seeing, with the header information inserted.
*/
static int
-ecryptfs_copy_up_encrypted_with_header(struct page *page,
+ecryptfs_copy_up_encrypted_with_header(struct folio *folio,
struct ecryptfs_crypt_stat *crypt_stat)
{
loff_t extent_num_in_page = 0;
@@ -113,9 +113,9 @@ ecryptfs_copy_up_encrypted_with_header(struct page *page,
int rc = 0;
while (extent_num_in_page < num_extents_per_page) {
- loff_t view_extent_num = ((((loff_t)page->index)
+ loff_t view_extent_num = ((loff_t)folio->index
* num_extents_per_page)
- + extent_num_in_page);
+ + extent_num_in_page;
size_t num_header_extents_at_front =
(crypt_stat->metadata_size / crypt_stat->extent_size);
@@ -123,21 +123,21 @@ ecryptfs_copy_up_encrypted_with_header(struct page *page,
/* This is a header extent */
char *page_virt;
- page_virt = kmap_local_page(page);
+ page_virt = kmap_local_folio(folio, 0);
memset(page_virt, 0, PAGE_SIZE);
/* TODO: Support more than one header extent */
if (view_extent_num == 0) {
size_t written;
rc = ecryptfs_read_xattr_region(
- page_virt, page->mapping->host);
+ page_virt, folio->mapping->host);
strip_xattr_flag(page_virt + 16, crypt_stat);
ecryptfs_write_header_metadata(page_virt + 20,
crypt_stat,
&written);
}
kunmap_local(page_virt);
- flush_dcache_page(page);
+ flush_dcache_folio(folio);
if (rc) {
printk(KERN_ERR "%s: Error reading xattr "
"region; rc = [%d]\n", __func__, rc);
@@ -150,9 +150,9 @@ ecryptfs_copy_up_encrypted_with_header(struct page *page,
- crypt_stat->metadata_size);
rc = ecryptfs_read_lower_page_segment(
- page, (lower_offset >> PAGE_SHIFT),
+ &folio->page, (lower_offset >> PAGE_SHIFT),
(lower_offset & ~PAGE_MASK),
- crypt_stat->extent_size, page->mapping->host);
+ crypt_stat->extent_size, folio->mapping->host);
if (rc) {
printk(KERN_ERR "%s: Error attempting to read "
"extent at offset [%lld] in the lower "
@@ -189,7 +189,7 @@ static int ecryptfs_read_folio(struct file *file, struct folio *folio)
inode);
} else if (crypt_stat->flags & ECRYPTFS_VIEW_AS_ENCRYPTED) {
if (crypt_stat->flags & ECRYPTFS_METADATA_IN_XATTR) {
- rc = ecryptfs_copy_up_encrypted_with_header(&folio->page,
+ rc = ecryptfs_copy_up_encrypted_with_header(folio,
crypt_stat);
if (rc) {
printk(KERN_ERR "%s: Error attempting to copy "
@@ -293,7 +293,7 @@ static int ecryptfs_write_begin(struct file *file,
} else if (crypt_stat->flags & ECRYPTFS_VIEW_AS_ENCRYPTED) {
if (crypt_stat->flags & ECRYPTFS_METADATA_IN_XATTR) {
rc = ecryptfs_copy_up_encrypted_with_header(
- &folio->page, crypt_stat);
+ folio, crypt_stat);
if (rc) {
printk(KERN_ERR "%s: Error attempting "
"to copy the encrypted content "
--
2.43.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 04/10] ecryptfs: Convert ecryptfs_read_lower_page_segment() to take a folio
2024-10-17 15:16 [PATCH 00/10] Convert ecryptfs to use folios Matthew Wilcox (Oracle)
` (2 preceding siblings ...)
2024-10-17 15:16 ` [PATCH 03/10] ecryptfs: Convert ecryptfs_copy_up_encrypted_with_header() to take a folio Matthew Wilcox (Oracle)
@ 2024-10-17 15:16 ` Matthew Wilcox (Oracle)
2024-10-17 15:17 ` [PATCH 05/10] ecryptfs: Convert ecryptfs_write() to use " Matthew Wilcox (Oracle)
` (5 subsequent siblings)
9 siblings, 0 replies; 20+ messages in thread
From: Matthew Wilcox (Oracle) @ 2024-10-17 15:16 UTC (permalink / raw)
To: Tyler Hicks
Cc: Matthew Wilcox (Oracle), ecryptfs, Christian Brauner,
linux-fsdevel
All callers have a folio, so pass it in and use it directly. This will
not work for large folios, but I doubt anybody wants to use large folios
with ecryptfs.
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
fs/ecryptfs/ecryptfs_kernel.h | 2 +-
fs/ecryptfs/mmap.c | 10 +++++-----
fs/ecryptfs/read_write.c | 10 +++++-----
3 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/fs/ecryptfs/ecryptfs_kernel.h b/fs/ecryptfs/ecryptfs_kernel.h
index c586c5db18b5..43f1b5ff987d 100644
--- a/fs/ecryptfs/ecryptfs_kernel.h
+++ b/fs/ecryptfs/ecryptfs_kernel.h
@@ -658,7 +658,7 @@ int ecryptfs_write_lower_page_segment(struct inode *ecryptfs_inode,
int ecryptfs_write(struct inode *inode, char *data, loff_t offset, size_t size);
int ecryptfs_read_lower(char *data, loff_t offset, size_t size,
struct inode *ecryptfs_inode);
-int ecryptfs_read_lower_page_segment(struct page *page_for_ecryptfs,
+int ecryptfs_read_lower_page_segment(struct folio *folio_for_ecryptfs,
pgoff_t page_index,
size_t offset_in_page, size_t size,
struct inode *ecryptfs_inode);
diff --git a/fs/ecryptfs/mmap.c b/fs/ecryptfs/mmap.c
index f7525a906ef7..b7ef0bf563bd 100644
--- a/fs/ecryptfs/mmap.c
+++ b/fs/ecryptfs/mmap.c
@@ -150,7 +150,7 @@ ecryptfs_copy_up_encrypted_with_header(struct folio *folio,
- crypt_stat->metadata_size);
rc = ecryptfs_read_lower_page_segment(
- &folio->page, (lower_offset >> PAGE_SHIFT),
+ folio, (lower_offset >> PAGE_SHIFT),
(lower_offset & ~PAGE_MASK),
crypt_stat->extent_size, folio->mapping->host);
if (rc) {
@@ -184,7 +184,7 @@ static int ecryptfs_read_folio(struct file *file, struct folio *folio)
int rc = 0;
if (!crypt_stat || !(crypt_stat->flags & ECRYPTFS_ENCRYPTED)) {
- rc = ecryptfs_read_lower_page_segment(&folio->page, folio->index, 0,
+ rc = ecryptfs_read_lower_page_segment(folio, folio->index, 0,
folio_size(folio),
inode);
} else if (crypt_stat->flags & ECRYPTFS_VIEW_AS_ENCRYPTED) {
@@ -201,7 +201,7 @@ static int ecryptfs_read_folio(struct file *file, struct folio *folio)
}
} else {
- rc = ecryptfs_read_lower_page_segment(&folio->page,
+ rc = ecryptfs_read_lower_page_segment(folio,
folio->index, 0, folio_size(folio),
inode);
if (rc) {
@@ -281,7 +281,7 @@ static int ecryptfs_write_begin(struct file *file,
if (!(crypt_stat->flags & ECRYPTFS_ENCRYPTED)) {
rc = ecryptfs_read_lower_page_segment(
- &folio->page, index, 0, PAGE_SIZE, mapping->host);
+ folio, index, 0, PAGE_SIZE, mapping->host);
if (rc) {
printk(KERN_ERR "%s: Error attempting to read "
"lower page segment; rc = [%d]\n",
@@ -307,7 +307,7 @@ static int ecryptfs_write_begin(struct file *file,
folio_mark_uptodate(folio);
} else {
rc = ecryptfs_read_lower_page_segment(
- &folio->page, index, 0, PAGE_SIZE,
+ folio, index, 0, PAGE_SIZE,
mapping->host);
if (rc) {
printk(KERN_ERR "%s: Error reading "
diff --git a/fs/ecryptfs/read_write.c b/fs/ecryptfs/read_write.c
index 3458f153a588..251e9f6c6972 100644
--- a/fs/ecryptfs/read_write.c
+++ b/fs/ecryptfs/read_write.c
@@ -228,7 +228,7 @@ int ecryptfs_read_lower(char *data, loff_t offset, size_t size,
/**
* ecryptfs_read_lower_page_segment
- * @page_for_ecryptfs: The page into which data for eCryptfs will be
+ * @folio_for_ecryptfs: The folio into which data for eCryptfs will be
* written
* @page_index: Page index in @page_for_ecryptfs from which to start
* writing
@@ -243,7 +243,7 @@ int ecryptfs_read_lower(char *data, loff_t offset, size_t size,
*
* Returns zero on success; non-zero otherwise
*/
-int ecryptfs_read_lower_page_segment(struct page *page_for_ecryptfs,
+int ecryptfs_read_lower_page_segment(struct folio *folio_for_ecryptfs,
pgoff_t page_index,
size_t offset_in_page, size_t size,
struct inode *ecryptfs_inode)
@@ -252,12 +252,12 @@ int ecryptfs_read_lower_page_segment(struct page *page_for_ecryptfs,
loff_t offset;
int rc;
- offset = ((((loff_t)page_index) << PAGE_SHIFT) + offset_in_page);
- virt = kmap_local_page(page_for_ecryptfs);
+ offset = (loff_t)page_index * PAGE_SIZE + offset_in_page;
+ virt = kmap_local_folio(folio_for_ecryptfs, 0);
rc = ecryptfs_read_lower(virt, offset, size, ecryptfs_inode);
if (rc > 0)
rc = 0;
kunmap_local(virt);
- flush_dcache_page(page_for_ecryptfs);
+ flush_dcache_folio(folio_for_ecryptfs);
return rc;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 05/10] ecryptfs: Convert ecryptfs_write() to use a folio
2024-10-17 15:16 [PATCH 00/10] Convert ecryptfs to use folios Matthew Wilcox (Oracle)
` (3 preceding siblings ...)
2024-10-17 15:16 ` [PATCH 04/10] ecryptfs: Convert ecryptfs_read_lower_page_segment() " Matthew Wilcox (Oracle)
@ 2024-10-17 15:17 ` Matthew Wilcox (Oracle)
2024-10-18 8:07 ` Pankaj Raghav (Samsung)
2024-10-17 15:17 ` [PATCH 06/10] ecryptfs: Convert ecryptfs_write_lower_page_segment() to take " Matthew Wilcox (Oracle)
` (4 subsequent siblings)
9 siblings, 1 reply; 20+ messages in thread
From: Matthew Wilcox (Oracle) @ 2024-10-17 15:17 UTC (permalink / raw)
To: Tyler Hicks
Cc: Matthew Wilcox (Oracle), ecryptfs, Christian Brauner,
linux-fsdevel
Remove ecryptfs_get_locked_page() and call read_mapping_folio()
directly. Use the folio throught this function.
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
fs/ecryptfs/ecryptfs_kernel.h | 1 -
fs/ecryptfs/mmap.c | 16 ----------------
fs/ecryptfs/read_write.c | 25 +++++++++++++------------
3 files changed, 13 insertions(+), 29 deletions(-)
diff --git a/fs/ecryptfs/ecryptfs_kernel.h b/fs/ecryptfs/ecryptfs_kernel.h
index 43f1b5ff987d..f04aa24f6bcd 100644
--- a/fs/ecryptfs/ecryptfs_kernel.h
+++ b/fs/ecryptfs/ecryptfs_kernel.h
@@ -662,7 +662,6 @@ int ecryptfs_read_lower_page_segment(struct folio *folio_for_ecryptfs,
pgoff_t page_index,
size_t offset_in_page, size_t size,
struct inode *ecryptfs_inode);
-struct page *ecryptfs_get_locked_page(struct inode *inode, loff_t index);
int ecryptfs_parse_packet_length(unsigned char *data, size_t *size,
size_t *length_size);
int ecryptfs_write_packet_length(char *dest, size_t size,
diff --git a/fs/ecryptfs/mmap.c b/fs/ecryptfs/mmap.c
index b7ef0bf563bd..ad535bf9d2f9 100644
--- a/fs/ecryptfs/mmap.c
+++ b/fs/ecryptfs/mmap.c
@@ -22,22 +22,6 @@
#include <linux/unaligned.h>
#include "ecryptfs_kernel.h"
-/*
- * ecryptfs_get_locked_page
- *
- * Get one page from cache or lower f/s, return error otherwise.
- *
- * Returns locked and up-to-date page (if ok), with increased
- * refcnt.
- */
-struct page *ecryptfs_get_locked_page(struct inode *inode, loff_t index)
-{
- struct page *page = read_mapping_page(inode->i_mapping, index, NULL);
- if (!IS_ERR(page))
- lock_page(page);
- return page;
-}
-
/*
* This is where we encrypt the data and pass the encrypted data to
* the lower filesystem. In OpenPGP-compatible mode, we operate on
diff --git a/fs/ecryptfs/read_write.c b/fs/ecryptfs/read_write.c
index 251e9f6c6972..cddfdfced879 100644
--- a/fs/ecryptfs/read_write.c
+++ b/fs/ecryptfs/read_write.c
@@ -93,7 +93,6 @@ int ecryptfs_write_lower_page_segment(struct inode *ecryptfs_inode,
int ecryptfs_write(struct inode *ecryptfs_inode, char *data, loff_t offset,
size_t size)
{
- struct page *ecryptfs_page;
struct ecryptfs_crypt_stat *crypt_stat;
char *ecryptfs_page_virt;
loff_t ecryptfs_file_size = i_size_read(ecryptfs_inode);
@@ -111,6 +110,7 @@ int ecryptfs_write(struct inode *ecryptfs_inode, char *data, loff_t offset,
else
pos = offset;
while (pos < (offset + size)) {
+ struct folio *ecryptfs_folio;
pgoff_t ecryptfs_page_idx = (pos >> PAGE_SHIFT);
size_t start_offset_in_page = (pos & ~PAGE_MASK);
size_t num_bytes = (PAGE_SIZE - start_offset_in_page);
@@ -130,17 +130,18 @@ int ecryptfs_write(struct inode *ecryptfs_inode, char *data, loff_t offset,
if (num_bytes > total_remaining_zeros)
num_bytes = total_remaining_zeros;
}
- ecryptfs_page = ecryptfs_get_locked_page(ecryptfs_inode,
- ecryptfs_page_idx);
- if (IS_ERR(ecryptfs_page)) {
- rc = PTR_ERR(ecryptfs_page);
+ ecryptfs_folio = read_mapping_folio(ecryptfs_inode->i_mapping,
+ ecryptfs_page_idx, NULL);
+ if (IS_ERR(ecryptfs_folio)) {
+ rc = PTR_ERR(ecryptfs_folio);
printk(KERN_ERR "%s: Error getting page at "
"index [%ld] from eCryptfs inode "
"mapping; rc = [%d]\n", __func__,
ecryptfs_page_idx, rc);
goto out;
}
- ecryptfs_page_virt = kmap_local_page(ecryptfs_page);
+ folio_lock(ecryptfs_folio);
+ ecryptfs_page_virt = kmap_local_folio(ecryptfs_folio, 0);
/*
* pos: where we're now writing, offset: where the request was
@@ -164,17 +165,17 @@ int ecryptfs_write(struct inode *ecryptfs_inode, char *data, loff_t offset,
data_offset += num_bytes;
}
kunmap_local(ecryptfs_page_virt);
- flush_dcache_page(ecryptfs_page);
- SetPageUptodate(ecryptfs_page);
- unlock_page(ecryptfs_page);
+ flush_dcache_folio(ecryptfs_folio);
+ folio_mark_uptodate(ecryptfs_folio);
+ folio_unlock(ecryptfs_folio);
if (crypt_stat->flags & ECRYPTFS_ENCRYPTED)
- rc = ecryptfs_encrypt_page(ecryptfs_page);
+ rc = ecryptfs_encrypt_page(&ecryptfs_folio->page);
else
rc = ecryptfs_write_lower_page_segment(ecryptfs_inode,
- ecryptfs_page,
+ &ecryptfs_folio->page,
start_offset_in_page,
data_offset);
- put_page(ecryptfs_page);
+ folio_put(ecryptfs_folio);
if (rc) {
printk(KERN_ERR "%s: Error encrypting "
"page; rc = [%d]\n", __func__, rc);
--
2.43.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 06/10] ecryptfs: Convert ecryptfs_write_lower_page_segment() to take a folio
2024-10-17 15:16 [PATCH 00/10] Convert ecryptfs to use folios Matthew Wilcox (Oracle)
` (4 preceding siblings ...)
2024-10-17 15:17 ` [PATCH 05/10] ecryptfs: Convert ecryptfs_write() to use " Matthew Wilcox (Oracle)
@ 2024-10-17 15:17 ` Matthew Wilcox (Oracle)
2024-10-17 15:17 ` [PATCH 07/10] ecryptfs: Convert ecryptfs_encrypt_page() " Matthew Wilcox (Oracle)
` (3 subsequent siblings)
9 siblings, 0 replies; 20+ messages in thread
From: Matthew Wilcox (Oracle) @ 2024-10-17 15:17 UTC (permalink / raw)
To: Tyler Hicks
Cc: Matthew Wilcox (Oracle), ecryptfs, Christian Brauner,
linux-fsdevel
Both callers now have a folio, so pass it in and use it throughout.
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
fs/ecryptfs/ecryptfs_kernel.h | 2 +-
fs/ecryptfs/mmap.c | 2 +-
fs/ecryptfs/read_write.c | 17 ++++++++---------
3 files changed, 10 insertions(+), 11 deletions(-)
diff --git a/fs/ecryptfs/ecryptfs_kernel.h b/fs/ecryptfs/ecryptfs_kernel.h
index f04aa24f6bcd..0cac8d3155ae 100644
--- a/fs/ecryptfs/ecryptfs_kernel.h
+++ b/fs/ecryptfs/ecryptfs_kernel.h
@@ -653,7 +653,7 @@ int ecryptfs_keyring_auth_tok_for_sig(struct key **auth_tok_key,
int ecryptfs_write_lower(struct inode *ecryptfs_inode, char *data,
loff_t offset, size_t size);
int ecryptfs_write_lower_page_segment(struct inode *ecryptfs_inode,
- struct page *page_for_lower,
+ struct folio *folio_for_lower,
size_t offset_in_page, size_t size);
int ecryptfs_write(struct inode *inode, char *data, loff_t offset, size_t size);
int ecryptfs_read_lower(char *data, loff_t offset, size_t size,
diff --git a/fs/ecryptfs/mmap.c b/fs/ecryptfs/mmap.c
index ad535bf9d2f9..acbef67d9c85 100644
--- a/fs/ecryptfs/mmap.c
+++ b/fs/ecryptfs/mmap.c
@@ -457,7 +457,7 @@ static int ecryptfs_write_end(struct file *file,
"(page w/ index = [0x%.16lx], to = [%d])\n", index, to);
if (!(crypt_stat->flags & ECRYPTFS_ENCRYPTED)) {
rc = ecryptfs_write_lower_page_segment(ecryptfs_inode,
- &folio->page, 0, to);
+ folio, 0, to);
if (!rc) {
rc = copied;
fsstack_copy_inode_size(ecryptfs_inode,
diff --git a/fs/ecryptfs/read_write.c b/fs/ecryptfs/read_write.c
index cddfdfced879..665bcd7d1c8e 100644
--- a/fs/ecryptfs/read_write.c
+++ b/fs/ecryptfs/read_write.c
@@ -41,30 +41,29 @@ int ecryptfs_write_lower(struct inode *ecryptfs_inode, char *data,
/**
* ecryptfs_write_lower_page_segment
* @ecryptfs_inode: The eCryptfs inode
- * @page_for_lower: The page containing the data to be written to the
+ * @folio_for_lower: The folio containing the data to be written to the
* lower file
- * @offset_in_page: The offset in the @page_for_lower from which to
+ * @offset_in_page: The offset in the @folio_for_lower from which to
* start writing the data
- * @size: The amount of data from @page_for_lower to write to the
+ * @size: The amount of data from @folio_for_lower to write to the
* lower file
*
* Determines the byte offset in the file for the given page and
* offset within the page, maps the page, and makes the call to write
- * the contents of @page_for_lower to the lower inode.
+ * the contents of @folio_for_lower to the lower inode.
*
* Returns zero on success; non-zero otherwise
*/
int ecryptfs_write_lower_page_segment(struct inode *ecryptfs_inode,
- struct page *page_for_lower,
+ struct folio *folio_for_lower,
size_t offset_in_page, size_t size)
{
char *virt;
loff_t offset;
int rc;
- offset = ((((loff_t)page_for_lower->index) << PAGE_SHIFT)
- + offset_in_page);
- virt = kmap_local_page(page_for_lower);
+ offset = (loff_t)folio_for_lower->index * PAGE_SIZE + offset_in_page;
+ virt = kmap_local_folio(folio_for_lower, 0);
rc = ecryptfs_write_lower(ecryptfs_inode, virt, offset, size);
if (rc > 0)
rc = 0;
@@ -172,7 +171,7 @@ int ecryptfs_write(struct inode *ecryptfs_inode, char *data, loff_t offset,
rc = ecryptfs_encrypt_page(&ecryptfs_folio->page);
else
rc = ecryptfs_write_lower_page_segment(ecryptfs_inode,
- &ecryptfs_folio->page,
+ ecryptfs_folio,
start_offset_in_page,
data_offset);
folio_put(ecryptfs_folio);
--
2.43.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 07/10] ecryptfs: Convert ecryptfs_encrypt_page() to take a folio
2024-10-17 15:16 [PATCH 00/10] Convert ecryptfs to use folios Matthew Wilcox (Oracle)
` (5 preceding siblings ...)
2024-10-17 15:17 ` [PATCH 06/10] ecryptfs: Convert ecryptfs_write_lower_page_segment() to take " Matthew Wilcox (Oracle)
@ 2024-10-17 15:17 ` Matthew Wilcox (Oracle)
2024-10-18 5:06 ` kernel test robot
2024-10-17 15:17 ` [PATCH 08/10] ecryptfs: Convert ecryptfs_decrypt_page() " Matthew Wilcox (Oracle)
` (2 subsequent siblings)
9 siblings, 1 reply; 20+ messages in thread
From: Matthew Wilcox (Oracle) @ 2024-10-17 15:17 UTC (permalink / raw)
To: Tyler Hicks
Cc: Matthew Wilcox (Oracle), ecryptfs, Christian Brauner,
linux-fsdevel
All three callers have a folio, so pass it in and use it throughout.
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
fs/ecryptfs/crypto.c | 10 +++++-----
fs/ecryptfs/ecryptfs_kernel.h | 2 +-
fs/ecryptfs/mmap.c | 4 ++--
fs/ecryptfs/read_write.c | 2 +-
4 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/fs/ecryptfs/crypto.c b/fs/ecryptfs/crypto.c
index 827278525fd9..424233177b43 100644
--- a/fs/ecryptfs/crypto.c
+++ b/fs/ecryptfs/crypto.c
@@ -406,7 +406,7 @@ static int crypt_extent(struct ecryptfs_crypt_stat *crypt_stat,
*
* Returns zero on success; negative on error
*/
-int ecryptfs_encrypt_page(struct page *page)
+int ecryptfs_encrypt_page(struct folio *folio)
{
struct inode *ecryptfs_inode;
struct ecryptfs_crypt_stat *crypt_stat;
@@ -416,7 +416,7 @@ int ecryptfs_encrypt_page(struct page *page)
loff_t lower_offset;
int rc = 0;
- ecryptfs_inode = page->mapping->host;
+ ecryptfs_inode = folio->mapping->host;
crypt_stat =
&(ecryptfs_inode_to_private(ecryptfs_inode)->crypt_stat);
BUG_ON(!(crypt_stat->flags & ECRYPTFS_ENCRYPTED));
@@ -431,8 +431,8 @@ int ecryptfs_encrypt_page(struct page *page)
for (extent_offset = 0;
extent_offset < (PAGE_SIZE / crypt_stat->extent_size);
extent_offset++) {
- rc = crypt_extent(crypt_stat, enc_extent_page, page,
- extent_offset, ENCRYPT);
+ rc = crypt_extent(crypt_stat, enc_extent_page,
+ folio_page(folio, 0), extent_offset, ENCRYPT);
if (rc) {
printk(KERN_ERR "%s: Error encrypting extent; "
"rc = [%d]\n", __func__, rc);
@@ -440,7 +440,7 @@ int ecryptfs_encrypt_page(struct page *page)
}
}
- lower_offset = lower_offset_for_page(crypt_stat, page);
+ lower_offset = lower_offset_for_page(crypt_stat, &folio->page);
enc_extent_virt = kmap_local_page(enc_extent_page);
rc = ecryptfs_write_lower(ecryptfs_inode, enc_extent_virt, lower_offset,
PAGE_SIZE);
diff --git a/fs/ecryptfs/ecryptfs_kernel.h b/fs/ecryptfs/ecryptfs_kernel.h
index 0cac8d3155ae..bffced0c1d8f 100644
--- a/fs/ecryptfs/ecryptfs_kernel.h
+++ b/fs/ecryptfs/ecryptfs_kernel.h
@@ -569,7 +569,7 @@ void ecryptfs_destroy_mount_crypt_stat(
struct ecryptfs_mount_crypt_stat *mount_crypt_stat);
int ecryptfs_init_crypt_ctx(struct ecryptfs_crypt_stat *crypt_stat);
int ecryptfs_write_inode_size_to_metadata(struct inode *ecryptfs_inode);
-int ecryptfs_encrypt_page(struct page *page);
+int ecryptfs_encrypt_page(struct folio *folio);
int ecryptfs_decrypt_page(struct page *page);
int ecryptfs_write_metadata(struct dentry *ecryptfs_dentry,
struct inode *ecryptfs_inode);
diff --git a/fs/ecryptfs/mmap.c b/fs/ecryptfs/mmap.c
index acbef67d9c85..1bf46d2c6a82 100644
--- a/fs/ecryptfs/mmap.c
+++ b/fs/ecryptfs/mmap.c
@@ -34,7 +34,7 @@ static int ecryptfs_writepages(struct address_space *mapping,
int error;
while ((folio = writeback_iter(mapping, wbc, folio, &error))) {
- error = ecryptfs_encrypt_page(&folio->page);
+ error = ecryptfs_encrypt_page(folio);
if (error) {
ecryptfs_printk(KERN_WARNING,
"Error encrypting folio (index [0x%.16lx])\n",
@@ -479,7 +479,7 @@ static int ecryptfs_write_end(struct file *file,
"zeros in page with index = [0x%.16lx]\n", index);
goto out;
}
- rc = ecryptfs_encrypt_page(&folio->page);
+ rc = ecryptfs_encrypt_page(folio);
if (rc) {
ecryptfs_printk(KERN_WARNING, "Error encrypting page (upper "
"index [0x%.16lx])\n", index);
diff --git a/fs/ecryptfs/read_write.c b/fs/ecryptfs/read_write.c
index 665bcd7d1c8e..b3b451c2b941 100644
--- a/fs/ecryptfs/read_write.c
+++ b/fs/ecryptfs/read_write.c
@@ -168,7 +168,7 @@ int ecryptfs_write(struct inode *ecryptfs_inode, char *data, loff_t offset,
folio_mark_uptodate(ecryptfs_folio);
folio_unlock(ecryptfs_folio);
if (crypt_stat->flags & ECRYPTFS_ENCRYPTED)
- rc = ecryptfs_encrypt_page(&ecryptfs_folio->page);
+ rc = ecryptfs_encrypt_page(ecryptfs_folio);
else
rc = ecryptfs_write_lower_page_segment(ecryptfs_inode,
ecryptfs_folio,
--
2.43.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 08/10] ecryptfs: Convert ecryptfs_decrypt_page() to take a folio
2024-10-17 15:16 [PATCH 00/10] Convert ecryptfs to use folios Matthew Wilcox (Oracle)
` (6 preceding siblings ...)
2024-10-17 15:17 ` [PATCH 07/10] ecryptfs: Convert ecryptfs_encrypt_page() " Matthew Wilcox (Oracle)
@ 2024-10-17 15:17 ` Matthew Wilcox (Oracle)
2024-10-18 6:39 ` kernel test robot
2024-10-17 15:17 ` [PATCH 09/10] ecryptfs: Convert lower_offset_for_page() " Matthew Wilcox (Oracle)
2024-10-17 15:17 ` [PATCH 10/10] ecryptfs: Pass the folio index to crypt_extent() Matthew Wilcox (Oracle)
9 siblings, 1 reply; 20+ messages in thread
From: Matthew Wilcox (Oracle) @ 2024-10-17 15:17 UTC (permalink / raw)
To: Tyler Hicks
Cc: Matthew Wilcox (Oracle), ecryptfs, Christian Brauner,
linux-fsdevel
Both callers have a folio, so pass it in and use it throughout.
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
fs/ecryptfs/crypto.c | 9 +++++----
fs/ecryptfs/ecryptfs_kernel.h | 2 +-
fs/ecryptfs/mmap.c | 4 ++--
3 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/fs/ecryptfs/crypto.c b/fs/ecryptfs/crypto.c
index 424233177b43..02bccaa7c666 100644
--- a/fs/ecryptfs/crypto.c
+++ b/fs/ecryptfs/crypto.c
@@ -475,7 +475,7 @@ int ecryptfs_encrypt_page(struct folio *folio)
*
* Returns zero on success; negative on error
*/
-int ecryptfs_decrypt_page(struct page *page)
+int ecryptfs_decrypt_page(struct folio *folio)
{
struct inode *ecryptfs_inode;
struct ecryptfs_crypt_stat *crypt_stat;
@@ -484,13 +484,13 @@ int ecryptfs_decrypt_page(struct page *page)
loff_t lower_offset;
int rc = 0;
- ecryptfs_inode = page->mapping->host;
+ ecryptfs_inode = folio->mapping->host;
crypt_stat =
&(ecryptfs_inode_to_private(ecryptfs_inode)->crypt_stat);
BUG_ON(!(crypt_stat->flags & ECRYPTFS_ENCRYPTED));
- lower_offset = lower_offset_for_page(crypt_stat, page);
- page_virt = kmap_local_page(page);
+ lower_offset = lower_offset_for_page(crypt_stat, &folio->page);
+ page_virt = kmap_local_folio(folio, 0);
rc = ecryptfs_read_lower(page_virt, lower_offset, PAGE_SIZE,
ecryptfs_inode);
kunmap_local(page_virt);
@@ -504,6 +504,7 @@ int ecryptfs_decrypt_page(struct page *page)
for (extent_offset = 0;
extent_offset < (PAGE_SIZE / crypt_stat->extent_size);
extent_offset++) {
+ struct page *page = folio_page(folio, 0);
rc = crypt_extent(crypt_stat, page, page,
extent_offset, DECRYPT);
if (rc) {
diff --git a/fs/ecryptfs/ecryptfs_kernel.h b/fs/ecryptfs/ecryptfs_kernel.h
index bffced0c1d8f..1f562e75d0e4 100644
--- a/fs/ecryptfs/ecryptfs_kernel.h
+++ b/fs/ecryptfs/ecryptfs_kernel.h
@@ -570,7 +570,7 @@ void ecryptfs_destroy_mount_crypt_stat(
int ecryptfs_init_crypt_ctx(struct ecryptfs_crypt_stat *crypt_stat);
int ecryptfs_write_inode_size_to_metadata(struct inode *ecryptfs_inode);
int ecryptfs_encrypt_page(struct folio *folio);
-int ecryptfs_decrypt_page(struct page *page);
+int ecryptfs_decrypt_page(struct folio *folio);
int ecryptfs_write_metadata(struct dentry *ecryptfs_dentry,
struct inode *ecryptfs_inode);
int ecryptfs_read_metadata(struct dentry *ecryptfs_dentry);
diff --git a/fs/ecryptfs/mmap.c b/fs/ecryptfs/mmap.c
index 1bf46d2c6a82..6ec4a60c1f3a 100644
--- a/fs/ecryptfs/mmap.c
+++ b/fs/ecryptfs/mmap.c
@@ -195,7 +195,7 @@ static int ecryptfs_read_folio(struct file *file, struct folio *folio)
}
}
} else {
- rc = ecryptfs_decrypt_page(&folio->page);
+ rc = ecryptfs_decrypt_page(folio);
if (rc) {
ecryptfs_printk(KERN_ERR, "Error decrypting page; "
"rc = [%d]\n", rc);
@@ -308,7 +308,7 @@ static int ecryptfs_write_begin(struct file *file,
folio_zero_range(folio, 0, PAGE_SIZE);
folio_mark_uptodate(folio);
} else if (len < PAGE_SIZE) {
- rc = ecryptfs_decrypt_page(&folio->page);
+ rc = ecryptfs_decrypt_page(folio);
if (rc) {
printk(KERN_ERR "%s: Error decrypting "
"page at index [%ld]; "
--
2.43.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 09/10] ecryptfs: Convert lower_offset_for_page() to take a folio
2024-10-17 15:16 [PATCH 00/10] Convert ecryptfs to use folios Matthew Wilcox (Oracle)
` (7 preceding siblings ...)
2024-10-17 15:17 ` [PATCH 08/10] ecryptfs: Convert ecryptfs_decrypt_page() " Matthew Wilcox (Oracle)
@ 2024-10-17 15:17 ` Matthew Wilcox (Oracle)
2024-10-17 15:17 ` [PATCH 10/10] ecryptfs: Pass the folio index to crypt_extent() Matthew Wilcox (Oracle)
9 siblings, 0 replies; 20+ messages in thread
From: Matthew Wilcox (Oracle) @ 2024-10-17 15:17 UTC (permalink / raw)
To: Tyler Hicks
Cc: Matthew Wilcox (Oracle), ecryptfs, Christian Brauner,
linux-fsdevel
Both callers have a folio, so pass it in and use folio->index instead of
page->index.
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
fs/ecryptfs/crypto.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/fs/ecryptfs/crypto.c b/fs/ecryptfs/crypto.c
index 02bccaa7c666..3db50a779dc7 100644
--- a/fs/ecryptfs/crypto.c
+++ b/fs/ecryptfs/crypto.c
@@ -328,10 +328,10 @@ static int crypt_scatterlist(struct ecryptfs_crypt_stat *crypt_stat,
* Convert an eCryptfs page index into a lower byte offset
*/
static loff_t lower_offset_for_page(struct ecryptfs_crypt_stat *crypt_stat,
- struct page *page)
+ struct folio *folio)
{
return ecryptfs_lower_header_size(crypt_stat) +
- ((loff_t)page->index << PAGE_SHIFT);
+ (loff_t)folio->index * PAGE_SIZE;
}
/**
@@ -440,7 +440,7 @@ int ecryptfs_encrypt_page(struct folio *folio)
}
}
- lower_offset = lower_offset_for_page(crypt_stat, &folio->page);
+ lower_offset = lower_offset_for_page(crypt_stat, folio);
enc_extent_virt = kmap_local_page(enc_extent_page);
rc = ecryptfs_write_lower(ecryptfs_inode, enc_extent_virt, lower_offset,
PAGE_SIZE);
@@ -489,7 +489,7 @@ int ecryptfs_decrypt_page(struct folio *folio)
&(ecryptfs_inode_to_private(ecryptfs_inode)->crypt_stat);
BUG_ON(!(crypt_stat->flags & ECRYPTFS_ENCRYPTED));
- lower_offset = lower_offset_for_page(crypt_stat, &folio->page);
+ lower_offset = lower_offset_for_page(crypt_stat, folio);
page_virt = kmap_local_folio(folio, 0);
rc = ecryptfs_read_lower(page_virt, lower_offset, PAGE_SIZE,
ecryptfs_inode);
--
2.43.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 10/10] ecryptfs: Pass the folio index to crypt_extent()
2024-10-17 15:16 [PATCH 00/10] Convert ecryptfs to use folios Matthew Wilcox (Oracle)
` (8 preceding siblings ...)
2024-10-17 15:17 ` [PATCH 09/10] ecryptfs: Convert lower_offset_for_page() " Matthew Wilcox (Oracle)
@ 2024-10-17 15:17 ` Matthew Wilcox (Oracle)
9 siblings, 0 replies; 20+ messages in thread
From: Matthew Wilcox (Oracle) @ 2024-10-17 15:17 UTC (permalink / raw)
To: Tyler Hicks
Cc: Matthew Wilcox (Oracle), ecryptfs, Christian Brauner,
linux-fsdevel
We need to pass pages, not folios, to crypt_extent() as we may be
working with a plain page rather than a folio. But we need to know the
index in the file, so pass it in from the caller.
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
fs/ecryptfs/crypto.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/fs/ecryptfs/crypto.c b/fs/ecryptfs/crypto.c
index 3db50a779dc7..c708b9012e21 100644
--- a/fs/ecryptfs/crypto.c
+++ b/fs/ecryptfs/crypto.c
@@ -350,9 +350,9 @@ static loff_t lower_offset_for_page(struct ecryptfs_crypt_stat *crypt_stat,
static int crypt_extent(struct ecryptfs_crypt_stat *crypt_stat,
struct page *dst_page,
struct page *src_page,
+ pgoff_t page_index,
unsigned long extent_offset, int op)
{
- pgoff_t page_index = op == ENCRYPT ? src_page->index : dst_page->index;
loff_t extent_base;
char extent_iv[ECRYPTFS_MAX_IV_BYTES];
struct scatterlist src_sg, dst_sg;
@@ -432,7 +432,8 @@ int ecryptfs_encrypt_page(struct folio *folio)
extent_offset < (PAGE_SIZE / crypt_stat->extent_size);
extent_offset++) {
rc = crypt_extent(crypt_stat, enc_extent_page,
- folio_page(folio, 0), extent_offset, ENCRYPT);
+ folio_page(folio, 0), folio->index,
+ extent_offset, ENCRYPT);
if (rc) {
printk(KERN_ERR "%s: Error encrypting extent; "
"rc = [%d]\n", __func__, rc);
@@ -505,8 +506,8 @@ int ecryptfs_decrypt_page(struct folio *folio)
extent_offset < (PAGE_SIZE / crypt_stat->extent_size);
extent_offset++) {
struct page *page = folio_page(folio, 0);
- rc = crypt_extent(crypt_stat, page, page,
- extent_offset, DECRYPT);
+ rc = crypt_extent(crypt_stat, page, page, folio->index,
+ extent_offset, DECRYPT);
if (rc) {
printk(KERN_ERR "%s: Error decrypting extent; "
"rc = [%d]\n", __func__, rc);
--
2.43.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* Re: [PATCH 03/10] ecryptfs: Convert ecryptfs_copy_up_encrypted_with_header() to take a folio
2024-10-17 15:16 ` [PATCH 03/10] ecryptfs: Convert ecryptfs_copy_up_encrypted_with_header() to take a folio Matthew Wilcox (Oracle)
@ 2024-10-18 3:43 ` kernel test robot
2024-10-18 6:33 ` Pankaj Raghav (Samsung)
1 sibling, 0 replies; 20+ messages in thread
From: kernel test robot @ 2024-10-18 3:43 UTC (permalink / raw)
To: Matthew Wilcox (Oracle), Tyler Hicks
Cc: oe-kbuild-all, Matthew Wilcox (Oracle), ecryptfs,
Christian Brauner, linux-fsdevel
Hi Matthew,
kernel test robot noticed the following build warnings:
[auto build test WARNING on v6.12-rc3]
[also build test WARNING on linus/master next-20241017]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Matthew-Wilcox-Oracle/ecryptfs-Convert-ecryptfs_writepage-to-ecryptfs_writepages/20241017-232033
base: v6.12-rc3
patch link: https://lore.kernel.org/r/20241017151709.2713048-4-willy%40infradead.org
patch subject: [PATCH 03/10] ecryptfs: Convert ecryptfs_copy_up_encrypted_with_header() to take a folio
config: x86_64-buildonly-randconfig-002-20241018 (https://download.01.org/0day-ci/archive/20241018/202410181111.XVnnYVNa-lkp@intel.com/config)
compiler: gcc-11 (Debian 11.3.0-12) 11.3.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241018/202410181111.XVnnYVNa-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202410181111.XVnnYVNa-lkp@intel.com/
All warnings (new ones prefixed by >>):
>> fs/ecryptfs/mmap.c:109: warning: Function parameter or struct member 'folio' not described in 'ecryptfs_copy_up_encrypted_with_header'
>> fs/ecryptfs/mmap.c:109: warning: Excess function parameter 'page' description in 'ecryptfs_copy_up_encrypted_with_header'
vim +109 fs/ecryptfs/mmap.c
f4e60e6b303bc4 Tyler Hicks 2010-02-11 79
688a9f7cd824e7 Lee Jones 2021-03-30 80 /*
e77a56ddceeec8 Michael Halcrow 2007-02-12 81 * Header Extent:
e77a56ddceeec8 Michael Halcrow 2007-02-12 82 * Octets 0-7: Unencrypted file size (big-endian)
e77a56ddceeec8 Michael Halcrow 2007-02-12 83 * Octets 8-15: eCryptfs special marker
e77a56ddceeec8 Michael Halcrow 2007-02-12 84 * Octets 16-19: Flags
e77a56ddceeec8 Michael Halcrow 2007-02-12 85 * Octet 16: File format version number (between 0 and 255)
e77a56ddceeec8 Michael Halcrow 2007-02-12 86 * Octets 17-18: Reserved
e77a56ddceeec8 Michael Halcrow 2007-02-12 87 * Octet 19: Bit 1 (lsb): Reserved
e77a56ddceeec8 Michael Halcrow 2007-02-12 88 * Bit 2: Encrypted?
e77a56ddceeec8 Michael Halcrow 2007-02-12 89 * Bits 3-8: Reserved
e77a56ddceeec8 Michael Halcrow 2007-02-12 90 * Octets 20-23: Header extent size (big-endian)
e77a56ddceeec8 Michael Halcrow 2007-02-12 91 * Octets 24-25: Number of header extents at front of file
e77a56ddceeec8 Michael Halcrow 2007-02-12 92 * (big-endian)
e77a56ddceeec8 Michael Halcrow 2007-02-12 93 * Octet 26: Begin RFC 2440 authentication token packet set
e77a56ddceeec8 Michael Halcrow 2007-02-12 94 */
237fead619984c Michael Halcrow 2006-10-04 95
237fead619984c Michael Halcrow 2006-10-04 96 /**
bf12be1cc851cf Michael Halcrow 2007-10-16 97 * ecryptfs_copy_up_encrypted_with_header
bf12be1cc851cf Michael Halcrow 2007-10-16 98 * @page: Sort of a ``virtual'' representation of the encrypted lower
bf12be1cc851cf Michael Halcrow 2007-10-16 99 * file. The actual lower file does not have the metadata in
bf12be1cc851cf Michael Halcrow 2007-10-16 100 * the header. This is locked.
bf12be1cc851cf Michael Halcrow 2007-10-16 101 * @crypt_stat: The eCryptfs inode's cryptographic context
237fead619984c Michael Halcrow 2006-10-04 102 *
bf12be1cc851cf Michael Halcrow 2007-10-16 103 * The ``view'' is the version of the file that userspace winds up
bf12be1cc851cf Michael Halcrow 2007-10-16 104 * seeing, with the header information inserted.
237fead619984c Michael Halcrow 2006-10-04 105 */
bf12be1cc851cf Michael Halcrow 2007-10-16 106 static int
f02b13c08673c2 Matthew Wilcox (Oracle 2024-10-17 107) ecryptfs_copy_up_encrypted_with_header(struct folio *folio,
bf12be1cc851cf Michael Halcrow 2007-10-16 108 struct ecryptfs_crypt_stat *crypt_stat)
237fead619984c Michael Halcrow 2006-10-04 @109 {
bf12be1cc851cf Michael Halcrow 2007-10-16 110 loff_t extent_num_in_page = 0;
09cbfeaf1a5a67 Kirill A. Shutemov 2016-04-01 111 loff_t num_extents_per_page = (PAGE_SIZE
bf12be1cc851cf Michael Halcrow 2007-10-16 112 / crypt_stat->extent_size);
237fead619984c Michael Halcrow 2006-10-04 113 int rc = 0;
237fead619984c Michael Halcrow 2006-10-04 114
bf12be1cc851cf Michael Halcrow 2007-10-16 115 while (extent_num_in_page < num_extents_per_page) {
f02b13c08673c2 Matthew Wilcox (Oracle 2024-10-17 116) loff_t view_extent_num = ((loff_t)folio->index
d6a13c17164fcc Michael Halcrow 2007-10-16 117 * num_extents_per_page)
f02b13c08673c2 Matthew Wilcox (Oracle 2024-10-17 118) + extent_num_in_page;
cc11beffdf80ca Michael Halcrow 2008-02-06 119 size_t num_header_extents_at_front =
fa3ef1cb4e6e99 Tyler Hicks 2010-02-11 120 (crypt_stat->metadata_size / crypt_stat->extent_size);
e77a56ddceeec8 Michael Halcrow 2007-02-12 121
cc11beffdf80ca Michael Halcrow 2008-02-06 122 if (view_extent_num < num_header_extents_at_front) {
bf12be1cc851cf Michael Halcrow 2007-10-16 123 /* This is a header extent */
e77a56ddceeec8 Michael Halcrow 2007-02-12 124 char *page_virt;
e77a56ddceeec8 Michael Halcrow 2007-02-12 125
f02b13c08673c2 Matthew Wilcox (Oracle 2024-10-17 126) page_virt = kmap_local_folio(folio, 0);
09cbfeaf1a5a67 Kirill A. Shutemov 2016-04-01 127 memset(page_virt, 0, PAGE_SIZE);
bf12be1cc851cf Michael Halcrow 2007-10-16 128 /* TODO: Support more than one header extent */
bf12be1cc851cf Michael Halcrow 2007-10-16 129 if (view_extent_num == 0) {
157f1071354db1 Tyler Hicks 2010-02-11 130 size_t written;
157f1071354db1 Tyler Hicks 2010-02-11 131
e77a56ddceeec8 Michael Halcrow 2007-02-12 132 rc = ecryptfs_read_xattr_region(
f02b13c08673c2 Matthew Wilcox (Oracle 2024-10-17 133) page_virt, folio->mapping->host);
f4e60e6b303bc4 Tyler Hicks 2010-02-11 134 strip_xattr_flag(page_virt + 16, crypt_stat);
157f1071354db1 Tyler Hicks 2010-02-11 135 ecryptfs_write_header_metadata(page_virt + 20,
157f1071354db1 Tyler Hicks 2010-02-11 136 crypt_stat,
157f1071354db1 Tyler Hicks 2010-02-11 137 &written);
e77a56ddceeec8 Michael Halcrow 2007-02-12 138 }
e2393b8f3987c5 Fabio M. De Francesco 2023-04-26 139 kunmap_local(page_virt);
f02b13c08673c2 Matthew Wilcox (Oracle 2024-10-17 140) flush_dcache_folio(folio);
e77a56ddceeec8 Michael Halcrow 2007-02-12 141 if (rc) {
bf12be1cc851cf Michael Halcrow 2007-10-16 142 printk(KERN_ERR "%s: Error reading xattr "
18d1dbf1d401e8 Harvey Harrison 2008-04-29 143 "region; rc = [%d]\n", __func__, rc);
e77a56ddceeec8 Michael Halcrow 2007-02-12 144 goto out;
e77a56ddceeec8 Michael Halcrow 2007-02-12 145 }
e77a56ddceeec8 Michael Halcrow 2007-02-12 146 } else {
bf12be1cc851cf Michael Halcrow 2007-10-16 147 /* This is an encrypted data extent */
bf12be1cc851cf Michael Halcrow 2007-10-16 148 loff_t lower_offset =
cc11beffdf80ca Michael Halcrow 2008-02-06 149 ((view_extent_num * crypt_stat->extent_size)
fa3ef1cb4e6e99 Tyler Hicks 2010-02-11 150 - crypt_stat->metadata_size);
bf12be1cc851cf Michael Halcrow 2007-10-16 151
bf12be1cc851cf Michael Halcrow 2007-10-16 152 rc = ecryptfs_read_lower_page_segment(
f02b13c08673c2 Matthew Wilcox (Oracle 2024-10-17 153) &folio->page, (lower_offset >> PAGE_SHIFT),
09cbfeaf1a5a67 Kirill A. Shutemov 2016-04-01 154 (lower_offset & ~PAGE_MASK),
f02b13c08673c2 Matthew Wilcox (Oracle 2024-10-17 155) crypt_stat->extent_size, folio->mapping->host);
e77a56ddceeec8 Michael Halcrow 2007-02-12 156 if (rc) {
bf12be1cc851cf Michael Halcrow 2007-10-16 157 printk(KERN_ERR "%s: Error attempting to read "
bf12be1cc851cf Michael Halcrow 2007-10-16 158 "extent at offset [%lld] in the lower "
18d1dbf1d401e8 Harvey Harrison 2008-04-29 159 "file; rc = [%d]\n", __func__,
bf12be1cc851cf Michael Halcrow 2007-10-16 160 lower_offset, rc);
e77a56ddceeec8 Michael Halcrow 2007-02-12 161 goto out;
e77a56ddceeec8 Michael Halcrow 2007-02-12 162 }
e77a56ddceeec8 Michael Halcrow 2007-02-12 163 }
bf12be1cc851cf Michael Halcrow 2007-10-16 164 extent_num_in_page++;
bf12be1cc851cf Michael Halcrow 2007-10-16 165 }
bf12be1cc851cf Michael Halcrow 2007-10-16 166 out:
bf12be1cc851cf Michael Halcrow 2007-10-16 167 return rc;
bf12be1cc851cf Michael Halcrow 2007-10-16 168 }
bf12be1cc851cf Michael Halcrow 2007-10-16 169
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 07/10] ecryptfs: Convert ecryptfs_encrypt_page() to take a folio
2024-10-17 15:17 ` [PATCH 07/10] ecryptfs: Convert ecryptfs_encrypt_page() " Matthew Wilcox (Oracle)
@ 2024-10-18 5:06 ` kernel test robot
0 siblings, 0 replies; 20+ messages in thread
From: kernel test robot @ 2024-10-18 5:06 UTC (permalink / raw)
To: Matthew Wilcox (Oracle), Tyler Hicks
Cc: oe-kbuild-all, Matthew Wilcox (Oracle), ecryptfs,
Christian Brauner, linux-fsdevel
Hi Matthew,
kernel test robot noticed the following build warnings:
[auto build test WARNING on v6.12-rc3]
[also build test WARNING on linus/master next-20241017]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Matthew-Wilcox-Oracle/ecryptfs-Convert-ecryptfs_writepage-to-ecryptfs_writepages/20241017-232033
base: v6.12-rc3
patch link: https://lore.kernel.org/r/20241017151709.2713048-8-willy%40infradead.org
patch subject: [PATCH 07/10] ecryptfs: Convert ecryptfs_encrypt_page() to take a folio
config: x86_64-buildonly-randconfig-002-20241018 (https://download.01.org/0day-ci/archive/20241018/202410181219.HUGM3U13-lkp@intel.com/config)
compiler: gcc-11 (Debian 11.3.0-12) 11.3.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241018/202410181219.HUGM3U13-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202410181219.HUGM3U13-lkp@intel.com/
All warnings (new ones prefixed by >>):
>> fs/ecryptfs/crypto.c:410: warning: Function parameter or struct member 'folio' not described in 'ecryptfs_encrypt_page'
>> fs/ecryptfs/crypto.c:410: warning: Excess function parameter 'page' description in 'ecryptfs_encrypt_page'
vim +410 fs/ecryptfs/crypto.c
237fead619984c Michael Halcrow 2006-10-04 392
237fead619984c Michael Halcrow 2006-10-04 393 /**
0216f7f7921759 Michael Halcrow 2007-10-16 394 * ecryptfs_encrypt_page
0216f7f7921759 Michael Halcrow 2007-10-16 395 * @page: Page mapped from the eCryptfs inode for the file; contains
0216f7f7921759 Michael Halcrow 2007-10-16 396 * decrypted content that needs to be encrypted (to a temporary
0216f7f7921759 Michael Halcrow 2007-10-16 397 * page; not in place) and written out to the lower file
237fead619984c Michael Halcrow 2006-10-04 398 *
0216f7f7921759 Michael Halcrow 2007-10-16 399 * Encrypt an eCryptfs page. This is done on a per-extent basis. Note
237fead619984c Michael Halcrow 2006-10-04 400 * that eCryptfs pages may straddle the lower pages -- for instance,
237fead619984c Michael Halcrow 2006-10-04 401 * if the file was created on a machine with an 8K page size
237fead619984c Michael Halcrow 2006-10-04 402 * (resulting in an 8K header), and then the file is copied onto a
237fead619984c Michael Halcrow 2006-10-04 403 * host with a 32K page size, then when reading page 0 of the eCryptfs
237fead619984c Michael Halcrow 2006-10-04 404 * file, 24K of page 0 of the lower file will be read and decrypted,
237fead619984c Michael Halcrow 2006-10-04 405 * and then 8K of page 1 of the lower file will be read and decrypted.
237fead619984c Michael Halcrow 2006-10-04 406 *
237fead619984c Michael Halcrow 2006-10-04 407 * Returns zero on success; negative on error
237fead619984c Michael Halcrow 2006-10-04 408 */
722a8483fde078 Matthew Wilcox (Oracle 2024-10-17 409) int ecryptfs_encrypt_page(struct folio *folio)
237fead619984c Michael Halcrow 2006-10-04 @410 {
0216f7f7921759 Michael Halcrow 2007-10-16 411 struct inode *ecryptfs_inode;
237fead619984c Michael Halcrow 2006-10-04 412 struct ecryptfs_crypt_stat *crypt_stat;
7fcba054373d5d Eric Sandeen 2008-07-28 413 char *enc_extent_virt;
7fcba054373d5d Eric Sandeen 2008-07-28 414 struct page *enc_extent_page = NULL;
0216f7f7921759 Michael Halcrow 2007-10-16 415 loff_t extent_offset;
0f89617623fed9 Tyler Hicks 2013-04-15 416 loff_t lower_offset;
237fead619984c Michael Halcrow 2006-10-04 417 int rc = 0;
237fead619984c Michael Halcrow 2006-10-04 418
722a8483fde078 Matthew Wilcox (Oracle 2024-10-17 419) ecryptfs_inode = folio->mapping->host;
0216f7f7921759 Michael Halcrow 2007-10-16 420 crypt_stat =
0216f7f7921759 Michael Halcrow 2007-10-16 421 &(ecryptfs_inode_to_private(ecryptfs_inode)->crypt_stat);
13a791b4e63eb0 Tyler Hicks 2009-04-13 422 BUG_ON(!(crypt_stat->flags & ECRYPTFS_ENCRYPTED));
7fcba054373d5d Eric Sandeen 2008-07-28 423 enc_extent_page = alloc_page(GFP_USER);
7fcba054373d5d Eric Sandeen 2008-07-28 424 if (!enc_extent_page) {
237fead619984c Michael Halcrow 2006-10-04 425 rc = -ENOMEM;
0216f7f7921759 Michael Halcrow 2007-10-16 426 ecryptfs_printk(KERN_ERR, "Error allocating memory for "
0216f7f7921759 Michael Halcrow 2007-10-16 427 "encrypted extent\n");
237fead619984c Michael Halcrow 2006-10-04 428 goto out;
237fead619984c Michael Halcrow 2006-10-04 429 }
0f89617623fed9 Tyler Hicks 2013-04-15 430
0216f7f7921759 Michael Halcrow 2007-10-16 431 for (extent_offset = 0;
09cbfeaf1a5a67 Kirill A. Shutemov 2016-04-01 432 extent_offset < (PAGE_SIZE / crypt_stat->extent_size);
0216f7f7921759 Michael Halcrow 2007-10-16 433 extent_offset++) {
722a8483fde078 Matthew Wilcox (Oracle 2024-10-17 434) rc = crypt_extent(crypt_stat, enc_extent_page,
722a8483fde078 Matthew Wilcox (Oracle 2024-10-17 435) folio_page(folio, 0), extent_offset, ENCRYPT);
237fead619984c Michael Halcrow 2006-10-04 436 if (rc) {
0216f7f7921759 Michael Halcrow 2007-10-16 437 printk(KERN_ERR "%s: Error encrypting extent; "
18d1dbf1d401e8 Harvey Harrison 2008-04-29 438 "rc = [%d]\n", __func__, rc);
237fead619984c Michael Halcrow 2006-10-04 439 goto out;
237fead619984c Michael Halcrow 2006-10-04 440 }
237fead619984c Michael Halcrow 2006-10-04 441 }
0216f7f7921759 Michael Halcrow 2007-10-16 442
722a8483fde078 Matthew Wilcox (Oracle 2024-10-17 443) lower_offset = lower_offset_for_page(crypt_stat, &folio->page);
8b70deb8ca901d Fabio M. De Francesco 2023-04-26 444 enc_extent_virt = kmap_local_page(enc_extent_page);
0f89617623fed9 Tyler Hicks 2013-04-15 445 rc = ecryptfs_write_lower(ecryptfs_inode, enc_extent_virt, lower_offset,
09cbfeaf1a5a67 Kirill A. Shutemov 2016-04-01 446 PAGE_SIZE);
8b70deb8ca901d Fabio M. De Francesco 2023-04-26 447 kunmap_local(enc_extent_virt);
0216f7f7921759 Michael Halcrow 2007-10-16 448 if (rc < 0) {
0f89617623fed9 Tyler Hicks 2013-04-15 449 ecryptfs_printk(KERN_ERR,
0f89617623fed9 Tyler Hicks 2013-04-15 450 "Error attempting to write lower page; rc = [%d]\n",
0216f7f7921759 Michael Halcrow 2007-10-16 451 rc);
237fead619984c Michael Halcrow 2006-10-04 452 goto out;
237fead619984c Michael Halcrow 2006-10-04 453 }
237fead619984c Michael Halcrow 2006-10-04 454 rc = 0;
0216f7f7921759 Michael Halcrow 2007-10-16 455 out:
7fcba054373d5d Eric Sandeen 2008-07-28 456 if (enc_extent_page) {
7fcba054373d5d Eric Sandeen 2008-07-28 457 __free_page(enc_extent_page);
7fcba054373d5d Eric Sandeen 2008-07-28 458 }
0216f7f7921759 Michael Halcrow 2007-10-16 459 return rc;
0216f7f7921759 Michael Halcrow 2007-10-16 460 }
0216f7f7921759 Michael Halcrow 2007-10-16 461
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 02/10] ecryptfs: Use a folio throughout ecryptfs_read_folio()
2024-10-17 15:16 ` [PATCH 02/10] ecryptfs: Use a folio throughout ecryptfs_read_folio() Matthew Wilcox (Oracle)
@ 2024-10-18 6:21 ` Pankaj Raghav (Samsung)
2024-10-25 18:50 ` Matthew Wilcox
0 siblings, 1 reply; 20+ messages in thread
From: Pankaj Raghav (Samsung) @ 2024-10-18 6:21 UTC (permalink / raw)
To: Matthew Wilcox (Oracle)
Cc: Tyler Hicks, ecryptfs, Christian Brauner, linux-fsdevel
On Thu, Oct 17, 2024 at 04:16:57PM +0100, Matthew Wilcox (Oracle) wrote:
> @@ -219,13 +219,11 @@ static int ecryptfs_read_folio(struct file *file, struct folio *folio)
> }
> }
> out:
> - if (rc)
> - ClearPageUptodate(page);
> - else
> - SetPageUptodate(page);
> + if (!rc)
> + folio_mark_uptodate(folio);
> ecryptfs_printk(KERN_DEBUG, "Unlocking page with index = [0x%.16lx]\n",
Nit: Unlocking folio with index ..
> - page->index);
--
Pankaj
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 01/10] ecryptfs: Convert ecryptfs_writepage() to ecryptfs_writepages()
2024-10-17 15:16 ` [PATCH 01/10] ecryptfs: Convert ecryptfs_writepage() to ecryptfs_writepages() Matthew Wilcox (Oracle)
@ 2024-10-18 6:23 ` Pankaj Raghav (Samsung)
2024-10-25 17:56 ` Matthew Wilcox
0 siblings, 1 reply; 20+ messages in thread
From: Pankaj Raghav (Samsung) @ 2024-10-18 6:23 UTC (permalink / raw)
To: Matthew Wilcox (Oracle)
Cc: Tyler Hicks, ecryptfs, Christian Brauner, linux-fsdevel
On Thu, Oct 17, 2024 at 04:16:56PM +0100, Matthew Wilcox (Oracle) wrote:
> By adding a ->migrate_folio implementation, theree is no need to keep
> the ->writepage implementation.
Is this documented somewhere or is it common knowledge?
> The new writepages removes the
> unnecessary call to SetPageUptodate(); the folio should already be
> uptodate at this point.
--
Pankaj
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 03/10] ecryptfs: Convert ecryptfs_copy_up_encrypted_with_header() to take a folio
2024-10-17 15:16 ` [PATCH 03/10] ecryptfs: Convert ecryptfs_copy_up_encrypted_with_header() to take a folio Matthew Wilcox (Oracle)
2024-10-18 3:43 ` kernel test robot
@ 2024-10-18 6:33 ` Pankaj Raghav (Samsung)
1 sibling, 0 replies; 20+ messages in thread
From: Pankaj Raghav (Samsung) @ 2024-10-18 6:33 UTC (permalink / raw)
To: Matthew Wilcox (Oracle)
Cc: Tyler Hicks, ecryptfs, Christian Brauner, linux-fsdevel
On Thu, Oct 17, 2024 at 04:16:58PM +0100, Matthew Wilcox (Oracle) wrote:
> Both callers have a folio, so pass it in and use it throughout.
>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Looks good.
Reviewed-by: Pankaj Raghav <p.raghav@samsung.com>
> ---
> fs/ecryptfs/mmap.c | 20 ++++++++++----------
> 1 file changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/fs/ecryptfs/mmap.c b/fs/ecryptfs/mmap.c
> index 346ed5f7ff8d..f7525a906ef7 100644
> --- a/fs/ecryptfs/mmap.c
> +++ b/fs/ecryptfs/mmap.c
> @@ -104,7 +104,7 @@ static void strip_xattr_flag(char *page_virt,
> * seeing, with the header information inserted.
> */
> static int
> -ecryptfs_copy_up_encrypted_with_header(struct page *page,
> +ecryptfs_copy_up_encrypted_with_header(struct folio *folio,
> struct ecryptfs_crypt_stat *crypt_stat)
> {
> loff_t extent_num_in_page = 0;
> @@ -113,9 +113,9 @@ ecryptfs_copy_up_encrypted_with_header(struct page *page,
> int rc = 0;
>
> while (extent_num_in_page < num_extents_per_page) {
> - loff_t view_extent_num = ((((loff_t)page->index)
> + loff_t view_extent_num = ((loff_t)folio->index
> * num_extents_per_page)
> - + extent_num_in_page);
> + + extent_num_in_page;
> size_t num_header_extents_at_front =
> (crypt_stat->metadata_size / crypt_stat->extent_size);
>
> @@ -123,21 +123,21 @@ ecryptfs_copy_up_encrypted_with_header(struct page *page,
> /* This is a header extent */
> char *page_virt;
>
> - page_virt = kmap_local_page(page);
> + page_virt = kmap_local_folio(folio, 0);
> memset(page_virt, 0, PAGE_SIZE);
> /* TODO: Support more than one header extent */
> if (view_extent_num == 0) {
> size_t written;
>
> rc = ecryptfs_read_xattr_region(
> - page_virt, page->mapping->host);
> + page_virt, folio->mapping->host);
> strip_xattr_flag(page_virt + 16, crypt_stat);
> ecryptfs_write_header_metadata(page_virt + 20,
> crypt_stat,
> &written);
> }
> kunmap_local(page_virt);
> - flush_dcache_page(page);
> + flush_dcache_folio(folio);
> if (rc) {
> printk(KERN_ERR "%s: Error reading xattr "
> "region; rc = [%d]\n", __func__, rc);
> @@ -150,9 +150,9 @@ ecryptfs_copy_up_encrypted_with_header(struct page *page,
> - crypt_stat->metadata_size);
>
> rc = ecryptfs_read_lower_page_segment(
> - page, (lower_offset >> PAGE_SHIFT),
> + &folio->page, (lower_offset >> PAGE_SHIFT),
> (lower_offset & ~PAGE_MASK),
> - crypt_stat->extent_size, page->mapping->host);
> + crypt_stat->extent_size, folio->mapping->host);
> if (rc) {
> printk(KERN_ERR "%s: Error attempting to read "
> "extent at offset [%lld] in the lower "
> @@ -189,7 +189,7 @@ static int ecryptfs_read_folio(struct file *file, struct folio *folio)
> inode);
> } else if (crypt_stat->flags & ECRYPTFS_VIEW_AS_ENCRYPTED) {
> if (crypt_stat->flags & ECRYPTFS_METADATA_IN_XATTR) {
> - rc = ecryptfs_copy_up_encrypted_with_header(&folio->page,
> + rc = ecryptfs_copy_up_encrypted_with_header(folio,
> crypt_stat);
> if (rc) {
> printk(KERN_ERR "%s: Error attempting to copy "
> @@ -293,7 +293,7 @@ static int ecryptfs_write_begin(struct file *file,
> } else if (crypt_stat->flags & ECRYPTFS_VIEW_AS_ENCRYPTED) {
> if (crypt_stat->flags & ECRYPTFS_METADATA_IN_XATTR) {
> rc = ecryptfs_copy_up_encrypted_with_header(
> - &folio->page, crypt_stat);
> + folio, crypt_stat);
> if (rc) {
> printk(KERN_ERR "%s: Error attempting "
> "to copy the encrypted content "
> --
> 2.43.0
>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 08/10] ecryptfs: Convert ecryptfs_decrypt_page() to take a folio
2024-10-17 15:17 ` [PATCH 08/10] ecryptfs: Convert ecryptfs_decrypt_page() " Matthew Wilcox (Oracle)
@ 2024-10-18 6:39 ` kernel test robot
0 siblings, 0 replies; 20+ messages in thread
From: kernel test robot @ 2024-10-18 6:39 UTC (permalink / raw)
To: Matthew Wilcox (Oracle), Tyler Hicks
Cc: oe-kbuild-all, Matthew Wilcox (Oracle), ecryptfs,
Christian Brauner, linux-fsdevel
Hi Matthew,
kernel test robot noticed the following build warnings:
[auto build test WARNING on v6.12-rc3]
[also build test WARNING on linus/master next-20241017]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Matthew-Wilcox-Oracle/ecryptfs-Convert-ecryptfs_writepage-to-ecryptfs_writepages/20241017-232033
base: v6.12-rc3
patch link: https://lore.kernel.org/r/20241017151709.2713048-9-willy%40infradead.org
patch subject: [PATCH 08/10] ecryptfs: Convert ecryptfs_decrypt_page() to take a folio
config: x86_64-buildonly-randconfig-002-20241018 (https://download.01.org/0day-ci/archive/20241018/202410181420.B8LE1KXl-lkp@intel.com/config)
compiler: gcc-11 (Debian 11.3.0-12) 11.3.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241018/202410181420.B8LE1KXl-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202410181420.B8LE1KXl-lkp@intel.com/
All warnings (new ones prefixed by >>):
fs/ecryptfs/crypto.c:410: warning: Function parameter or struct member 'folio' not described in 'ecryptfs_encrypt_page'
fs/ecryptfs/crypto.c:410: warning: Excess function parameter 'page' description in 'ecryptfs_encrypt_page'
>> fs/ecryptfs/crypto.c:479: warning: Function parameter or struct member 'folio' not described in 'ecryptfs_decrypt_page'
>> fs/ecryptfs/crypto.c:479: warning: Excess function parameter 'page' description in 'ecryptfs_decrypt_page'
vim +479 fs/ecryptfs/crypto.c
237fead619984c Michael Halcrow 2006-10-04 392
237fead619984c Michael Halcrow 2006-10-04 393 /**
0216f7f7921759 Michael Halcrow 2007-10-16 394 * ecryptfs_encrypt_page
0216f7f7921759 Michael Halcrow 2007-10-16 395 * @page: Page mapped from the eCryptfs inode for the file; contains
0216f7f7921759 Michael Halcrow 2007-10-16 396 * decrypted content that needs to be encrypted (to a temporary
0216f7f7921759 Michael Halcrow 2007-10-16 397 * page; not in place) and written out to the lower file
237fead619984c Michael Halcrow 2006-10-04 398 *
0216f7f7921759 Michael Halcrow 2007-10-16 399 * Encrypt an eCryptfs page. This is done on a per-extent basis. Note
237fead619984c Michael Halcrow 2006-10-04 400 * that eCryptfs pages may straddle the lower pages -- for instance,
237fead619984c Michael Halcrow 2006-10-04 401 * if the file was created on a machine with an 8K page size
237fead619984c Michael Halcrow 2006-10-04 402 * (resulting in an 8K header), and then the file is copied onto a
237fead619984c Michael Halcrow 2006-10-04 403 * host with a 32K page size, then when reading page 0 of the eCryptfs
237fead619984c Michael Halcrow 2006-10-04 404 * file, 24K of page 0 of the lower file will be read and decrypted,
237fead619984c Michael Halcrow 2006-10-04 405 * and then 8K of page 1 of the lower file will be read and decrypted.
237fead619984c Michael Halcrow 2006-10-04 406 *
237fead619984c Michael Halcrow 2006-10-04 407 * Returns zero on success; negative on error
237fead619984c Michael Halcrow 2006-10-04 408 */
722a8483fde078 Matthew Wilcox (Oracle 2024-10-17 409) int ecryptfs_encrypt_page(struct folio *folio)
237fead619984c Michael Halcrow 2006-10-04 @410 {
0216f7f7921759 Michael Halcrow 2007-10-16 411 struct inode *ecryptfs_inode;
237fead619984c Michael Halcrow 2006-10-04 412 struct ecryptfs_crypt_stat *crypt_stat;
7fcba054373d5d Eric Sandeen 2008-07-28 413 char *enc_extent_virt;
7fcba054373d5d Eric Sandeen 2008-07-28 414 struct page *enc_extent_page = NULL;
0216f7f7921759 Michael Halcrow 2007-10-16 415 loff_t extent_offset;
0f89617623fed9 Tyler Hicks 2013-04-15 416 loff_t lower_offset;
237fead619984c Michael Halcrow 2006-10-04 417 int rc = 0;
237fead619984c Michael Halcrow 2006-10-04 418
722a8483fde078 Matthew Wilcox (Oracle 2024-10-17 419) ecryptfs_inode = folio->mapping->host;
0216f7f7921759 Michael Halcrow 2007-10-16 420 crypt_stat =
0216f7f7921759 Michael Halcrow 2007-10-16 421 &(ecryptfs_inode_to_private(ecryptfs_inode)->crypt_stat);
13a791b4e63eb0 Tyler Hicks 2009-04-13 422 BUG_ON(!(crypt_stat->flags & ECRYPTFS_ENCRYPTED));
7fcba054373d5d Eric Sandeen 2008-07-28 423 enc_extent_page = alloc_page(GFP_USER);
7fcba054373d5d Eric Sandeen 2008-07-28 424 if (!enc_extent_page) {
237fead619984c Michael Halcrow 2006-10-04 425 rc = -ENOMEM;
0216f7f7921759 Michael Halcrow 2007-10-16 426 ecryptfs_printk(KERN_ERR, "Error allocating memory for "
0216f7f7921759 Michael Halcrow 2007-10-16 427 "encrypted extent\n");
237fead619984c Michael Halcrow 2006-10-04 428 goto out;
237fead619984c Michael Halcrow 2006-10-04 429 }
0f89617623fed9 Tyler Hicks 2013-04-15 430
0216f7f7921759 Michael Halcrow 2007-10-16 431 for (extent_offset = 0;
09cbfeaf1a5a67 Kirill A. Shutemov 2016-04-01 432 extent_offset < (PAGE_SIZE / crypt_stat->extent_size);
0216f7f7921759 Michael Halcrow 2007-10-16 433 extent_offset++) {
722a8483fde078 Matthew Wilcox (Oracle 2024-10-17 434) rc = crypt_extent(crypt_stat, enc_extent_page,
722a8483fde078 Matthew Wilcox (Oracle 2024-10-17 435) folio_page(folio, 0), extent_offset, ENCRYPT);
237fead619984c Michael Halcrow 2006-10-04 436 if (rc) {
0216f7f7921759 Michael Halcrow 2007-10-16 437 printk(KERN_ERR "%s: Error encrypting extent; "
18d1dbf1d401e8 Harvey Harrison 2008-04-29 438 "rc = [%d]\n", __func__, rc);
237fead619984c Michael Halcrow 2006-10-04 439 goto out;
237fead619984c Michael Halcrow 2006-10-04 440 }
237fead619984c Michael Halcrow 2006-10-04 441 }
0216f7f7921759 Michael Halcrow 2007-10-16 442
722a8483fde078 Matthew Wilcox (Oracle 2024-10-17 443) lower_offset = lower_offset_for_page(crypt_stat, &folio->page);
8b70deb8ca901d Fabio M. De Francesco 2023-04-26 444 enc_extent_virt = kmap_local_page(enc_extent_page);
0f89617623fed9 Tyler Hicks 2013-04-15 445 rc = ecryptfs_write_lower(ecryptfs_inode, enc_extent_virt, lower_offset,
09cbfeaf1a5a67 Kirill A. Shutemov 2016-04-01 446 PAGE_SIZE);
8b70deb8ca901d Fabio M. De Francesco 2023-04-26 447 kunmap_local(enc_extent_virt);
0216f7f7921759 Michael Halcrow 2007-10-16 448 if (rc < 0) {
0f89617623fed9 Tyler Hicks 2013-04-15 449 ecryptfs_printk(KERN_ERR,
0f89617623fed9 Tyler Hicks 2013-04-15 450 "Error attempting to write lower page; rc = [%d]\n",
0216f7f7921759 Michael Halcrow 2007-10-16 451 rc);
237fead619984c Michael Halcrow 2006-10-04 452 goto out;
237fead619984c Michael Halcrow 2006-10-04 453 }
237fead619984c Michael Halcrow 2006-10-04 454 rc = 0;
0216f7f7921759 Michael Halcrow 2007-10-16 455 out:
7fcba054373d5d Eric Sandeen 2008-07-28 456 if (enc_extent_page) {
7fcba054373d5d Eric Sandeen 2008-07-28 457 __free_page(enc_extent_page);
7fcba054373d5d Eric Sandeen 2008-07-28 458 }
0216f7f7921759 Michael Halcrow 2007-10-16 459 return rc;
0216f7f7921759 Michael Halcrow 2007-10-16 460 }
0216f7f7921759 Michael Halcrow 2007-10-16 461
0216f7f7921759 Michael Halcrow 2007-10-16 462 /**
0216f7f7921759 Michael Halcrow 2007-10-16 463 * ecryptfs_decrypt_page
0216f7f7921759 Michael Halcrow 2007-10-16 464 * @page: Page mapped from the eCryptfs inode for the file; data read
0216f7f7921759 Michael Halcrow 2007-10-16 465 * and decrypted from the lower file will be written into this
0216f7f7921759 Michael Halcrow 2007-10-16 466 * page
0216f7f7921759 Michael Halcrow 2007-10-16 467 *
0216f7f7921759 Michael Halcrow 2007-10-16 468 * Decrypt an eCryptfs page. This is done on a per-extent basis. Note
0216f7f7921759 Michael Halcrow 2007-10-16 469 * that eCryptfs pages may straddle the lower pages -- for instance,
0216f7f7921759 Michael Halcrow 2007-10-16 470 * if the file was created on a machine with an 8K page size
0216f7f7921759 Michael Halcrow 2007-10-16 471 * (resulting in an 8K header), and then the file is copied onto a
0216f7f7921759 Michael Halcrow 2007-10-16 472 * host with a 32K page size, then when reading page 0 of the eCryptfs
0216f7f7921759 Michael Halcrow 2007-10-16 473 * file, 24K of page 0 of the lower file will be read and decrypted,
0216f7f7921759 Michael Halcrow 2007-10-16 474 * and then 8K of page 1 of the lower file will be read and decrypted.
0216f7f7921759 Michael Halcrow 2007-10-16 475 *
0216f7f7921759 Michael Halcrow 2007-10-16 476 * Returns zero on success; negative on error
0216f7f7921759 Michael Halcrow 2007-10-16 477 */
9f117fd1efdb64 Matthew Wilcox (Oracle 2024-10-17 478) int ecryptfs_decrypt_page(struct folio *folio)
0216f7f7921759 Michael Halcrow 2007-10-16 @479 {
0216f7f7921759 Michael Halcrow 2007-10-16 480 struct inode *ecryptfs_inode;
0216f7f7921759 Michael Halcrow 2007-10-16 481 struct ecryptfs_crypt_stat *crypt_stat;
9c6043f41222b4 Tyler Hicks 2013-04-06 482 char *page_virt;
0216f7f7921759 Michael Halcrow 2007-10-16 483 unsigned long extent_offset;
0f89617623fed9 Tyler Hicks 2013-04-15 484 loff_t lower_offset;
0216f7f7921759 Michael Halcrow 2007-10-16 485 int rc = 0;
0216f7f7921759 Michael Halcrow 2007-10-16 486
9f117fd1efdb64 Matthew Wilcox (Oracle 2024-10-17 487) ecryptfs_inode = folio->mapping->host;
0216f7f7921759 Michael Halcrow 2007-10-16 488 crypt_stat =
0216f7f7921759 Michael Halcrow 2007-10-16 489 &(ecryptfs_inode_to_private(ecryptfs_inode)->crypt_stat);
13a791b4e63eb0 Tyler Hicks 2009-04-13 490 BUG_ON(!(crypt_stat->flags & ECRYPTFS_ENCRYPTED));
0f89617623fed9 Tyler Hicks 2013-04-15 491
9f117fd1efdb64 Matthew Wilcox (Oracle 2024-10-17 492) lower_offset = lower_offset_for_page(crypt_stat, &folio->page);
9f117fd1efdb64 Matthew Wilcox (Oracle 2024-10-17 493) page_virt = kmap_local_folio(folio, 0);
09cbfeaf1a5a67 Kirill A. Shutemov 2016-04-01 494 rc = ecryptfs_read_lower(page_virt, lower_offset, PAGE_SIZE,
0216f7f7921759 Michael Halcrow 2007-10-16 495 ecryptfs_inode);
8b70deb8ca901d Fabio M. De Francesco 2023-04-26 496 kunmap_local(page_virt);
96a7b9c2f5df89 Tyler Hicks 2009-09-16 497 if (rc < 0) {
0f89617623fed9 Tyler Hicks 2013-04-15 498 ecryptfs_printk(KERN_ERR,
0f89617623fed9 Tyler Hicks 2013-04-15 499 "Error attempting to read lower page; rc = [%d]\n",
0f89617623fed9 Tyler Hicks 2013-04-15 500 rc);
16a72c455a67bb Michael Halcrow 2007-10-16 501 goto out;
0216f7f7921759 Michael Halcrow 2007-10-16 502 }
0f89617623fed9 Tyler Hicks 2013-04-15 503
0216f7f7921759 Michael Halcrow 2007-10-16 504 for (extent_offset = 0;
09cbfeaf1a5a67 Kirill A. Shutemov 2016-04-01 505 extent_offset < (PAGE_SIZE / crypt_stat->extent_size);
0216f7f7921759 Michael Halcrow 2007-10-16 506 extent_offset++) {
9f117fd1efdb64 Matthew Wilcox (Oracle 2024-10-17 507) struct page *page = folio_page(folio, 0);
0df5ed65c14e2c Tyler Hicks 2013-05-23 508 rc = crypt_extent(crypt_stat, page, page,
d78de618962d1e Tyler Hicks 2013-04-06 509 extent_offset, DECRYPT);
0216f7f7921759 Michael Halcrow 2007-10-16 510 if (rc) {
1abbe1106d48ab Sascha Hauer 2021-02-24 511 printk(KERN_ERR "%s: Error decrypting extent; "
18d1dbf1d401e8 Harvey Harrison 2008-04-29 512 "rc = [%d]\n", __func__, rc);
16a72c455a67bb Michael Halcrow 2007-10-16 513 goto out;
237fead619984c Michael Halcrow 2006-10-04 514 }
237fead619984c Michael Halcrow 2006-10-04 515 }
237fead619984c Michael Halcrow 2006-10-04 516 out:
237fead619984c Michael Halcrow 2006-10-04 517 return rc;
237fead619984c Michael Halcrow 2006-10-04 518 }
237fead619984c Michael Halcrow 2006-10-04 519
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 05/10] ecryptfs: Convert ecryptfs_write() to use a folio
2024-10-17 15:17 ` [PATCH 05/10] ecryptfs: Convert ecryptfs_write() to use " Matthew Wilcox (Oracle)
@ 2024-10-18 8:07 ` Pankaj Raghav (Samsung)
0 siblings, 0 replies; 20+ messages in thread
From: Pankaj Raghav (Samsung) @ 2024-10-18 8:07 UTC (permalink / raw)
To: Matthew Wilcox (Oracle)
Cc: Tyler Hicks, ecryptfs, Christian Brauner, linux-fsdevel
On Thu, Oct 17, 2024 at 04:17:00PM +0100, Matthew Wilcox (Oracle) wrote:
> Remove ecryptfs_get_locked_page() and call read_mapping_folio()
> directly. Use the folio throught this function.
>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Looks good.
Reviewed-by: Pankaj Raghav <p.raghav@samsung.com>
> ---
> fs/ecryptfs/ecryptfs_kernel.h | 1 -
> fs/ecryptfs/mmap.c | 16 ----------------
> fs/ecryptfs/read_write.c | 25 +++++++++++++------------
> 3 files changed, 13 insertions(+), 29 deletions(-)
>
> diff --git a/fs/ecryptfs/ecryptfs_kernel.h b/fs/ecryptfs/ecryptfs_kernel.h
> index 43f1b5ff987d..f04aa24f6bcd 100644
> --- a/fs/ecryptfs/ecryptfs_kernel.h
> +++ b/fs/ecryptfs/ecryptfs_kernel.h
> @@ -662,7 +662,6 @@ int ecryptfs_read_lower_page_segment(struct folio *folio_for_ecryptfs,
> pgoff_t page_index,
> size_t offset_in_page, size_t size,
> struct inode *ecryptfs_inode);
> -struct page *ecryptfs_get_locked_page(struct inode *inode, loff_t index);
> int ecryptfs_parse_packet_length(unsigned char *data, size_t *size,
> size_t *length_size);
> int ecryptfs_write_packet_length(char *dest, size_t size,
> diff --git a/fs/ecryptfs/mmap.c b/fs/ecryptfs/mmap.c
> index b7ef0bf563bd..ad535bf9d2f9 100644
> --- a/fs/ecryptfs/mmap.c
> +++ b/fs/ecryptfs/mmap.c
> @@ -22,22 +22,6 @@
> #include <linux/unaligned.h>
> #include "ecryptfs_kernel.h"
>
> -/*
> - * ecryptfs_get_locked_page
> - *
> - * Get one page from cache or lower f/s, return error otherwise.
> - *
> - * Returns locked and up-to-date page (if ok), with increased
> - * refcnt.
> - */
> -struct page *ecryptfs_get_locked_page(struct inode *inode, loff_t index)
> -{
> - struct page *page = read_mapping_page(inode->i_mapping, index, NULL);
> - if (!IS_ERR(page))
> - lock_page(page);
> - return page;
> -}
> -
> /*
> * This is where we encrypt the data and pass the encrypted data to
> * the lower filesystem. In OpenPGP-compatible mode, we operate on
> diff --git a/fs/ecryptfs/read_write.c b/fs/ecryptfs/read_write.c
> index 251e9f6c6972..cddfdfced879 100644
> --- a/fs/ecryptfs/read_write.c
> +++ b/fs/ecryptfs/read_write.c
> @@ -93,7 +93,6 @@ int ecryptfs_write_lower_page_segment(struct inode *ecryptfs_inode,
> int ecryptfs_write(struct inode *ecryptfs_inode, char *data, loff_t offset,
> size_t size)
> {
> - struct page *ecryptfs_page;
> struct ecryptfs_crypt_stat *crypt_stat;
> char *ecryptfs_page_virt;
> loff_t ecryptfs_file_size = i_size_read(ecryptfs_inode);
> @@ -111,6 +110,7 @@ int ecryptfs_write(struct inode *ecryptfs_inode, char *data, loff_t offset,
> else
> pos = offset;
> while (pos < (offset + size)) {
> + struct folio *ecryptfs_folio;
> pgoff_t ecryptfs_page_idx = (pos >> PAGE_SHIFT);
> size_t start_offset_in_page = (pos & ~PAGE_MASK);
> size_t num_bytes = (PAGE_SIZE - start_offset_in_page);
> @@ -130,17 +130,18 @@ int ecryptfs_write(struct inode *ecryptfs_inode, char *data, loff_t offset,
> if (num_bytes > total_remaining_zeros)
> num_bytes = total_remaining_zeros;
> }
> - ecryptfs_page = ecryptfs_get_locked_page(ecryptfs_inode,
> - ecryptfs_page_idx);
> - if (IS_ERR(ecryptfs_page)) {
> - rc = PTR_ERR(ecryptfs_page);
> + ecryptfs_folio = read_mapping_folio(ecryptfs_inode->i_mapping,
> + ecryptfs_page_idx, NULL);
> + if (IS_ERR(ecryptfs_folio)) {
> + rc = PTR_ERR(ecryptfs_folio);
> printk(KERN_ERR "%s: Error getting page at "
> "index [%ld] from eCryptfs inode "
> "mapping; rc = [%d]\n", __func__,
> ecryptfs_page_idx, rc);
> goto out;
> }
> - ecryptfs_page_virt = kmap_local_page(ecryptfs_page);
> + folio_lock(ecryptfs_folio);
> + ecryptfs_page_virt = kmap_local_folio(ecryptfs_folio, 0);
>
> /*
> * pos: where we're now writing, offset: where the request was
> @@ -164,17 +165,17 @@ int ecryptfs_write(struct inode *ecryptfs_inode, char *data, loff_t offset,
> data_offset += num_bytes;
> }
> kunmap_local(ecryptfs_page_virt);
> - flush_dcache_page(ecryptfs_page);
> - SetPageUptodate(ecryptfs_page);
> - unlock_page(ecryptfs_page);
> + flush_dcache_folio(ecryptfs_folio);
> + folio_mark_uptodate(ecryptfs_folio);
> + folio_unlock(ecryptfs_folio);
> if (crypt_stat->flags & ECRYPTFS_ENCRYPTED)
> - rc = ecryptfs_encrypt_page(ecryptfs_page);
> + rc = ecryptfs_encrypt_page(&ecryptfs_folio->page);
> else
> rc = ecryptfs_write_lower_page_segment(ecryptfs_inode,
> - ecryptfs_page,
> + &ecryptfs_folio->page,
> start_offset_in_page,
> data_offset);
> - put_page(ecryptfs_page);
> + folio_put(ecryptfs_folio);
> if (rc) {
> printk(KERN_ERR "%s: Error encrypting "
> "page; rc = [%d]\n", __func__, rc);
> --
> 2.43.0
>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 01/10] ecryptfs: Convert ecryptfs_writepage() to ecryptfs_writepages()
2024-10-18 6:23 ` Pankaj Raghav (Samsung)
@ 2024-10-25 17:56 ` Matthew Wilcox
0 siblings, 0 replies; 20+ messages in thread
From: Matthew Wilcox @ 2024-10-25 17:56 UTC (permalink / raw)
To: Pankaj Raghav (Samsung)
Cc: Tyler Hicks, ecryptfs, Christian Brauner, linux-fsdevel
On Fri, Oct 18, 2024 at 11:53:41AM +0530, Pankaj Raghav (Samsung) wrote:
> On Thu, Oct 17, 2024 at 04:16:56PM +0100, Matthew Wilcox (Oracle) wrote:
> > By adding a ->migrate_folio implementation, theree is no need to keep
> > the ->writepage implementation.
>
> Is this documented somewhere or is it common knowledge?
It's mentioned a few times in various other removals of ->writepage.
I don't think it's worth documenting, since the goal is to remove all
implementations of ->writepage (anon memory will continue to call
swap_writepage(), but it'll do it directly, not through ->writepage as
there will not be a ->writepage() any more).
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 02/10] ecryptfs: Use a folio throughout ecryptfs_read_folio()
2024-10-18 6:21 ` Pankaj Raghav (Samsung)
@ 2024-10-25 18:50 ` Matthew Wilcox
0 siblings, 0 replies; 20+ messages in thread
From: Matthew Wilcox @ 2024-10-25 18:50 UTC (permalink / raw)
To: Pankaj Raghav (Samsung)
Cc: Tyler Hicks, ecryptfs, Christian Brauner, linux-fsdevel
On Fri, Oct 18, 2024 at 11:51:11AM +0530, Pankaj Raghav (Samsung) wrote:
> On Thu, Oct 17, 2024 at 04:16:57PM +0100, Matthew Wilcox (Oracle) wrote:
> > ecryptfs_printk(KERN_DEBUG, "Unlocking page with index = [0x%.16lx]\n",
>
> Nit: Unlocking folio with index ..
Sure. I wasn't terribly careful because I don't think ecryptfs will
ever be converted to support multiple pages per folio, so they're
essentially the same thing. Same reason I didn't bother renaming any
functions.
^ permalink raw reply [flat|nested] 20+ messages in thread
end of thread, other threads:[~2024-10-25 18:50 UTC | newest]
Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-17 15:16 [PATCH 00/10] Convert ecryptfs to use folios Matthew Wilcox (Oracle)
2024-10-17 15:16 ` [PATCH 01/10] ecryptfs: Convert ecryptfs_writepage() to ecryptfs_writepages() Matthew Wilcox (Oracle)
2024-10-18 6:23 ` Pankaj Raghav (Samsung)
2024-10-25 17:56 ` Matthew Wilcox
2024-10-17 15:16 ` [PATCH 02/10] ecryptfs: Use a folio throughout ecryptfs_read_folio() Matthew Wilcox (Oracle)
2024-10-18 6:21 ` Pankaj Raghav (Samsung)
2024-10-25 18:50 ` Matthew Wilcox
2024-10-17 15:16 ` [PATCH 03/10] ecryptfs: Convert ecryptfs_copy_up_encrypted_with_header() to take a folio Matthew Wilcox (Oracle)
2024-10-18 3:43 ` kernel test robot
2024-10-18 6:33 ` Pankaj Raghav (Samsung)
2024-10-17 15:16 ` [PATCH 04/10] ecryptfs: Convert ecryptfs_read_lower_page_segment() " Matthew Wilcox (Oracle)
2024-10-17 15:17 ` [PATCH 05/10] ecryptfs: Convert ecryptfs_write() to use " Matthew Wilcox (Oracle)
2024-10-18 8:07 ` Pankaj Raghav (Samsung)
2024-10-17 15:17 ` [PATCH 06/10] ecryptfs: Convert ecryptfs_write_lower_page_segment() to take " Matthew Wilcox (Oracle)
2024-10-17 15:17 ` [PATCH 07/10] ecryptfs: Convert ecryptfs_encrypt_page() " Matthew Wilcox (Oracle)
2024-10-18 5:06 ` kernel test robot
2024-10-17 15:17 ` [PATCH 08/10] ecryptfs: Convert ecryptfs_decrypt_page() " Matthew Wilcox (Oracle)
2024-10-18 6:39 ` kernel test robot
2024-10-17 15:17 ` [PATCH 09/10] ecryptfs: Convert lower_offset_for_page() " Matthew Wilcox (Oracle)
2024-10-17 15:17 ` [PATCH 10/10] ecryptfs: Pass the folio index to crypt_extent() Matthew Wilcox (Oracle)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).