From owner-svn-src-head@FreeBSD.ORG Thu Dec 30 10:52:08 2010 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 00953106564A; Thu, 30 Dec 2010 10:52:08 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D99618FC0C; Thu, 30 Dec 2010 10:52:07 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id oBUAq79A037461; Thu, 30 Dec 2010 10:52:07 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oBUAq7SH037458; Thu, 30 Dec 2010 10:52:07 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201012301052.oBUAq7SH037458@svn.freebsd.org> From: Konstantin Belousov Date: Thu, 30 Dec 2010 10:52:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r216818 - in head/sys/ufs: ffs ufs X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 Dec 2010 10:52:08 -0000 Author: kib Date: Thu Dec 30 10:52:07 2010 New Revision: 216818 URL: http://svn.freebsd.org/changeset/base/216818 Log: Handle missing jremrefs when a directory is renamed overtop of another, deleting it. If the directory is removed, UFS always need to remove the .. ref, even if the ultimate ref on the parent would not change. The new directory must have a new journal entry for that ref. Otherwise journal processing would not properly account for the parent's reference since it will belong to a removed directory entry. Change ufs_rename()'s dotdot rename section to always setup_dotdot_link(). In the tip != NULL case SUJ needs the newref dependency allocated via setup_dotdot_link(). Stop setting isrmdir to 2 for newdirrem() in softdep_setup_remove(). Remove the isdirrem > 1 checks from newdirrem(). Reported by: many Submitted by: jeff Tested by: pho Modified: head/sys/ufs/ffs/ffs_softdep.c head/sys/ufs/ufs/ufs_vnops.c Modified: head/sys/ufs/ffs/ffs_softdep.c ============================================================================== --- head/sys/ufs/ffs/ffs_softdep.c Thu Dec 30 10:41:17 2010 (r216817) +++ head/sys/ufs/ffs/ffs_softdep.c Thu Dec 30 10:52:07 2010 (r216818) @@ -6918,7 +6918,7 @@ softdep_setup_remove(bp, dp, ip, isrmdir * newdirrem() to setup the full directory remove which requires * isrmdir > 1. */ - dirrem = newdirrem(bp, dp, ip, isrmdir?2:0, &prevdirrem); + dirrem = newdirrem(bp, dp, ip, isrmdir, &prevdirrem); /* * Add the dirrem to the inodedep's pending remove list for quick * discovery later. @@ -7152,14 +7152,12 @@ newdirrem(bp, dp, ip, isrmdir, prevdirre ip->i_effnlink + 2); dotremref = newjremref(dirrem, ip, ip, DOT_OFFSET, ip->i_effnlink + 1); - } else - jremref = newjremref(dirrem, dp, ip, dp->i_offset, - ip->i_effnlink + 1); - if (isrmdir > 1) { dotdotremref = newjremref(dirrem, ip, dp, DOTDOT_OFFSET, dp->i_effnlink + 1); dotdotremref->jr_state |= MKDIR_PARENT; - } + } else + jremref = newjremref(dirrem, dp, ip, dp->i_offset, + ip->i_effnlink + 1); } ACQUIRE_LOCK(&lk); lbn = lblkno(dp->i_fs, dp->i_offset); @@ -7184,7 +7182,7 @@ newdirrem(bp, dp, ip, isrmdir, prevdirre * cancel it. Any pending journal work will be added to the dirrem * to be completed when the workitem remove completes. */ - if (isrmdir > 1) + if (isrmdir) dotdotremref = cancel_diradd_dotdot(ip, dirrem, dotdotremref); /* * Check for a diradd dependency for the same directory entry. Modified: head/sys/ufs/ufs/ufs_vnops.c ============================================================================== --- head/sys/ufs/ufs/ufs_vnops.c Thu Dec 30 10:41:17 2010 (r216817) +++ head/sys/ufs/ufs/ufs_vnops.c Thu Dec 30 10:52:07 2010 (r216818) @@ -1497,7 +1497,9 @@ relock: /* Don't go to bad here as the new link exists. */ if (error) goto unlockout; - } + } else if (DOINGSUJ(tdvp)) + /* Journal must account for each new link. */ + softdep_setup_dotdot_link(tdp, fip); fip->i_offset = mastertemplate.dot_reclen; ufs_dirrewrite(fip, fdp, newparent, DT_DIR, 0); cache_purge(fdvp);