public inbox for ecryptfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Tyler Hicks <code@tyhicks.com>
Cc: ecryptfs@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: [PATCH 4/7] ecryptfs: combine the two ATTR_SIZE blocks in ecryptfs_setattr
Date: Tue, 31 Mar 2026 17:37:25 +0200	[thread overview]
Message-ID: <20260331153752.4049454-5-hch@lst.de> (raw)
In-Reply-To: <20260331153752.4049454-1-hch@lst.de>

Simplify the logic in ecryptfs_setattr by combining the two ATTR_SIZE
blocks.  This initializes lower_ia before the size check, which is
obviously correct as the size check doesn't look at it.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/ecryptfs/inode.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
index 57df35a22e9c..7a3da72eb3c6 100644
--- a/fs/ecryptfs/inode.c
+++ b/fs/ecryptfs/inode.c
@@ -934,16 +934,15 @@ static int ecryptfs_setattr(struct mnt_idmap *idmap,
 	rc = setattr_prepare(&nop_mnt_idmap, dentry, ia);
 	if (rc)
 		goto out;
-	if (ia->ia_valid & ATTR_SIZE) {
-		rc = ecryptfs_inode_newsize_ok(inode, ia->ia_size);
-		if (rc)
-			goto out;
-	}
 
 	memcpy(&lower_ia, ia, sizeof(lower_ia));
 	if (ia->ia_valid & ATTR_FILE)
 		lower_ia.ia_file = ecryptfs_file_to_lower(ia->ia_file);
 	if (ia->ia_valid & ATTR_SIZE) {
+		rc = ecryptfs_inode_newsize_ok(inode, ia->ia_size);
+		if (rc)
+			goto out;
+
 		rc = truncate_upper(dentry, ia, &lower_ia);
 		if (rc < 0)
 			goto out;
-- 
2.47.3


  parent reply	other threads:[~2026-03-31 15:38 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-31 15:37 cleanup truncate handling in ecryptfs Christoph Hellwig
2026-03-31 15:37 ` [PATCH 1/7] ecryptfs: streamline truncate_upper Christoph Hellwig
2026-04-06  5:52   ` Tyler Hicks
2026-04-06  6:28     ` Christoph Hellwig
2026-03-31 15:37 ` [PATCH 2/7] ecryptfs: cleanup ecryptfs_setattr Christoph Hellwig
2026-04-06  5:52   ` Tyler Hicks
2026-03-31 15:37 ` [PATCH 3/7] ecryptfs: use ZERO_PAGE instead of allocating zeroed memory in truncate_upper Christoph Hellwig
2026-04-06  5:52   ` Tyler Hicks
2026-03-31 15:37 ` Christoph Hellwig [this message]
2026-04-06  5:53   ` [PATCH 4/7] ecryptfs: combine the two ATTR_SIZE blocks in ecryptfs_setattr Tyler Hicks
2026-03-31 15:37 ` [PATCH 5/7] ecryptfs: sanitize struct iattr handling in truncate_upper Christoph Hellwig
2026-04-06  5:58   ` Tyler Hicks
2026-04-06  6:22     ` Tyler Hicks
2026-04-06  6:27       ` Christoph Hellwig
2026-04-06  6:59         ` Tyler Hicks
2026-03-31 15:37 ` [PATCH 6/7] ecryptfs: merge ecryptfs_inode_newsize_ok into truncate_upper Christoph Hellwig
2026-04-06  6:09   ` Tyler Hicks
2026-03-31 15:37 ` [PATCH 7/7] ecryptfs: call notify_change from truncate_upper Christoph Hellwig
2026-04-06  6:52   ` Tyler Hicks
  -- strict thread matches above, loose matches on Subject: below --
2026-04-07 14:02 cleanup truncate handling in ecryptfs v2 Christoph Hellwig
2026-04-07 14:02 ` [PATCH 4/7] ecryptfs: combine the two ATTR_SIZE blocks in ecryptfs_setattr Christoph Hellwig
2026-04-08  6:06 cleanup truncate handling in ecryptfs v3 Christoph Hellwig
2026-04-08  6:06 ` [PATCH 4/7] ecryptfs: combine the two ATTR_SIZE blocks in ecryptfs_setattr Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260331153752.4049454-5-hch@lst.de \
    --to=hch@lst.de \
    --cc=code@tyhicks.com \
    --cc=ecryptfs@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox