From patchwork Tue Oct 8 08:16:37 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benny Halevy X-Patchwork-Id: 3001231 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 16A11BF924 for ; Tue, 8 Oct 2013 08:16:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 46E632010E for ; Tue, 8 Oct 2013 08:16:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EB9B8201E9 for ; Tue, 8 Oct 2013 08:16:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754480Ab3JHIQo (ORCPT ); Tue, 8 Oct 2013 04:16:44 -0400 Received: from mail-wi0-f171.google.com ([209.85.212.171]:56579 "EHLO mail-wi0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752483Ab3JHIQn (ORCPT ); Tue, 8 Oct 2013 04:16:43 -0400 Received: by mail-wi0-f171.google.com with SMTP id hm2so6105171wib.10 for ; Tue, 08 Oct 2013 01:16:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id; bh=XpwOE2broT4kALi/jrMf7/MLbVGuMQGOUc1WOKysamQ=; b=yMhmTuBW4lDY25OT7xqmHYq1MkSHsTgpMIStZLWUy+iYk8vLR9RNCq+4ZuAYAzOs4O mofO5gVnnZ1qtpoZtQB+W69bpmYMMvSPPzJNaa/sgZsb56EFTu9SURDEIDU0NvoiuOiw R9a4xEHnJXdnXUV3YtQ8+6v1I5R2b/FuLysGUIAqWpNNtaPxCPTko4hB3J/M3AByLCWf JK0RW2wW1eKkWTJIEr/BJkYD3vYtqNQi3UUro/BXEASi9rJs1SsKAUB8/ss2TpOF4+dw pSU+qPYxm21WoXTNxo881esfBrCsvWh0EUm7eyyIITDY+4MzZVnl8cRjKTjQttEkjSFY X06w== X-Received: by 10.180.206.129 with SMTP id lo1mr22313878wic.15.1381220201684; Tue, 08 Oct 2013 01:16:41 -0700 (PDT) Received: from bhalevy-lt.il.tonian.com (bzq-80-49-130.static.bezeqint.net. [82.80.49.130]) by mx.google.com with ESMTPSA id mb7sm2674089wic.10.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 08 Oct 2013 01:16:40 -0700 (PDT) From: Benny Halevy To: linux-nfs@vger.kernel.org Cc: nadav@primarydata.com, Benny Halevy Subject: [PATCH] SQUASHME: pnfsd: destroy fi_lo_lock at put time Date: Tue, 8 Oct 2013 11:16:37 +0300 Message-Id: <1381220197-378-1-git-send-email-bhalevy@primarydata.com> X-Mailer: git-send-email 1.8.3.1 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently, the mutex lock is destroyed at nfsd4_free_file time but on the nfsd4_process_open2 -> nfsd4_is_deleg_cur path, open->op_file points to a nfs4_file that was never properly initialized and destroy_mutex rightfully warns about that. The following test reproduces the warning: python testserver.py 192.168.122.37:/server --maketree open Oct 7 20:10:49 localhost kernel: nfsv4 compound op #5/6: 18 (OP_OPEN) Oct 7 20:10:49 localhost kernel: nfsd4_check_resp_size length 352, xb->page_len 0 tlen 0 pad 232 Oct 7 20:10:49 localhost kernel: NFSD: nfsd4_open filename DELEG1_1381165848 op_openowner (null) Oct 7 20:10:49 localhost kernel: renewing client (clientid 5252ea55/00000003) Oct 7 20:10:49 localhost kernel: nfsd: fh_verify(16: 01010001 00000000 00004277 f9f8a80e 00000000 00000000) Oct 7 20:10:49 localhost kernel: nfsd: nfsd_lookup(fh 16: 01010001 00000000 00004277 f9f8a80e 00000000 00000000, DELEG1_1381165848) Oct 7 20:10:49 localhost kernel: nfsd: fh_compose(exp fd:01/18170 tmp/DELEG1_1381165848, ino=17154) Oct 7 20:10:49 localhost kernel: nfsd: fh_verify(16: 01010001 00000000 00004302 9ad5e870 00000000 00000000) Oct 7 20:10:49 localhost kernel: NFSD alloc_init_deleg Oct 7 20:10:49 localhost kernel: NFSD: delegation stateid=(5252ea55/00000003/00000002/00000001) Oct 7 20:10:49 localhost kernel: nfsd4_process_open2: stateid=(5252ea55/00000003/00000000/00000002) Oct 7 20:10:49 localhost kernel: ------------[ cut here ]------------ Oct 7 20:10:49 localhost kernel: WARNING: CPU: 1 PID: 309 at /usr0/home/bhalevy/dev/linux-pnfs/kernel/mutex-debug.c:106 mutex_destroy+0x57/0x60() Oct 7 20:10:49 localhost kernel: DEBUG_LOCKS_WARN_ON(mutex_is_locked(lock)) Oct 7 20:10:49 localhost kernel: Modules linked in: nfs_layout_nfsv41_files rpcsec_gss_krb5 nfsv4 nfs nfsd auth_rpcgss oid_registry nfs_acl lockd sunrpc autofs4 Oct 7 20:10:49 localhost kernel: CPU: 1 PID: 309 Comm: nfsd Not tainted 3.12.0-rc3-pnfs+ #19 Oct 7 20:10:49 localhost kernel: Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011 Oct 7 20:10:49 localhost kernel: 0000000000000009 ffff880036f4fbd0 ffffffff81702320 ffff880036f4fc18 Oct 7 20:10:49 localhost kernel: ffff880036f4fc08 ffffffff81068b5d ffff88003b665628 ffff88003c2e4c40 Oct 7 20:10:49 localhost kernel: ffff88003b670160 0000000000000000 ffff88003d7efc80 ffff880036f4fc68 Oct 7 20:10:49 localhost kernel: Call Trace: Oct 7 20:10:49 localhost kernel: [] dump_stack+0x54/0x74 Oct 7 20:10:49 localhost kernel: [] warn_slowpath_common+0x7d/0xa0 Oct 7 20:10:49 localhost kernel: [] warn_slowpath_fmt+0x4c/0x50 Oct 7 20:10:49 localhost kernel: [] mutex_destroy+0x57/0x60 Oct 7 20:10:49 localhost kernel: [] nfsd4_cleanup_open_state+0x6d/0xd0 [nfsd] Oct 7 20:10:49 localhost kernel: [] nfsd4_open+0x1b9/0xa80 [nfsd] Oct 7 20:10:49 localhost kernel: [] ? nfsd4_open+0x5/0xa80 [nfsd] Oct 7 20:10:49 localhost kernel: [] nfsd4_proc_compound+0x56a/0x7b0 [nfsd] Oct 7 20:10:49 localhost kernel: [] nfsd_dispatch+0xbb/0x200 [nfsd] Oct 7 20:10:49 localhost kernel: [] svc_process_common+0x46d/0x6e0 [sunrpc] Oct 7 20:10:49 localhost kernel: [] svc_process+0x107/0x170 [sunrpc] Oct 7 20:10:49 localhost kernel: [] nfsd+0xd3/0x160 [nfsd] Oct 7 20:10:49 localhost kernel: [] ? nfsd_destroy+0x220/0x220 [nfsd] Oct 7 20:10:49 localhost kernel: [] kthread+0xed/0x100 Oct 7 20:10:49 localhost kernel: [] ? trace_hardirqs_off+0xd/0x10 Oct 7 20:10:49 localhost kernel: [] ? trace_hardirqs_on_caller+0xfd/0x1c0 Oct 7 20:10:49 localhost kernel: [] ? insert_kthread_work+0x80/0x80 Oct 7 20:10:49 localhost kernel: [] ret_from_fork+0x7c/0xb0 Oct 7 20:10:49 localhost kernel: [] ? insert_kthread_work+0x80/0x80 Oct 7 20:10:49 localhost kernel: ---[ end trace 3f1862caf9f88967 ]--- Signed-off-by: Benny Halevy --- fs/nfsd/nfs4state.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 6918316..7306190 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -238,9 +238,6 @@ void put_client_renew(struct nfs4_client *clp) static void nfsd4_free_file(struct nfs4_file *f) { -#if defined(CONFIG_PNFSD) - mutex_destroy(&f->fi_lo_lock); -#endif /* CONFIG_PNFSD */ kmem_cache_free(file_slab, f); } @@ -252,6 +249,9 @@ static struct inode *put_nfs4_file_common(struct nfs4_file *fi) hlist_del(&fi->fi_hash); spin_unlock(&recall_lock); ino = fi->fi_inode; +#if defined(CONFIG_PNFSD) + mutex_destroy(&f->fi_lo_lock); +#endif /* CONFIG_PNFSD */ nfsd4_free_file(fi); return ino;