From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7A61722333B; Thu, 12 Dec 2024 17:34:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734024879; cv=none; b=V1d8m5Ox7knZs9noKnj1uqglPT/zCcGROFsiwhx8kYunWiUK6B/ztBZjI98G4NKWPg26uFOxU4uFVq6Sh5UhRj21hfISPHUMxPo0IWUHO6IW9VaARyoBeJSo21rkF8aZhqoZ7cxzK7yte5U0BCNi7xgCgCAqgapbEZ33GYod7kg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734024879; c=relaxed/simple; bh=sUrOqsLOY6HoJYuB53oYWcUIeQa78wiT9lax+/7qlok=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mKOuS7saqzl0hK54H2+Xcnr/VrBCEDe2qPp1J/pnJrG42M9ujnARop1hncQuTGVNhhxP/Lfa5ftVgfhQTsr1Mi6iDxEmJt8qnxgB+tKQAF4r+oFDxIeQB/oT2utnlnwMMYEwP6l6Sji0zPANMdblBM3OaJe8fCBNvHFyFfSC5Wg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=nJq2NilM; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="nJq2NilM" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 99D0BC4CED4; Thu, 12 Dec 2024 17:34:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1734024879; bh=sUrOqsLOY6HoJYuB53oYWcUIeQa78wiT9lax+/7qlok=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nJq2NilM59YKJSfNSf5jSInJqPRPwio3O4Ca4McZHAcdsJCRajezcKmllGd6Hp1P8 lWlN5YpRbfCeAwCYSRjjb5noRZBmY+KEhDZLbRZxwcu6y43wZya7uuYMmbqRyGec5V EK1zWb4w/zA/uvhW6A6LFtoI4zhBu8FpK2AMFAKo= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Johannes Thumshirn , David Sterba , Qu Wenruo , Filipe Manana , Sasha Levin Subject: [PATCH 5.10 441/459] btrfs: fix missing snapshot drew unlock when root is dead during swap activation Date: Thu, 12 Dec 2024 16:02:59 +0100 Message-ID: <20241212144311.172355020@linuxfoundation.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241212144253.511169641@linuxfoundation.org> References: <20241212144253.511169641@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Filipe Manana [ Upstream commit 9c803c474c6c002d8ade68ebe99026cc39c37f85 ] When activating a swap file we acquire the root's snapshot drew lock and then check if the root is dead, failing and returning with -EPERM if it's dead but without unlocking the root's snapshot lock. Fix this by adding the missing unlock. Fixes: 60021bd754c6 ("btrfs: prevent subvol with swapfile from being deleted") Reviewed-by: Johannes Thumshirn Reviewed-by: David Sterba Reviewed-by: Qu Wenruo Signed-off-by: Filipe Manana Signed-off-by: David Sterba Signed-off-by: Sasha Levin --- fs/btrfs/inode.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 24598acb9a314..eba87f2936d2c 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -10283,6 +10283,7 @@ static int btrfs_swap_activate(struct swap_info_struct *sis, struct file *file, if (btrfs_root_dead(root)) { spin_unlock(&root->root_item_lock); + btrfs_drew_write_unlock(&root->snapshot_lock); btrfs_exclop_finish(fs_info); btrfs_warn(fs_info, "cannot activate swapfile because subvolume %llu is being deleted", -- 2.43.0