git: 2c88fb783f75 - stable/13 - tmpfs: update changed/modified timestamps for truncates that do not change size

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Sat, 31 Dec 2022 01:03:13 UTC
The branch stable/13 has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=2c88fb783f754982d1ef964e6c73386d152e9d03

commit 2c88fb783f754982d1ef964e6c73386d152e9d03
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2022-12-24 00:11:05 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2022-12-31 01:02:42 +0000

    tmpfs: update changed/modified timestamps for truncates that do not change size
    
    PR:     268528
    
    (cherry picked from commit 860399eb86cc431412bfbce0ab76c6652e5b6c07)
---
 sys/fs/tmpfs/tmpfs_subr.c | 22 ++++++----------------
 1 file changed, 6 insertions(+), 16 deletions(-)

diff --git a/sys/fs/tmpfs/tmpfs_subr.c b/sys/fs/tmpfs/tmpfs_subr.c
index c278261c9453..f0ed8ee404fa 100644
--- a/sys/fs/tmpfs/tmpfs_subr.c
+++ b/sys/fs/tmpfs/tmpfs_subr.c
@@ -2161,29 +2161,19 @@ tmpfs_itimes(struct vnode *vp, const struct timespec *acc,
 int
 tmpfs_truncate(struct vnode *vp, off_t length)
 {
-	int error;
 	struct tmpfs_node *node;
+	int error;
 
-	node = VP_TO_TMPFS_NODE(vp);
-
-	if (length < 0) {
-		error = EINVAL;
-		goto out;
-	}
-
-	if (node->tn_size == length) {
-		error = 0;
-		goto out;
-	}
-
+	if (length < 0)
+		return (EINVAL);
 	if (length > VFS_TO_TMPFS(vp->v_mount)->tm_maxfilesize)
 		return (EFBIG);
 
-	error = tmpfs_reg_resize(vp, length, FALSE);
+	node = VP_TO_TMPFS_NODE(vp);
+	error = node->tn_size == length ? 0 : tmpfs_reg_resize(vp, length,
+	    FALSE);
 	if (error == 0)
 		node->tn_status |= TMPFS_NODE_CHANGED | TMPFS_NODE_MODIFIED;
-
-out:
 	tmpfs_update(vp);
 
 	return (error);