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
This commit is contained in:
Konstantin Belousov 2022-12-24 02:11:05 +02:00
parent 6fd6a0e342
commit 860399eb86

View file

@ -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);