git: 79802c179a5d - stable/12 - msdosfs: zero partially valid extended cluster
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 11 Sep 2023 18:50:28 UTC
The branch stable/12 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=79802c179a5de367a0c16b07e746b280d4813a2c commit 79802c179a5de367a0c16b07e746b280d4813a2c Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2023-07-06 01:51:07 +0000 Commit: Ed Maste <emaste@FreeBSD.org> CommitDate: 2023-09-11 18:05:09 +0000 msdosfs: zero partially valid extended cluster (cherry picked from commit 7e4c6b2163fbed6be92b1e19f0eec4da973cfaec) (cherry picked from commit 868f3eadc5e0b50863c13457074ac1a0b03958dd) --- sys/fs/msdosfs/msdosfs_denode.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/sys/fs/msdosfs/msdosfs_denode.c b/sys/fs/msdosfs/msdosfs_denode.c index 57d1c96a561b..3b4e809d6196 100644 --- a/sys/fs/msdosfs/msdosfs_denode.c +++ b/sys/fs/msdosfs/msdosfs_denode.c @@ -477,6 +477,7 @@ deextend(struct denode *dep, u_long length, struct ucred *cred) struct msdosfsmount *pmp = dep->de_pmp; struct vnode *vp = DETOV(dep); struct buf *bp; + off_t eof_clusteroff; u_long count; int error; @@ -515,13 +516,19 @@ deextend(struct denode *dep, u_long length, struct ucred *cred) * B_CACHE | B_DELWRI but with invalid pages, and cannot be * neither written out nor validated. * - * Fix it by proactively clearing extended pages. + * Fix it by proactively clearing extended pages. Need to do + * both vfs_bio_clrbuf() to mark pages valid, and to zero + * actual buffer content which might exist in the tail of the + * already valid cluster. */ error = bread(vp, de_cluster(pmp, dep->de_FileSize), pmp->pm_bpcluster, NOCRED, &bp); if (error != 0) goto rewind; vfs_bio_clrbuf(bp); + eof_clusteroff = de_cn2off(pmp, de_cluster(pmp, dep->de_FileSize)); + vfs_bio_bzero_buf(bp, dep->de_FileSize - eof_clusteroff, + pmp->pm_bpcluster - dep->de_FileSize + eof_clusteroff); if (!DOINGASYNC(vp)) (void)bwrite(bp); else if (vm_page_count_severe() || buf_dirty_count_severe())