diff options
author | Konstantin Belousov <kib@FreeBSD.org> | 2022-12-24 00:11:05 +0000 |
---|---|---|
committer | Konstantin Belousov <kib@FreeBSD.org> | 2022-12-24 06:32:48 +0000 |
commit | 860399eb86cc431412bfbce0ab76c6652e5b6c07 (patch) | |
tree | 16bc388e6b8ae5f2259ad0fbe0b76e8258385d57 | |
parent | 6fd6a0e342fbfb8513ae56105cf0f85f55c6276e (diff) | |
download | src-860399eb86cc431412bfbce0ab76c6652e5b6c07.tar.gz src-860399eb86cc431412bfbce0ab76c6652e5b6c07.zip |
tmpfs: update changed/modified timestamps for truncates that do not change size
While there, move all error checks into the common place at the start,
and eliminate the 'out' label.
PR: 268528
Analyzed and tested by: Mark Millard <marklmi@yahoo.com>
Reviewed by: mckusick
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D37866
-rw-r--r-- | sys/fs/tmpfs/tmpfs_subr.c | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/sys/fs/tmpfs/tmpfs_subr.c b/sys/fs/tmpfs/tmpfs_subr.c index ef558c424914..7afabf6e4baa 100644 --- a/sys/fs/tmpfs/tmpfs_subr.c +++ b/sys/fs/tmpfs/tmpfs_subr.c @@ -2325,29 +2325,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); |