All of lore.kernel.org
 help / color / mirror / Atom feed
From: "J. Bruce Fields" <bfields@fieldses.org>
To: Mark Fasheh <mfasheh@suse.com>,
	ocfs2-devel@oss.oracle.com, linux-fsdevel@vger.kernel.org
Subject: [PATCH] ocfs2: comment missing-cluster-lock warning
Date: Thu, 16 Aug 2012 15:54:25 -0400	[thread overview]
Message-ID: <20120816195425.GD4385@fieldses.org> (raw)
In-Reply-To: <20120816194203.GC4385@fieldses.org>

From: "J. Bruce Fields" <bfields@redhat.com>

Add some explanation of the DCACHE_DISCONNECTED use here.  And hide away
the boring warning code in a helper function.

Signed-off-by: J. Bruce Fields <bfields@redhat.com>
---
 fs/ocfs2/dcache.c |   40 +++++++++++++++++++++++++---------------
 1 file changed, 25 insertions(+), 15 deletions(-)

By the way, something like this might save me a little time next time I
run across this and forget this conversation.  But, no big deal if you
think it's overkill.  Untested except by a make fs/ocfs2/dcache.o.

diff --git a/fs/ocfs2/dcache.c b/fs/ocfs2/dcache.c
index 8db4b58..27677ab 100644
--- a/fs/ocfs2/dcache.c
+++ b/fs/ocfs2/dcache.c
@@ -446,26 +446,36 @@ void ocfs2_dentry_lock_put(struct ocfs2_super *osb,
 		ocfs2_drop_dentry_lock(osb, dl);
 }
 
+static void ocfs2_warn_if_missing_lock(struct dentry *dentry, struct inode *inode)
+{
+	unsigned long long ino = 0ULL;
+
+	/* It's OK not to have the dentry lock on an unhashed dentry: */
+	if (d_unhashed(dentry))
+		return;
+	/*
+	 * It's also fine if we're disconnected.  (Note: a dentry may be
+	 * marked DCACHE_DISCONNECTED for a brief time after it's been
+	 * fully connected, so we may fail to warn in some cases we
+	 * should.  We prefer that to warning when we shouldn't.)
+	 */
+	if (dentry->d_flags & DCACHE_DISCONNECTED)
+		return;
+
+	if (inode)
+		ino = (unsigned long long)OCFS2_I(inode)->ip_blkno;
+	mlog(ML_ERROR, "Dentry is missing cluster lock. "
+	     "inode: %llu, d_flags: 0x%x, d_name: %.*s\n",
+	     ino, dentry->d_flags, dentry->d_name.len,
+	     dentry->d_name.name);
+}
+
 static void ocfs2_dentry_iput(struct dentry *dentry, struct inode *inode)
 {
 	struct ocfs2_dentry_lock *dl = dentry->d_fsdata;
 
 	if (!dl) {
-		/*
-		 * No dentry lock is ok if we're disconnected or
-		 * unhashed.
-		 */
-		if (!(dentry->d_flags & DCACHE_DISCONNECTED) &&
-		    !d_unhashed(dentry)) {
-			unsigned long long ino = 0ULL;
-			if (inode)
-				ino = (unsigned long long)OCFS2_I(inode)->ip_blkno;
-			mlog(ML_ERROR, "Dentry is missing cluster lock. "
-			     "inode: %llu, d_flags: 0x%x, d_name: %.*s\n",
-			     ino, dentry->d_flags, dentry->d_name.len,
-			     dentry->d_name.name);
-		}
-
+		ocfs2_warn_if_missing_lock(dentry, inode);
 		goto out;
 	}
 
-- 
1.7.9.5


      reply	other threads:[~2012-08-16 19:54 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-31 22:33 [Ocfs2-devel] [RFC PATCH] ocfs2: don't depend on DCACHE_DISCONNECTED J. Bruce Fields
2012-07-31 22:33 ` J. Bruce Fields
2012-08-02  7:57 ` [Ocfs2-devel] " Joel Becker
2012-08-02  7:57   ` Joel Becker
2012-08-02 12:59   ` [Ocfs2-devel] " J. Bruce Fields
2012-08-02 12:59     ` J. Bruce Fields
2012-08-15 10:22     ` [Ocfs2-devel] " Joel Becker
2012-08-15 10:22       ` Joel Becker
2012-08-16 19:42       ` J. Bruce Fields
2012-08-16 19:54         ` J. Bruce Fields [this message]

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=20120816195425.GD4385@fieldses.org \
    --to=bfields@fieldses.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=mfasheh@suse.com \
    --cc=ocfs2-devel@oss.oracle.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.