From ddb82f214f0cd5171f9830a6d28b75e8ded98613 Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Tue, 12 Dec 2023 00:57:28 +0200 Subject: [PATCH] ufs: do not leave around empty buffers shadowing disk content (cherry picked from commit ca39f23347e1416a28dde13279bfe5841ad9a746) --- sys/ufs/ffs/ffs_vnops.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/sys/ufs/ffs/ffs_vnops.c b/sys/ufs/ffs/ffs_vnops.c index 2b11a15c46c..c14cb5e1ee6 100644 --- a/sys/ufs/ffs/ffs_vnops.c +++ b/sys/ufs/ffs/ffs_vnops.c @@ -981,8 +981,15 @@ ffs_write( * validated the pages. */ if (error != 0 && (bp->b_flags & B_CACHE) == 0 && - fs->fs_bsize == xfersize) - vfs_bio_clrbuf(bp); + fs->fs_bsize == xfersize) { + if (error == EFAULT && LIST_EMPTY(&bp->b_dep)) { + bp->b_flags |= B_INVAL | B_RELBUF | B_NOCACHE; + brelse(bp); + break; + } else { + vfs_bio_clrbuf(bp); + } + } vfs_bio_set_flags(bp, ioflag);