From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: fdmanana@kernel.org, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 2/3] btrfs: use READ_ONCE() when accessing delayed_node at btrfs_dirty_node()
Date: Sat, 18 May 2024 08:21:36 +0930 [thread overview]
Message-ID: <bdb528e7-8c1d-43bc-8236-a47d9c612983@gmx.com> (raw)
In-Reply-To: <68f8da7780333faba472e44689f977abd7222ffc.1715951291.git.fdmanana@suse.com>
在 2024/5/17 22:43, fdmanana@kernel.org 写道:
> From: Filipe Manana <fdmanana@suse.com>
>
> An inode's delayed_node is set while holding the root->delayed_nodes
> xarray's lock, so accessing it without holding the lock at
> btrfs_dirty_node() is racy and will likely trigger warnings from tools
> like KCSAN.
>
> Since we update the inode's delayed_node with WRITE_ONCE(), we can use
> READ_ONCE() without taking the lock, as we do in several other places
> at delayed-inode.c. So change btrfs_dirty_node() to use READ_ONCE().
>
> Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Thanks,
Qu
> ---
> fs/btrfs/inode.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
> index 000809e16aba..11cad22d7b4c 100644
> --- a/fs/btrfs/inode.c
> +++ b/fs/btrfs/inode.c
> @@ -6100,7 +6100,7 @@ static int btrfs_dirty_inode(struct btrfs_inode *inode)
> ret = btrfs_update_inode(trans, inode);
> }
> btrfs_end_transaction(trans);
> - if (inode->delayed_node)
> + if (READ_ONCE(inode->delayed_node))
> btrfs_balance_delayed_items(fs_info);
>
> return ret;
next prev parent reply other threads:[~2024-05-17 22:51 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-17 13:13 [PATCH 0/3] btrfs: avoid data races when accessing an inode's delayed_node fdmanana
2024-05-17 13:13 ` [PATCH 1/3] btrfs: always set an inode's delayed_inode with WRITE_ONCE() fdmanana
2024-05-17 22:51 ` Qu Wenruo
2024-05-17 13:13 ` [PATCH 2/3] btrfs: use READ_ONCE() when accessing delayed_node at btrfs_dirty_node() fdmanana
2024-05-17 22:51 ` Qu Wenruo [this message]
2024-05-17 13:13 ` [PATCH 3/3] btrfs: add and use helpers to get and set an inode's delayed_node fdmanana
2024-05-17 22:51 ` Qu Wenruo
2024-05-20 15:48 ` [PATCH 0/3] btrfs: avoid data races when accessing " David Sterba
2024-05-20 16:58 ` Filipe Manana
2024-05-20 20:20 ` David Sterba
2024-05-21 14:47 ` David Sterba
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=bdb528e7-8c1d-43bc-8236-a47d9c612983@gmx.com \
--to=quwenruo.btrfs@gmx.com \
--cc=fdmanana@kernel.org \
--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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).