From: Meng Xu <mengxu.gatech@gmail.com>
To: linux-btrfs@vger.kernel.org
Subject: potential data race on disk_i_size in two btrfs_endio_writer_helper()
Date: Wed, 27 Nov 2019 22:44:53 -0500 [thread overview]
Message-ID: <CAAwBoOJpmhs9dQHcVYorCeAW81JySM4fGFf8Rp9LJhvBtpCw3g@mail.gmail.com> (raw)
Hi Btrfs Developers,
I found a potential data race around the disk_i_size in btrfs inodes.
Following is the call stack in the helper threads.
[Thread 1]
btrfs_endio_write_helper
normal_work_helper
finish_ordered_fn
btrfs_finish_ordered_io
btrfs_ordered_update_i_size
[WRITE] BTRFS_I(inode)->disk_i_size = new_i_size;
[Thread 2]
btrfs_endio_write_helper
normal_work_helper
finish_ordered_fn
btrfs_finish_ordered_io
insert_reserved_file_extent
__btrfs_drop_extents
[READ] if (start >= BTRFS_I(inode)->disk_i_size && !replace_extent)
I can confirm that the read and write may happen in close proximity
(in time) and the READ may get either the old value or the new value
of the disk_i_size. Is this a valid data race or some operation
designed for lock-free accesses?
Best Regards,
Meng
reply other threads:[~2019-11-28 3:45 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=CAAwBoOJpmhs9dQHcVYorCeAW81JySM4fGFf8Rp9LJhvBtpCw3g@mail.gmail.com \
--to=mengxu.gatech@gmail.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;
as well as URLs for NNTP newsgroup(s).