From mboxrd@z Thu Jan 1 00:00:00 1970 From: "J. Bruce Fields" Subject: [PATCH] ocfs2: comment missing-cluster-lock warning Date: Thu, 16 Aug 2012 15:54:25 -0400 Message-ID: <20120816195425.GD4385@fieldses.org> References: <20120731223323.GA32253@fieldses.org> <20120802075743.GA3368@dhcp-172-17-9-228.mtv.corp.google.com> <20120802125910.GC9849@fieldses.org> <20120815102241.GP31083@dhcp-172-17-9-228.mtv.corp.google.com> <20120816194203.GC4385@fieldses.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii To: Mark Fasheh , ocfs2-devel@oss.oracle.com, linux-fsdevel@vger.kernel.org Return-path: Received: from fieldses.org ([174.143.236.118]:43869 "EHLO fieldses.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933187Ab2HPTy1 (ORCPT ); Thu, 16 Aug 2012 15:54:27 -0400 Content-Disposition: inline In-Reply-To: <20120816194203.GC4385@fieldses.org> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: From: "J. Bruce Fields" 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 --- 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