stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Ioannis Angelakopoulos <iangelak@fb.com>,
	Josef Bacik <josef@toxicpanda.com>,
	David Sterba <dsterba@suse.com>, Sasha Levin <sashal@kernel.org>,
	clm@fb.com, linux-btrfs@vger.kernel.org
Subject: [PATCH AUTOSEL 5.15 18/26] btrfs: change the lockdep class of free space inode's invalidate_lock
Date: Tue, 11 Oct 2022 10:52:25 -0400	[thread overview]
Message-ID: <20221011145233.1624013-18-sashal@kernel.org> (raw)
In-Reply-To: <20221011145233.1624013-1-sashal@kernel.org>

From: Ioannis Angelakopoulos <iangelak@fb.com>

[ Upstream commit 9d7464c87b159bbf763c24faeb7a2dcaac96e4a1 ]

Reinitialize the class of the lockdep map for struct inode's
mapping->invalidate_lock in load_free_space_cache() function in
fs/btrfs/free-space-cache.c. This will prevent lockdep from producing
false positives related to execution paths that make use of free space
inodes and paths that make use of normal inodes.

Specifically, with this change lockdep will create separate lock
dependencies that include the invalidate_lock, in the case that free
space inodes are used and in the case that normal inodes are used.

The lockdep class for this lock was first initialized in
inode_init_always() in fs/inode.c.

Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Ioannis Angelakopoulos <iangelak@fb.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 fs/btrfs/free-space-cache.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
index 529907ea3825..456da08feccd 100644
--- a/fs/btrfs/free-space-cache.c
+++ b/fs/btrfs/free-space-cache.c
@@ -899,6 +899,8 @@ static int copy_free_space_cache(struct btrfs_block_group *block_group,
 	return ret;
 }
 
+static struct lock_class_key btrfs_free_space_inode_key;
+
 int load_free_space_cache(struct btrfs_block_group *block_group)
 {
 	struct btrfs_fs_info *fs_info = block_group->fs_info;
@@ -968,6 +970,14 @@ int load_free_space_cache(struct btrfs_block_group *block_group)
 	}
 	spin_unlock(&block_group->lock);
 
+	/*
+	 * Reinitialize the class of struct inode's mapping->invalidate_lock for
+	 * free space inodes to prevent false positives related to locks for normal
+	 * inodes.
+	 */
+	lockdep_set_class(&(&inode->i_data)->invalidate_lock,
+			  &btrfs_free_space_inode_key);
+
 	ret = __load_free_space_cache(fs_info->tree_root, inode, &tmp_ctl,
 				      path, block_group->start);
 	btrfs_free_path(path);
-- 
2.35.1


  parent reply	other threads:[~2022-10-11 15:32 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-11 14:52 [PATCH AUTOSEL 5.15 01/26] arm64: dts: qcom: sdm845: narrow LLCC address space Sasha Levin
2022-10-11 14:52 ` [PATCH AUTOSEL 5.15 02/26] ARM: dts: imx7d-sdb: config the max pressure for tsc2046 Sasha Levin
2022-10-11 14:52 ` [PATCH AUTOSEL 5.15 03/26] soc: mediatek: Let PMIC Wrapper and SCPSYS depend on OF Sasha Levin
2022-10-11 14:52 ` [PATCH AUTOSEL 5.15 04/26] arm64: dts: qcom: sc7280-idp: correct ADC channel node name and unit address Sasha Levin
2022-10-11 14:52 ` [PATCH AUTOSEL 5.15 05/26] ARM: dts: imx6q: add missing properties for sram Sasha Levin
2022-10-11 14:52 ` [PATCH AUTOSEL 5.15 06/26] ARM: dts: imx6dl: " Sasha Levin
2022-10-11 14:52 ` [PATCH AUTOSEL 5.15 07/26] ARM: dts: imx6qp: " Sasha Levin
2022-10-11 14:52 ` [PATCH AUTOSEL 5.15 08/26] ARM: dts: imx6sl: " Sasha Levin
2022-10-11 14:52 ` [PATCH AUTOSEL 5.15 09/26] ARM: dts: imx6sll: " Sasha Levin
2022-10-11 14:52 ` [PATCH AUTOSEL 5.15 10/26] ARM: dts: imx6sx: " Sasha Levin
2022-10-11 14:52 ` [PATCH AUTOSEL 5.15 11/26] kselftest/arm64: Fix validatation termination record after EXTRA_CONTEXT Sasha Levin
2022-10-11 14:52 ` [PATCH AUTOSEL 5.15 12/26] sparc: Fix the generic IO helpers Sasha Levin
2022-10-11 14:52 ` [PATCH AUTOSEL 5.15 13/26] arm64: run softirqs on the per-CPU IRQ stack Sasha Levin
2022-10-11 14:52 ` [PATCH AUTOSEL 5.15 14/26] arm64: dts: imx8mq-librem5: Add bq25895 as max17055's power supply Sasha Levin
2022-10-11 14:52 ` [PATCH AUTOSEL 5.15 15/26] ARM: orion: fix include path Sasha Levin
2022-10-11 14:52 ` [PATCH AUTOSEL 5.15 16/26] btrfs: dump extra info if one free space cache has more bitmaps than it should Sasha Levin
2022-10-11 14:52 ` [PATCH AUTOSEL 5.15 17/26] btrfs: add macros for annotating wait events with lockdep Sasha Levin
2022-10-11 14:52 ` Sasha Levin [this message]
2022-10-11 14:52 ` [PATCH AUTOSEL 5.15 19/26] btrfs: scrub: try to fix super block errors Sasha Levin
2022-10-11 14:52 ` [PATCH AUTOSEL 5.15 20/26] btrfs: don't print information about space cache or tree every remount Sasha Levin
2022-10-11 14:52 ` [PATCH AUTOSEL 5.15 21/26] btrfs: check superblock to ensure the fs was not modified at thaw time Sasha Levin
2022-10-11 14:52 ` [PATCH AUTOSEL 5.15 22/26] btrfs: add KCSAN annotations for unlocked access to block_rsv->full Sasha Levin
2022-10-11 14:52 ` [PATCH AUTOSEL 5.15 23/26] btrfs: separate out the eb and extent state leak helpers Sasha Levin
2022-10-11 14:52 ` [PATCH AUTOSEL 5.15 24/26] arm64: dts: uniphier: Add USB-device support for PXs3 reference board Sasha Levin
2022-10-11 14:52 ` [PATCH AUTOSEL 5.15 25/26] ARM: 9242/1: kasan: Only map modules if CONFIG_KASAN_VMALLOC=n Sasha Levin
2022-10-11 14:52 ` [PATCH AUTOSEL 5.15 26/26] selftests/cpu-hotplug: Use return instead of exit Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221011145233.1624013-18-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=clm@fb.com \
    --cc=dsterba@suse.com \
    --cc=iangelak@fb.com \
    --cc=josef@toxicpanda.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).