mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Erez Zadok <ezk@cs.sunysb.edu>
To: akpm@linux-foundation.org
Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	viro@ftp.linux.org.uk, hch@infradead.org,
	Erez Zadok <ezk@cs.sunysb.edu>
Subject: [PATCH 2/3] Unionfs: locking fixes
Date: Thu,  3 Jan 2008 00:57:39 -0500	[thread overview]
Message-ID: <119933986346-git-send-email-ezk@cs.sunysb.edu> (raw)
In-Reply-To: <11993398601-git-send-email-ezk@cs.sunysb.edu>

Lock parent dentries during revalidation.
Reduce total number of lockdep classes used.

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
---
 fs/unionfs/dentry.c |   13 ++++++++++++-
 fs/unionfs/fanout.h |    3 ++-
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/fs/unionfs/dentry.c b/fs/unionfs/dentry.c
index 0369d93..7646828 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))
@@ -351,7 +352,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);
@@ -366,6 +370,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))
@@ -376,6 +382,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))) {
@@ -394,6 +403,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 5f31015..4d9a45f 100644
--- a/fs/unionfs/fanout.h
+++ b/fs/unionfs/fanout.h
@@ -290,7 +290,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,
-- 
1.5.2.2


  parent reply	other threads:[~2008-01-03  5:58 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-03  5:57 [GIT PULL -mm] 0/3 Unionfs updates/fixes/cleanups Erez Zadok
2008-01-03  5:57 ` [PATCH 1/3] Unionfs: use printk KERN_CONT for debugging messages Erez Zadok
2008-01-03  6:26   ` Joe Perches
2008-01-03 18:36     ` Erez Zadok
2008-01-03  5:57 ` Erez Zadok [this message]
2008-01-03  5:57 ` [PATCH 3/3] Unionfs: use VFS helpers to manipulate i_nlink Erez Zadok

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=119933986346-git-send-email-ezk@cs.sunysb.edu \
    --to=ezk@cs.sunysb.edu \
    --cc=akpm@linux-foundation.org \
    --cc=hch@infradead.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@ftp.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome