From patchwork Sat Mar 28 11:02:06 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 6113661 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D95FBBF4A6 for ; Sat, 28 Mar 2015 11:02:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D4DE52038E for ; Sat, 28 Mar 2015 11:02:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0049D20386 for ; Sat, 28 Mar 2015 11:02:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752888AbbC1LC2 (ORCPT ); Sat, 28 Mar 2015 07:02:28 -0400 Received: from mail-pa0-f48.google.com ([209.85.220.48]:32821 "EHLO mail-pa0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752092AbbC1LC0 (ORCPT ); Sat, 28 Mar 2015 07:02:26 -0400 Received: by pabxg6 with SMTP id xg6so119974299pab.0 for ; Sat, 28 Mar 2015 04:02:26 -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=eKA2aRufz+gc/gTaaViOt79DdqUEXsoVrrsrTL2pXOU=; b=Vk0XS8gJoz6yxaHd5gVbVfHg2ZeeSPQWYtKDPqJAtfBUDb7AfryvzuiDvtJmk3Bo2U S2UdjATf8mtgOMy8m1dh7Mt3EHaSE0RP3SKqceI5NH5wBpcAtdB0eAIpGrtihud8QYqo 7QO9Efx/FaHOg6NSFF2VDFlHKGqejNDlRp0yDTwFlzeK1voKP2/1QP67L7iVsd84c+bW nq717NLd2xeHVdOTBsgmheZw+KSqZ/yz0fdscZGoJiYEoDHVi0HmDD1vbg3Vr6ZDXZtC evuxPlEm9qr6X7gxIhKk2DNtwAHcWvE5IoZ3rvIWo/O4h7vMEQ5sADxzA/LTnMWoaTnd 2/Dg== X-Gm-Message-State: ALoCoQlCQoUu2B0nmnl+mItsW5gsXFaUGzQeJddVn2ixQDN1DG+gyrluNZ9ybNcXdyqWkW0y10Ba X-Received: by 10.70.119.37 with SMTP id kr5mr42389007pdb.107.1427540545953; Sat, 28 Mar 2015 04:02:25 -0700 (PDT) Received: from mew.localdomain (c-76-104-211-44.hsd1.wa.comcast.net. [76.104.211.44]) by mx.google.com with ESMTPSA id qh9sm1773046pbc.24.2015.03.28.04.02.24 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 28 Mar 2015 04:02:25 -0700 (PDT) From: Omar Sandoval To: Chris Mason , Josef Bacik , David Sterba Cc: Filipe Manana , linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org, Omar Sandoval Subject: [PATCH] btrfs: unlock i_mutex after attempting to delete subvolume during send Date: Sat, 28 Mar 2015 04:02:06 -0700 Message-Id: <74abba0fe653d9ac27bfe4f14ae3e8f65b5b7317.1427539655.git.osandov@osandov.com> X-Mailer: git-send-email 2.3.4 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. Signed-off-by: Omar Sandoval Reviewed-by: Filipe Manana Reviewed-by: David Sterba --- 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);