From: Ioannis Angelakopoulos <iangelak@fb.com>
To: <linux-btrfs@vger.kernel.org>, <kernel-team@fb.com>
Subject: [PATCH v3 5/6] btrfs: Change the lockdep class of struct inode's invalidate_lock
Date: Wed, 20 Jul 2022 16:38:23 -0700 [thread overview]
Message-ID: <20220720233818.3107724-6-iangelak@fb.com> (raw)
In-Reply-To: <20220720233818.3107724-1-iangelak@fb.com>
Reinitialize the class of the lockdep map for
inode->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.
Signed-off-by: Ioannis Angelakopoulos <iangelak@fb.com>
---
fs/btrfs/free-space-cache.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
index 996da650ecdc..a2b2329ae558 100644
--- a/fs/btrfs/free-space-cache.c
+++ b/fs/btrfs/free-space-cache.c
@@ -914,6 +914,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;
@@ -924,6 +926,7 @@ int load_free_space_cache(struct btrfs_block_group *block_group)
int ret = 0;
bool matched;
u64 used = block_group->used;
+ struct address_space *mapping;
/*
* Because we could potentially discard our loaded free space, we want
@@ -983,6 +986,14 @@ int load_free_space_cache(struct btrfs_block_group *block_group)
}
spin_unlock(&block_group->lock);
+ /*
+ * Reinitialize the class of the inode->mapping->invalidate_lock for free
+ * space inodes to prevent false positives related to locks for normal
+ * inodes.
+ */
+ mapping = &inode->i_data;
+ lockdep_set_class(&mapping->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.30.2
next prev parent reply other threads:[~2022-07-20 23:43 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-20 23:38 [PATCH v3 0/6] btrfs: Annotate wait events with lockdep Ioannis Angelakopoulos
2022-07-20 23:38 ` [PATCH v3 1/6] btrfs: Add a lockdep model for the num_writers wait event Ioannis Angelakopoulos
2022-07-21 0:42 ` Wang Yugui
2022-07-21 16:37 ` Ioannis Angelakopoulos
2022-07-20 23:38 ` [PATCH v3 2/6] btrfs: Add a lockdep model for the num_extwriters " Ioannis Angelakopoulos
2022-07-20 23:38 ` [PATCH v3 3/6] btrfs: Add lockdep models for the transaction states wait events Ioannis Angelakopoulos
2022-07-20 23:38 ` [PATCH v3 4/6] btrfs: Add a lockdep model for the pending_ordered wait event Ioannis Angelakopoulos
2022-07-20 23:38 ` Ioannis Angelakopoulos [this message]
2022-07-20 23:38 ` [PATCH v3 6/6] btrfs: Add a lockdep model for the ordered extents " Ioannis Angelakopoulos
2022-07-22 13:36 ` [PATCH v3 0/6] btrfs: Annotate wait events with lockdep Josef Bacik
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=20220720233818.3107724-6-iangelak@fb.com \
--to=iangelak@fb.com \
--cc=kernel-team@fb.com \
--cc=linux-btrfs@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