From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from fout-a5-smtp.messagingengine.com (fout-a5-smtp.messagingengine.com [103.168.172.148]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6F45C3559C9; Mon, 6 Apr 2026 06:09:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.148 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775455756; cv=none; b=FF9+twHZ2Rg88tRZdrf0slKnduxpmUrc0O59+2bxg61krWLovFT/I4+aenYcumZka6PXzKwHMc/iccm5f9TDUAH0U7WoGo0uzx3joDd/9N5hYMk9VZwdCx11qElSZYfapBrbbejsWMOsoLOMZrob4BWyDKRy2SW2O1y+ob9QGTk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775455756; c=relaxed/simple; bh=vLSpNgH+np/nRXsfyuGV99zjujfwgAD5u9LBurNsNMc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=FZvbcmTzICLeXrJMaZSsfqRw6u1T/bfeOXggXvlPgbZhy9kavFhZqBhth/f0h5mprOSja/3lPlM3/dpFpwlaXVJ4Uq4GaFQmoiU8+0fUdmNejPOeARUxi6NmOO4H3k8cm5FevPfMF2KGQjtwUvtBl7Q4VKH6oOwLJJulgWasCpM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tyhicks.com; spf=pass smtp.mailfrom=tyhicks.com; dkim=pass (2048-bit key) header.d=tyhicks.com header.i=@tyhicks.com header.b=mBZDzHNd; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=ktjtSkAU; arc=none smtp.client-ip=103.168.172.148 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tyhicks.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tyhicks.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tyhicks.com header.i=@tyhicks.com header.b="mBZDzHNd"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="ktjtSkAU" Received: from phl-compute-06.internal (phl-compute-06.internal [10.202.2.46]) by mailfout.phl.internal (Postfix) with ESMTP id 9C44CEC0141; Mon, 6 Apr 2026 02:09:14 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-06.internal (MEProxy); Mon, 06 Apr 2026 02:09:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tyhicks.com; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm1; t=1775455754; x=1775542154; bh=4LGqyFu0T1 m8auGh4JIjH9wjPcINe7epog/BgmIdCXY=; b=mBZDzHNd0UZ3cdjEy/AulWTkwB 1iLYnO+2F+BF0aQlQ3cLYQe0vJ1NLOjxdwH25/ywKB0rRDXKyw9TYMQcDXnU/Z/k gW7IwDmi86B3/J05MWZr2hKRJwmCByKjALgh3gvoVMQT5DgkAKGVjdRK2KYAqUpj 1Izu+sGZ1FiFT0VLTVFpHUEmo13sd8ujsy6STgOktKGiPlPpj+uZsswEZW+vT7Jx oyyUugDAFQabByxBCHz9M1DT6WjdI+lTFcaUpgcltLHm9xXrcwcj5i3DAT2x3TWZ m0gTQSTK0HkRd35a9+XvO9seYJnf2Z4Aqu1fV5qw2Xb4Bk90P3PvE/yB3Iug== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t= 1775455754; x=1775542154; bh=4LGqyFu0T1m8auGh4JIjH9wjPcINe7epog/ BgmIdCXY=; b=ktjtSkAUACeqxfkXsEwo4cXdCXvO5lqFH52tLGpCdDcsZ2EyyJP eCw3Ug+2Xad+UwWvTbmVMExdIzcyZIIobxzHrat3dyXVpZaKzWdC68ZSR2PxnWwX BliLFVs2RpZy3oqrxFBkhfb0Vuac+fjcCBSakzAhoB4W1dfASCG7Xrgxp61j13Pq qa+lhO1wqT3IwZIjoymeei+n49pmn706E+OvimcD9wZw3vLgWu30SO1ohNGp4AcG WQmfabhRNV8p/xl5fCiXaD3+az8mqmtVSGbK0nRi5q4wQHXKppGEP4dfEQT601xI BWOGnJKn04D1O7MiwZoZbmXS9P5Ea0T4xXw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefhedrtddtgdduieelfecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjug hrpeffhffvvefukfhfgggtuggjsehttdertddttddvnecuhfhrohhmpefvhihlvghrucfj ihgtkhhsuceotghouggvsehthihhihgtkhhsrdgtohhmqeenucggtffrrghtthgvrhhnpe dvhedvtddthfefhfdtgfelheefgefgudejueevkeduveekvdegjedttdefgfelieenucev lhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegtohguvgesth ihhhhitghkshdrtghomhdpnhgspghrtghpthhtohepfedpmhhouggvpehsmhhtphhouhht pdhrtghpthhtohephhgthheslhhsthdruggvpdhrtghpthhtohepvggtrhihphhtfhhsse hvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqfhhsuggvvhgv lhesvhhgvghrrdhkvghrnhgvlhdrohhrgh X-ME-Proxy: Feedback-ID: i78e14604:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 6 Apr 2026 02:09:14 -0400 (EDT) Date: Mon, 6 Apr 2026 01:09:12 -0500 From: Tyler Hicks To: Christoph Hellwig Cc: ecryptfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: Re: [PATCH 6/7] ecryptfs: merge ecryptfs_inode_newsize_ok into truncate_upper Message-ID: References: <20260331153752.4049454-1-hch@lst.de> <20260331153752.4049454-7-hch@lst.de> Precedence: bulk X-Mailing-List: ecryptfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260331153752.4049454-7-hch@lst.de> On 2026-03-31 17:37:27, Christoph Hellwig wrote: > Both callers of ecryptfs_inode_newsize_ok call truncate_upper right > after. Merge ecryptfs_inode_newsize_ok into truncate_upper to simplify > the logic. > > Signed-off-by: Christoph Hellwig This one looks good to me. Tyler > --- > fs/ecryptfs/inode.c | 53 +++++++++++++++------------------------------ > 1 file changed, 17 insertions(+), 36 deletions(-) > > diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c > index a7dc25fae8ee..c87ee3c6ecba 100644 > --- a/fs/ecryptfs/inode.c > +++ b/fs/ecryptfs/inode.c > @@ -736,6 +736,23 @@ static int truncate_upper(struct dentry *dentry, struct iattr *lower_ia) > return 0; > } > > + crypt_stat = &ecryptfs_inode_to_private(inode)->crypt_stat; > + lower_size_before_truncate = > + upper_size_to_lower_size(crypt_stat, i_size); > + lower_size_after_truncate = > + upper_size_to_lower_size(crypt_stat, lower_ia->ia_size); > + if (lower_size_after_truncate > lower_size_before_truncate) { > + /* > + * The eCryptfs inode and the new *lower* size are mixed here > + * because we may not have the lower i_mutex held and/or it may > + * not be appropriate to call inode_newsize_ok() with inodes > + * from other filesystems. > + */ > + rc = inode_newsize_ok(inode, lower_size_after_truncate); > + if (rc) > + return rc; > + } > + > rc = ecryptfs_get_lower_file(dentry, inode); > if (rc) > return rc; > @@ -754,7 +771,6 @@ static int truncate_upper(struct dentry *dentry, struct iattr *lower_ia) > goto out; > } > > - crypt_stat = &ecryptfs_inode_to_private(d_inode(dentry))->crypt_stat; > if (!(crypt_stat->flags & ECRYPTFS_ENCRYPTED)) { > truncate_setsize(inode, lower_ia->ia_size); > goto out; > @@ -787,42 +803,15 @@ static int truncate_upper(struct dentry *dentry, struct iattr *lower_ia) > * We are reducing the size of the ecryptfs file, and need to know if we > * need to reduce the size of the lower file. > */ > - lower_size_before_truncate = > - upper_size_to_lower_size(crypt_stat, i_size); > - lower_size_after_truncate = > - upper_size_to_lower_size(crypt_stat, lower_ia->ia_size); > if (lower_size_after_truncate < lower_size_before_truncate) > lower_ia->ia_size = lower_size_after_truncate; > else > lower_ia->ia_valid &= ~ATTR_SIZE; > - > out: > ecryptfs_put_lower_file(inode); > return rc; > } > > -static int ecryptfs_inode_newsize_ok(struct inode *inode, loff_t offset) > -{ > - struct ecryptfs_crypt_stat *crypt_stat; > - loff_t lower_oldsize, lower_newsize; > - > - crypt_stat = &ecryptfs_inode_to_private(inode)->crypt_stat; > - lower_oldsize = upper_size_to_lower_size(crypt_stat, > - i_size_read(inode)); > - lower_newsize = upper_size_to_lower_size(crypt_stat, offset); > - if (lower_newsize > lower_oldsize) { > - /* > - * The eCryptfs inode and the new *lower* size are mixed here > - * because we may not have the lower i_mutex held and/or it may > - * not be appropriate to call inode_newsize_ok() with inodes > - * from other filesystems. > - */ > - return inode_newsize_ok(inode, lower_newsize); > - } > - > - return 0; > -} > - > /** > * ecryptfs_truncate > * @dentry: The ecryptfs layer dentry > @@ -841,10 +830,6 @@ int ecryptfs_truncate(struct dentry *dentry, loff_t new_length) > }; > int rc; > > - rc = ecryptfs_inode_newsize_ok(d_inode(dentry), new_length); > - if (rc) > - return rc; > - > rc = truncate_upper(dentry, &lower_ia); > if (!rc && lower_ia.ia_valid & ATTR_SIZE) { > struct dentry *lower_dentry = ecryptfs_dentry_to_lower(dentry); > @@ -936,10 +921,6 @@ static int ecryptfs_setattr(struct mnt_idmap *idmap, > 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, &lower_ia); > if (rc < 0) > goto out; > -- > 2.47.3 >