From patchwork Fri Apr 10 21:20:40 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 6199431 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 9E7079F2EC for ; Fri, 10 Apr 2015 21:21:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A9F9E20357 for ; Fri, 10 Apr 2015 21:21:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B334C202D1 for ; Fri, 10 Apr 2015 21:21:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755010AbbDJVUx (ORCPT ); Fri, 10 Apr 2015 17:20:53 -0400 Received: from mail-pd0-f176.google.com ([209.85.192.176]:34600 "EHLO mail-pd0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756292AbbDJVUv (ORCPT ); Fri, 10 Apr 2015 17:20:51 -0400 Received: by pdbqa5 with SMTP id qa5so34448892pdb.1 for ; Fri, 10 Apr 2015 14:20:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=gsNKY9HeaRp9MgmZbWNNzd9RchHBzK2uh2413J5ZTEU=; b=k6m6LtQXT4DfOcix56jxnb+S2PKBNc2Rx2+9VGq6pi8fd6UYnkH17WJzLtjEnlgbCM CoYEtnTXtO6jMCFjaCMBFS4aK8UNUU4YvSjaXi8BMelTfS4hPsWwMQY6frAwxDg5SSne nDJ742UXxMyTN6RmbdLZsJD6Vu38+i056yhK/iB7dW85/C5Hs+2hvqwx7tz+xfOFo/tf 8lQmmyjIiI0As5OwJawSGnvsScbXWlUZs5NZIj86lCLuSJjXbbOj1RoUra+pCEzDiHX8 dl/gnXT4iD0Et09u6xWf+CAQGTG9xHwew5AhdkVDlVQ8QlSCJLVOWASmbJjbz9ILEA/P GSBA== X-Gm-Message-State: ALoCoQlrYTGn9wBPYHOrg1fL1DD+IoH3KGw8EoF8Y/noZ1jvgBHAHmRTlfrkL3Z4VJFrpTBZEx8c X-Received: by 10.66.221.135 with SMTP id qe7mr5809826pac.97.1428700850531; Fri, 10 Apr 2015 14:20:50 -0700 (PDT) Received: from mew.dhcp4.washington.edu (D-128-95-134-146.dhcp4.washington.edu. [128.95.134.146]) by mx.google.com with ESMTPSA id q3sm3198659pds.49.2015.04.10.14.20.49 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 10 Apr 2015 14:20:49 -0700 (PDT) From: Omar Sandoval To: Chris Mason , Josef Bacik , David Sterba , linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Omar Sandoval , stable@vger.kernel.org Subject: [PATCH RESEND] btrfs: unlock i_mutex after attempting to delete subvolume during send Date: Fri, 10 Apr 2015 14:20:40 -0700 Message-Id: <00d6e1021fdd56192360d2eb0fb43130f3607fe1.1428700740.git.osandov@osandov.com> X-Mailer: git-send-email 2.3.5 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, 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 Whenever the check for a send in progress introduced in commit 521e0546c970 (btrfs: protect snapshots from deleting during send) is hit, we return without unlocking inode->i_mutex. This is easy to see with lockdep enabled: [ +0.000059] ================================================ [ +0.000028] [ BUG: lock held when returning to user space! ] [ +0.000029] 4.0.0-rc5-00096-g3c435c1 #93 Not tainted [ +0.000026] ------------------------------------------------ [ +0.000029] btrfs/211 is leaving the kernel with locks still held! [ +0.000029] 1 lock held by btrfs/211: [ +0.000023] #0: (&type->i_mutex_dir_key){+.+.+.}, at: [] btrfs_ioctl_snap_destroy+0x2df/0x7a0 Make sure we unlock it in the error path. Reviewed-by: Filipe Manana Reviewed-by: David Sterba Cc: stable@vger.kernel.org Signed-off-by: Omar Sandoval --- Just resending this with Filipe's and David's Reviewed-bys and Cc-ing stable. fs/btrfs/ioctl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 74609b9..9fde01f 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -2403,7 +2403,7 @@ static noinline int btrfs_ioctl_snap_destroy(struct file *file, "Attempt to delete subvolume %llu during send", dest->root_key.objectid); err = -EPERM; - goto out_dput; + goto out_unlock_inode; } d_invalidate(dentry); @@ -2498,6 +2498,7 @@ out_up_write: root_flags & ~BTRFS_ROOT_SUBVOL_DEAD); spin_unlock(&dest->root_item_lock); } +out_unlock_inode: mutex_unlock(&inode->i_mutex); if (!err) { shrink_dcache_sb(root->fs_info->sb);