[PATCH 7/7] ecryptfs: refer to folios in comments and printk strings

From: Tal Zussman

Date: Wed Oct 14 2026 - 21:40:46 EST


Update the comments and printk strings to refer to folios instead of
pages. While at it, join the strings that were split across lines, use
pr_err() for the printk(KERN_ERR) calls among them, and fix the block
comment style.

Signed-off-by: Tal Zussman <tz2294@xxxxxxxxxxxx>
---
fs/ecryptfs/crypto.c | 17 ++++++++---------
fs/ecryptfs/mmap.c | 36 +++++++++++++++++-------------------
fs/ecryptfs/read_write.c | 36 ++++++++++++++++++------------------
3 files changed, 43 insertions(+), 46 deletions(-)

diff --git a/fs/ecryptfs/crypto.c b/fs/ecryptfs/crypto.c
index bbaeb9a38db0..d426dc95517c 100644
--- a/fs/ecryptfs/crypto.c
+++ b/fs/ecryptfs/crypto.c
@@ -214,7 +214,7 @@ static int crypt_scatterlist(struct ecryptfs_crypt_stat *crypt_stat,
/*
* lower_offset_for_folio
*
- * Convert an eCryptfs page index into a lower byte offset
+ * Convert an eCryptfs folio index into a lower byte offset
*/
static loff_t lower_offset_for_folio(struct ecryptfs_crypt_stat *crypt_stat,
struct folio *folio)
@@ -263,9 +263,8 @@ static int crypt_extent(struct ecryptfs_crypt_stat *crypt_stat,
rc = crypt_scatterlist(crypt_stat, dst_sgp, &src_sg, extent_size,
extent_iv, op);
if (rc < 0) {
- printk(KERN_ERR "%s: Error attempting to crypt page with "
- "page_index = [%ld], extent_offset = [%ld]; "
- "rc = [%d]\n", __func__, page_index, extent_offset, rc);
+ pr_err("%s: Error attempting to crypt folio with page_index = [%ld], extent_offset = [%ld]; rc = [%d]\n",
+ __func__, page_index, extent_offset, rc);
goto out;
}
rc = 0;
@@ -279,8 +278,8 @@ static int crypt_extent(struct ecryptfs_crypt_stat *crypt_stat,
* decrypted content that needs to be encrypted (to a temporary
* buffer; not in place) and written out to the lower file
*
- * Encrypt an eCryptfs page. This is done on a per-extent basis. Note
- * that eCryptfs pages may straddle the lower pages -- for instance,
+ * Encrypt an eCryptfs folio. This is done on a per-extent basis. Note
+ * that eCryptfs folios may straddle the lower pages -- for instance,
* if the file was created on a machine with an 8K page size
* (resulting in an 8K header), and then the file is copied onto a
* host with a 32K page size, then when reading page 0 of the eCryptfs
@@ -341,10 +340,10 @@ int ecryptfs_encrypt_folio(struct folio *folio)
* ecryptfs_decrypt_folio
* @folio: Folio mapped from the eCryptfs inode for the file; data read
* and decrypted from the lower file will be written into this
- * page
+ * folio
*
- * Decrypt an eCryptfs page. This is done on a per-extent basis. Note
- * that eCryptfs pages may straddle the lower pages -- for instance,
+ * Decrypt an eCryptfs folio. This is done on a per-extent basis. Note
+ * that eCryptfs folios may straddle the lower pages -- for instance,
* if the file was created on a machine with an 8K page size
* (resulting in an 8K header), and then the file is copied onto a
* host with a 32K page size, then when reading page 0 of the eCryptfs
diff --git a/fs/ecryptfs/mmap.c b/fs/ecryptfs/mmap.c
index d841610644ed..305231cd5336 100644
--- a/fs/ecryptfs/mmap.c
+++ b/fs/ecryptfs/mmap.c
@@ -188,16 +188,16 @@ static int ecryptfs_read_folio(struct file *file, struct folio *folio)
folio->index, 0, folio_size(folio),
inode);
if (err) {
- printk(KERN_ERR "Error reading page; err = "
- "[%d]\n", err);
+ pr_err("Error reading folio; err = [%d]\n",
+ err);
goto out;
}
}
} else {
err = ecryptfs_decrypt_folio(folio);
if (err) {
- ecryptfs_printk(KERN_ERR, "Error decrypting page; "
- "err = [%d]\n", err);
+ ecryptfs_printk(KERN_ERR, "Error decrypting folio; err = [%d]\n",
+ err);
goto out;
}
}
@@ -264,8 +264,7 @@ static int ecryptfs_write_begin(const struct kiocb *iocb,
rc = ecryptfs_read_lower_folio_segment(
folio, index, 0, PAGE_SIZE, mapping->host);
if (rc) {
- printk(KERN_ERR "%s: Error attempting to read "
- "lower page segment; rc = [%d]\n",
+ pr_err("%s: Error attempting to read lower folio segment; rc = [%d]\n",
__func__, rc);
folio_clear_uptodate(folio);
goto out;
@@ -291,8 +290,7 @@ static int ecryptfs_write_begin(const struct kiocb *iocb,
folio, index, 0, PAGE_SIZE,
mapping->host);
if (rc) {
- printk(KERN_ERR "%s: Error reading "
- "page; rc = [%d]\n",
+ pr_err("%s: Error reading folio; rc = [%d]\n",
__func__, rc);
folio_clear_uptodate(folio);
goto out;
@@ -307,9 +305,7 @@ static int ecryptfs_write_begin(const struct kiocb *iocb,
} else if (len < PAGE_SIZE) {
rc = ecryptfs_decrypt_folio(folio);
if (rc) {
- printk(KERN_ERR "%s: Error decrypting "
- "page at index [%ld]; "
- "rc = [%d]\n",
+ pr_err("%s: Error decrypting folio at index [%ld]; rc = [%d]\n",
__func__, folio->index, rc);
folio_clear_uptodate(folio);
goto out;
@@ -333,8 +329,10 @@ static int ecryptfs_write_begin(const struct kiocb *iocb,
}
}
}
- /* Writing to a new page, and creating a small hole from start
- * of page? Zero it out. */
+ /*
+ * Writing to a new folio, and creating a small hole from start
+ * of folio? Zero it out.
+ */
if ((i_size_read(mapping->host) == prev_page_end_size)
&& (pos != 0))
folio_zero_range(folio, 0, PAGE_SIZE);
@@ -443,8 +441,8 @@ static int ecryptfs_write_end(const struct kiocb *iocb,
&ecryptfs_inode_to_private(ecryptfs_inode)->crypt_stat;
int rc;

- ecryptfs_printk(KERN_DEBUG, "Calling fill_zeros_to_end_of_folio"
- "(page w/ index = [0x%.16lx], to = [%d])\n", index, to);
+ ecryptfs_printk(KERN_DEBUG, "Calling fill_zeros_to_end_of_folio(folio w/ index = [0x%.16lx], to = [%d])\n",
+ index, to);
if (!(crypt_stat->flags & ECRYPTFS_ENCRYPTED)) {
rc = ecryptfs_write_lower_folio_segment(ecryptfs_inode,
folio, 0, to);
@@ -465,14 +463,14 @@ static int ecryptfs_write_end(const struct kiocb *iocb,
/* Fills in zeros if 'to' goes beyond inode size */
rc = fill_zeros_to_end_of_folio(folio, to);
if (rc) {
- ecryptfs_printk(KERN_WARNING, "Error attempting to fill "
- "zeros in page with index = [0x%.16lx]\n", index);
+ ecryptfs_printk(KERN_WARNING, "Error attempting to fill zeros in folio with index = [0x%.16lx]\n",
+ index);
goto out;
}
rc = ecryptfs_encrypt_folio(folio);
if (rc) {
- ecryptfs_printk(KERN_WARNING, "Error encrypting page (upper "
- "index [0x%.16lx])\n", index);
+ ecryptfs_printk(KERN_WARNING, "Error encrypting folio (upper index [0x%.16lx])\n",
+ index);
goto out;
}
if (pos + copied > i_size_read(ecryptfs_inode)) {
diff --git a/fs/ecryptfs/read_write.c b/fs/ecryptfs/read_write.c
index 611f74061441..a1949c769225 100644
--- a/fs/ecryptfs/read_write.c
+++ b/fs/ecryptfs/read_write.c
@@ -48,8 +48,8 @@ int ecryptfs_write_lower(struct inode *ecryptfs_inode, char *data,
* @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
+ * Determines the byte offset in the file for the given folio and
+ * offset within the folio, maps the folio, and makes the call to write
* the contents of @folio_for_lower to the lower inode.
*
* Returns zero on success; non-zero otherwise
@@ -80,7 +80,7 @@ int ecryptfs_write_lower_folio_segment(struct inode *ecryptfs_inode,
* @size: The number of bytes to write from @data
*
* Write an arbitrary amount of data to an arbitrary location in the
- * eCryptfs inode page cache. This is done on a page-by-page, and then
+ * eCryptfs inode page cache. This is done on a folio-by-folio, and then
* by an extent-by-extent, basis; individual extents are encrypted and
* written to the lower page cache (via VFS writes). This function
* takes care of all the address translation to locations in the lower
@@ -133,10 +133,8 @@ int ecryptfs_write(struct inode *ecryptfs_inode, char *data, loff_t offset,
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);
+ pr_err("%s: Error getting folio at index [%ld] from eCryptfs inode mapping; rc = [%d]\n",
+ __func__, ecryptfs_page_idx, rc);
goto out;
}
folio_lock(ecryptfs_folio);
@@ -146,11 +144,13 @@ int ecryptfs_write(struct inode *ecryptfs_inode, char *data, loff_t offset,
* pos: where we're now writing, offset: where the request was
* If current pos is before request, we are filling zeros
* If we are at or beyond request, we are writing the *data*
- * If we're in a fresh page beyond eof, zero it in either case
+ * If we're in a fresh folio beyond eof, zero it in either case
*/
if (pos < offset || !start_offset_in_page) {
- /* We are extending past the previous end of the file.
- * Fill in zero values to the end of the page */
+ /*
+ * We are extending past the previous end of the file.
+ * Fill in zero values to the end of the folio.
+ */
memset(((char *)ecryptfs_page_virt
+ start_offset_in_page), 0,
PAGE_SIZE - start_offset_in_page);
@@ -176,8 +176,8 @@ int ecryptfs_write(struct inode *ecryptfs_inode, char *data, loff_t offset,
data_offset);
folio_put(ecryptfs_folio);
if (rc) {
- printk(KERN_ERR "%s: Error encrypting "
- "page; rc = [%d]\n", __func__, rc);
+ pr_err("%s: Error encrypting folio; rc = [%d]\n",
+ __func__, rc);
goto out;
}
pos += num_bytes;
@@ -230,16 +230,16 @@ int ecryptfs_read_lower(char *data, loff_t offset, size_t size,
* ecryptfs_read_lower_folio_segment
* @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
+ * @page_index: Page index in @folio_for_ecryptfs from which to start
* writing
- * @offset_in_page: Offset in @page_for_ecryptfs from which to start
+ * @offset_in_page: Offset in @folio_for_ecryptfs from which to start
* writing
- * @size: The number of bytes to write into @page_for_ecryptfs
+ * @size: The number of bytes to write into @folio_for_ecryptfs
* @ecryptfs_inode: The eCryptfs inode
*
- * Determines the byte offset in the file for the given page and
- * offset within the page, maps the page, and makes the call to read
- * the contents of @page_for_ecryptfs from the lower inode.
+ * Determines the byte offset in the file for the given folio and
+ * offset within the folio, maps the folio, and makes the call to read
+ * the contents of @folio_for_ecryptfs from the lower inode.
*
* Returns zero on success; non-zero otherwise
*/

--
2.39.5