From: Frank Mayhar Subject: dput() crash in Nick's vfs-scale tree (with patch). Date: Mon, 27 Sep 2010 15:42:53 -0700 Message-ID: <1285627373.1943.85.camel@bobble.smo.corp.google.com> References: <1285369448.4562.148.camel@bobble.smo.corp.google.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Cc: linux-fsdevel@vger.kernel.org To: npiggin@kernel.dk Return-path: Received: from smtp-out.google.com ([216.239.44.51]:41133 "EHLO smtp-out.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760294Ab0I0WnB (ORCPT ); Mon, 27 Sep 2010 18:43:01 -0400 Received: from wpaz29.hot.corp.google.com (wpaz29.hot.corp.google.com [172.24.198.93]) by smtp-out.google.com with ESMTP id o8RMh0f3030901 for ; Mon, 27 Sep 2010 15:43:00 -0700 Received: from ewy23 (ewy23.prod.google.com [10.241.103.23]) by wpaz29.hot.corp.google.com with ESMTP id o8RMgw4h006005 for ; Mon, 27 Sep 2010 15:42:59 -0700 Received: by ewy23 with SMTP id 23so1805292ewy.5 for ; Mon, 27 Sep 2010 15:42:58 -0700 (PDT) In-Reply-To: <1285369448.4562.148.camel@bobble.smo.corp.google.com> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: It turns out that the problem wasn't as obscure as I was afraid it might be. Basically it stems from the addition of d_set_d_op(), which as an optimization uses flags in d_flags to indicate the presence or absence of the various ops. The problem is that we may be replacing one set of ops with another, which was in fact the case in the call from the cgroup code. (We might even be setting d_op to NULL.) If the new set doesn't implement everything that the old one did, we'll have bits set in d_flags that correspond to NULL function pointers. The fix is simply to clear our bits when we change d_op. Patch: When we change dentry->d_op we need to clear our flags first, just in case the new set (which may even be NULL) doesn't implement everything the old set did. Signed-off-by: Frank Mayhar --- fs/dcache.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/fs/dcache.c b/fs/dcache.c index b055536..bd5e1fe 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -1358,6 +1358,14 @@ EXPORT_SYMBOL(d_alloc); void d_set_d_op(struct dentry *dentry, const struct dentry_operations *op) { dentry->d_op = op; + /* + * The new ops may be NULL or may not implement everything that the + * old set (if any) did. We need to clear the flags just in case + * either of those is true. + */ + dentry->d_flags &= ~(DCACHE_OP_HASH | DCACHE_OP_COMPARE | + DCACHE_OP_REVALIDATE | DCACHE_OP_REVALIDATE_RCU | + DCACHE_OP_DELETE); if (!op) return; if (op->d_hash)