From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796387197; b=cA+wwdV+0/rRhxmqEpZ2DzxlhOiMVLe37OVj621OPXaiX18C4r8Sqehp3vaAoTSPUWHu R/NVRc2avwKK2z18ASdC+UNgm1YndJ/QoCP3ky467KhNO+qHHokBYSgQTQ2YlPEfwbom6 rGBl1u8F3QMEGw3YsdyyOHPJ7K5K+Yl44V50cyrEE1849ojmD51CEN6gyPZ7VVxanSpyU HJpWI0r1qFzKjlli2bKi7r3fYNTVMUH4LWyldmnl/uppxhHVQO/7HuUZEmK5DY98+ozbD VwgUJW0UfPhImVh/yglaIPJJgnZoykZMTdUSqFjRU1psOMlI9yQcfEwzCr9TKrOAH3w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796387197; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=rKR11TkWzgU/siasgO2XXt6KxgJU2o3lc6OtH2y05Tw=; b=DNQDKGLcWqsYpIyx94BKw5uQzxjV/9hai32VxMYRLZjm7aHRN7cyznULwHMCUfF2y77+ 3CsRIaCLf4YhEMWhPom1oEcmRNgxBK28hwPQ8rN0MNHbakaaA/R7a/MXK+3fhfqG4h5j6 I8m0GsLICc8ebS018iPZHBomuYZxh5MFcAFeGVgsw/Xc0yQSf3N38xVPvHSEPphuefuwE cdVANLgUTN/+8qgkjpflBdBVZPRj5QQRsiu0/JHfd2G56rAS0LG1q8i0i1xb/v862y9wC /9LKkAyN15p9kroxlR0KZQPm3C3pTcT0js5qtFrtKO8IxxzSWqBilrOxdseOSoMCNgg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=tfRYriIW; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E49C2606A322; Fri, 4 Dec 2026 12:26:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=tfRYriIW Received: by smtp.kernel.org (Postfix) with ESMTPSA id 59D421F00935; Fri, 4 Dec 2026 12:26:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796387196; bh=rKR11TkWzgU/siasgO2XXt6KxgJU2o3lc6OtH2y05Tw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=tfRYriIWfuSdNu3wecENAN+6NYLvAKRPRw6ymk5ZOFKwG4X6Lg53EYQukHGTfgOmA kfs0EDjLjdf6PVqF645fa5yo7I3j+Gv1EMh0CrcmsNFMhUUhedwNZUXd0q0tFHdtdR SKTGK8/yH2gSSTQKxxZh/bkiSmkY1jg9dJMG82SA= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Hungyu Lin , Jeff Layton , "Christian Brauner (Amutable)" , Sasha Levin Subject: [PATCH 6.1 0141/1059] vfs: preserve subsecond timestamps at filesystem time limits Date: Fri, 4 Dec 2026 18:54:32 +0900 Message-ID: <20261204100647.869490017@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Hungyu Lin [ Upstream commit 55a0c91000646b008261e3b1e15d1e774f3026e4 ] timestamp_truncate() clears tv_nsec whenever the clamped seconds equal either filesystem time limit. This also drops the fractional part of timestamps whose seconds were already within the supported range. For example, setting a JFS mtime to 0.123456789 produces 0.000000000, although the filesystem can store the requested value. Utilities such as touch and cp -p consequently lose valid subsecond timestamps when preserving these endpoint values. Timestamps strictly between the filesystem limits are unaffected. Only clear tv_nsec when clamping actually changes tv_sec. Continue to truncate in-range nanoseconds to the filesystem's timestamp granularity, including when the seconds equal either endpoint. Ben Hutchings suggested comparing clamped and original seconds in the 2019 utimes review. That caller was switched to timestamp_truncate(), but the helper retained its endpoint equality check. Link: https://lore.kernel.org/lkml/12c095e595836a7ff7f2c7b2a32cb5544dd29b55.camel@codethink.co.uk/ Fixes: 50e17c000c46 ("vfs: Add timestamp_truncate() api") Signed-off-by: Hungyu Lin Link: https://patch.msgid.link/20261101113815.52911-1-dennylin0707@gmail.com Reviewed-by: Jeff Layton Signed-off-by: Christian Brauner (Amutable) Signed-off-by: Sasha Levin --- fs/inode.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/inode.c b/fs/inode.c index 08fbf3648ce78..c21db9bf09d4d 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -2512,9 +2512,10 @@ struct timespec64 timestamp_truncate(struct timespec64 t, struct inode *inode) { struct super_block *sb = inode->i_sb; unsigned int gran = sb->s_time_gran; + time64_t seconds = t.tv_sec; t.tv_sec = clamp(t.tv_sec, sb->s_time_min, sb->s_time_max); - if (unlikely(t.tv_sec == sb->s_time_max || t.tv_sec == sb->s_time_min)) + if (unlikely(t.tv_sec != seconds)) t.tv_nsec = 0; /* Avoid division in the common cases 1 ns and 1 s. */ -- 2.53.0