Linux-BTRFS Archive on lore.kernel.org
 help / color / Atom feed
* potential data race on disk_i_size in two btrfs_endio_writer_helper()
@ 2019-11-28  3:44 Meng Xu
  0 siblings, 0 replies; only message in thread
From: Meng Xu @ 2019-11-28  3:44 UTC (permalink / raw)
  To: linux-btrfs

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, back to index

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-28  3:44 potential data race on disk_i_size in two btrfs_endio_writer_helper() Meng Xu

Linux-BTRFS Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-btrfs/0 linux-btrfs/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-btrfs linux-btrfs/ https://lore.kernel.org/linux-btrfs \
		linux-btrfs@vger.kernel.org
	public-inbox-index linux-btrfs

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-btrfs


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git