svn commit: r216818 - in head/sys/ufs: ffs ufs
Konstantin Belousov
kib at FreeBSD.org
Thu Dec 30 10:52:08 UTC 2010
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);
More information about the svn-src-all
mailing list