Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 27 Jul 2016 08:53:11 +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-10@freebsd.org
Subject:   svn commit: r303376 - stable/10/sys/ufs/ufs
Message-ID:  <201607270853.u6R8rBoZ025703@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Wed Jul 27 08:53:11 2016
New Revision: 303376
URL: https://svnweb.freebsd.org/changeset/base/303376

Log:
  MFC r303090:
  Ensure that the UFS directory vnode' vm_object is properly sized
  before UFS_BALLOC() is called.

Modified:
  stable/10/sys/ufs/ufs/ufs_lookup.c
  stable/10/sys/ufs/ufs/ufs_vnops.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/ufs/ufs/ufs_lookup.c
==============================================================================
--- stable/10/sys/ufs/ufs/ufs_lookup.c	Wed Jul 27 08:47:24 2016	(r303375)
+++ stable/10/sys/ufs/ufs/ufs_lookup.c	Wed Jul 27 08:53:11 2016	(r303376)
@@ -881,6 +881,7 @@ ufs_direnter(dvp, tvp, dirp, cnp, newdir
 	struct buf *bp;
 	u_int dsize;
 	struct direct *ep, *nep;
+	u_int64_t old_isize;
 	int error, ret, blkoff, loc, spacefree, flags, namlen;
 	char *dirbuf;
 
@@ -909,16 +910,18 @@ ufs_direnter(dvp, tvp, dirp, cnp, newdir
 			return (error);
 		}
 #endif
+		old_isize = dp->i_size;
+		vnode_pager_setsize(dvp, (u_long)dp->i_offset + DIRBLKSIZ);
 		if ((error = UFS_BALLOC(dvp, (off_t)dp->i_offset, DIRBLKSIZ,
 		    cr, flags, &bp)) != 0) {
 			if (DOINGSOFTDEP(dvp) && newdirbp != NULL)
 				bdwrite(newdirbp);
+			vnode_pager_setsize(dvp, (u_long)old_isize);
 			return (error);
 		}
 		dp->i_size = dp->i_offset + DIRBLKSIZ;
 		DIP_SET(dp, i_size, dp->i_size);
 		dp->i_flag |= IN_CHANGE | IN_UPDATE;
-		vnode_pager_setsize(dvp, (u_long)dp->i_size);
 		dirp->d_reclen = DIRBLKSIZ;
 		blkoff = dp->i_offset &
 		    (VFSTOUFS(dvp->v_mount)->um_mountp->mnt_stat.f_iosize - 1);

Modified: stable/10/sys/ufs/ufs/ufs_vnops.c
==============================================================================
--- stable/10/sys/ufs/ufs/ufs_vnops.c	Wed Jul 27 08:47:24 2016	(r303375)
+++ stable/10/sys/ufs/ufs/ufs_vnops.c	Wed Jul 27 08:53:11 2016	(r303376)
@@ -1914,13 +1914,13 @@ ufs_mkdir(ap)
 	dirtemplate = *dtp;
 	dirtemplate.dot_ino = ip->i_number;
 	dirtemplate.dotdot_ino = dp->i_number;
+	vnode_pager_setsize(tvp, DIRBLKSIZ);
 	if ((error = UFS_BALLOC(tvp, (off_t)0, DIRBLKSIZ, cnp->cn_cred,
 	    BA_CLRBUF, &bp)) != 0)
 		goto bad;
 	ip->i_size = DIRBLKSIZ;
 	DIP_SET(ip, i_size, DIRBLKSIZ);
 	ip->i_flag |= IN_CHANGE | IN_UPDATE;
-	vnode_pager_setsize(tvp, (u_long)ip->i_size);
 	bcopy((caddr_t)&dirtemplate, (caddr_t)bp->b_data, sizeof dirtemplate);
 	if (DOINGSOFTDEP(tvp)) {
 		/*



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