svn commit: r345847 - head/sys/fs/msdosfs
Konstantin Belousov
kib at FreeBSD.org
Tue Sep 3 14:06:31 UTC 2019
Author: kib
Date: Wed Apr 3 17:02:18 2019
New Revision: 345847
URL: https://svnweb.freebsd.org/changeset/base/345847
Log:
msdosfs: zero tail of the last block on truncation for VREG vnodes as well.
Despite the call to vtruncbuf() from detrunc(), which results in
zeroing part of the partial page after EOF, there still is a
possibility to retain the stale data which is revived on file
enlargement. If the filesystem block size is greater than the page
size, partial block might keep other after-EOF pages wired and they
get reused then. Fix it by zeroing whole part of the partial buffer
after EOF, not relying on vnode_pager_setsize().
PR: 236977
Reported by: asomers
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Modified:
head/sys/fs/msdosfs/msdosfs_denode.c
Modified: head/sys/fs/msdosfs/msdosfs_denode.c
==============================================================================
--- head/sys/fs/msdosfs/msdosfs_denode.c Wed Apr 3 13:59:35 2019 (r345846)
+++ head/sys/fs/msdosfs/msdosfs_denode.c Wed Apr 3 17:02:18 2019 (r345847)
@@ -405,19 +405,21 @@ detrunc(struct denode *dep, u_long length, int flags,
bn = cntobn(pmp, eofentry);
error = bread(pmp->pm_devvp, bn, pmp->pm_bpcluster,
NOCRED, &bp);
- if (error) {
- brelse(bp);
+ } else {
+ error = bread(DETOV(dep), de_cluster(pmp, length),
+ pmp->pm_bpcluster, cred, &bp);
+ }
+ if (error) {
#ifdef MSDOSFS_DEBUG
- printf("detrunc(): bread fails %d\n", error);
+ printf("detrunc(): bread fails %d\n", error);
#endif
- return (error);
- }
- memset(bp->b_data + boff, 0, pmp->pm_bpcluster - boff);
- if (flags & IO_SYNC)
- bwrite(bp);
- else
- bdwrite(bp);
+ return (error);
}
+ memset(bp->b_data + boff, 0, pmp->pm_bpcluster - boff);
+ if ((flags & IO_SYNC) != 0)
+ bwrite(bp);
+ else
+ bdwrite(bp);
}
/*
More information about the svn-src-all
mailing list