msdosfs: correct handling of vnode pager size on file extension error

If extension fails, vnode pager recorded size might be left increased.
Only update vnode pager when extension is past the point of no rollback.

Reviewed by:	markj
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D38549
This commit is contained in:
Konstantin Belousov 2023-02-10 06:58:43 +02:00
parent 020e8a4d06
commit e59180ea09

View File

@ -386,10 +386,8 @@ detrunc(struct denode *dep, u_long length, int flags, struct ucred *cred)
return (EINVAL);
}
if (dep->de_FileSize < length) {
vnode_pager_setsize(DETOV(dep), length);
if (dep->de_FileSize < length)
return (deextend(dep, length, cred));
}
/*
* If the desired length is 0 then remember the starting cluster of
@ -530,6 +528,7 @@ deextend(struct denode *dep, u_long length, struct ucred *cred)
return (error);
}
}
vnode_pager_setsize(DETOV(dep), length);
dep->de_FileSize = length;
dep->de_flag |= DE_UPDATE | DE_MODIFIED;
return (deupdat(dep, !DOINGASYNC(DETOV(dep))));