Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 15 Apr 2014 07:50:18 +0000 (UTC)
From:      Scott Long <scottl@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: r264490 - stable/10/sys/ufs/ufs
Message-ID:  <201404150750.s3F7oIcJ003585@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: scottl
Date: Tue Apr 15 07:50:18 2014
New Revision: 264490
URL: http://svnweb.freebsd.org/changeset/base/264490

Log:
  MFC r262812
  
  - Gracefully handle truncation failures when trying to shrink directories.
    This could cause dirhash panics since the dirhash state would be
    successfully truncated while the directory was not.
  
  Submitted by:   jeffr

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

Modified: stable/10/sys/ufs/ufs/ufs_lookup.c
==============================================================================
--- stable/10/sys/ufs/ufs/ufs_lookup.c	Tue Apr 15 07:37:56 2014	(r264489)
+++ stable/10/sys/ufs/ufs/ufs_lookup.c	Tue Apr 15 07:50:18 2014	(r264490)
@@ -1130,12 +1130,15 @@ ufs_direnter(dvp, tvp, dirp, cnp, newdir
 	    dp->i_endoff && dp->i_endoff < dp->i_size) {
 		if (tvp != NULL)
 			VOP_UNLOCK(tvp, 0);
+		error = UFS_TRUNCATE(dvp, (off_t)dp->i_endoff,
+		    IO_NORMAL | IO_SYNC, cr);
+		if (error != 0)
+			vprint("ufs_direnter: failted to truncate", dvp);
 #ifdef UFS_DIRHASH
-		if (dp->i_dirhash != NULL)
+		if (error == 0 && dp->i_dirhash != NULL)
 			ufsdirhash_dirtrunc(dp, dp->i_endoff);
 #endif
-		(void) UFS_TRUNCATE(dvp, (off_t)dp->i_endoff,
-		    IO_NORMAL | IO_SYNC, cr);
+		error = 0;
 		if (tvp != NULL)
 			vn_lock(tvp, LK_EXCLUSIVE | LK_RETRY);
 	}



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