Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 10 Apr 2019 08:34:18 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org
Subject:   svn commit: r346074 - stable/12/sys/fs/msdosfs
Message-ID:  <201904100834.x3A8YIm9070744@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Wed Apr 10 08:34:17 2019
New Revision: 346074
URL: https://svnweb.freebsd.org/changeset/base/346074

Log:
  MFC r345847:
  msdosfs: zero tail of the last block on truncation for VREG vnodes as well.

Modified:
  stable/12/sys/fs/msdosfs/msdosfs_denode.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/fs/msdosfs/msdosfs_denode.c
==============================================================================
--- stable/12/sys/fs/msdosfs/msdosfs_denode.c	Wed Apr 10 08:17:56 2019	(r346073)
+++ stable/12/sys/fs/msdosfs/msdosfs_denode.c	Wed Apr 10 08:34:17 2019	(r346074)
@@ -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);
 	}
 
 	/*



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201904100834.x3A8YIm9070744>