commit 3744b969a6961971a164da8a94778fd2e029766b
Author: Erez Zadok <[EMAIL PROTECTED]>
Date: Tue Jan 1 21:50:54 2008 -0500
Unionfs: locking fixes
Lock parent dentries during revalidation.
Reduce total number of lockdep classes used.
Signed-off-by: Erez Zadok <[EMAIL PROTECTED]>
diff --git a/fs/unionfs/dentry.c b/fs/unionfs/dentry.c
index b4c964d..971605f 100644
--- a/fs/unionfs/dentry.c
+++ b/fs/unionfs/dentry.c
@@ -42,6 +42,7 @@ static bool __unionfs_d_revalidate_one(struct dentry *dentry,
memset(&lowernd, 0, sizeof(struct nameidata));
verify_locked(dentry);
+ verify_locked(dentry->d_parent);
/* if the dentry is unhashed, do NOT revalidate */
if (d_deleted(dentry))
@@ -346,7 +347,10 @@ bool __unionfs_d_revalidate_chain(struct dentry *dentry,
struct nameidata *nd,
* to child order.
*/
for (i = 0; i < chain_len; i++) {
- unionfs_lock_dentry(chain[i], UNIONFS_DMUTEX_REVAL+i);
+ unionfs_lock_dentry(chain[i], UNIONFS_DMUTEX_REVAL_CHILD);
+ if (chain[i] != chain[i]->d_parent)
+ unionfs_lock_dentry(chain[i]->d_parent,
+ UNIONFS_DMUTEX_REVAL_PARENT);
saved_bstart = dbstart(chain[i]);
saved_bend = dbend(chain[i]);
sbgen = atomic_read(&UNIONFS_SB(dentry->d_sb)->generation);
@@ -361,6 +365,8 @@ bool __unionfs_d_revalidate_chain(struct dentry *dentry,
struct nameidata *nd,
bindex++)
unionfs_mntput(chain[i], bindex);
}
+ if (chain[i] != chain[i]->d_parent)
+ unionfs_unlock_dentry(chain[i]->d_parent);
unionfs_unlock_dentry(chain[i]);
if (unlikely(!valid))
@@ -371,6 +377,9 @@ bool __unionfs_d_revalidate_chain(struct dentry *dentry,
struct nameidata *nd,
out_this:
/* finally, lock this dentry and revalidate it */
verify_locked(dentry);
+ if (dentry != dentry->d_parent)
+ unionfs_lock_dentry(dentry->d_parent,
+ UNIONFS_DMUTEX_REVAL_PARENT);
dgen = atomic_read(&UNIONFS_D(dentry)->generation);
if (unlikely(is_newer_lower(dentry))) {
@@ -389,6 +398,8 @@ out_this:
purge_inode_data(dentry->d_inode);
}
valid = __unionfs_d_revalidate_one(dentry, nd);
+ if (dentry != dentry->d_parent)
+ unionfs_unlock_dentry(dentry->d_parent);
/*
* If __unionfs_d_revalidate_one() succeeded above, then it will
diff --git a/fs/unionfs/fanout.h b/fs/unionfs/fanout.h
index 07eb223..86b194e 100644
--- a/fs/unionfs/fanout.h
+++ b/fs/unionfs/fanout.h
@@ -291,7 +291,8 @@ enum unionfs_dentry_lock_class {
UNIONFS_DMUTEX_PARENT,
UNIONFS_DMUTEX_CHILD,
UNIONFS_DMUTEX_WHITEOUT,
- UNIONFS_DMUTEX_REVAL, /* for file/dentry revalidate */
+ UNIONFS_DMUTEX_REVAL_PARENT, /* for file/dentry revalidate */
+ UNIONFS_DMUTEX_REVAL_CHILD, /* for file/dentry revalidate */
};
static inline void unionfs_lock_dentry(struct dentry *d,
_______________________________________________
unionfs-cvs mailing list: http://unionfs.filesystems.org/
[email protected]
http://www.fsl.cs.sunysb.edu/mailman/listinfo/unionfs-cvs